added morph_renderer
[demo] / gl_shaders / morphing.f.glsl
diff --git a/gl_shaders/morphing.f.glsl b/gl_shaders/morphing.f.glsl
new file mode 100644 (file)
index 0000000..490efab
--- /dev/null
@@ -0,0 +1,31 @@
+#version 450
+
+uniform sampler2D tex;
+
+uniform vec4 diffuse;
+uniform vec4 specular;
+uniform float shininess;
+
+varying vec3 pos;
+varying vec3 normal;
+varying vec3 ldir;
+varying vec2 tex_coord;
+
+out vec4 color;
+
+void main()
+{
+       vec3 p = normalize(pos);
+       vec3 n = normalize(normal);
+       vec3 l = normalize(ldir);
+
+       vec3 r = normalize(-reflect(l, n));
+       vec3 vdir = normalize(-p);
+
+       float cdiff = max(dot(l, n), 0.0);
+       float cspec = pow(max(dot(r, vdir), 0.0), shininess);
+
+       vec4 texel = texture2D(tex, tex_coord);
+       color.xyz = diffuse.xyz * cdiff * texel.xyz + specular.xyz * cspec;
+       color.w = 1.0;
+}