=== modified file 'data/shaders/buffer-wireframe.frag'
@@ -1,17 +1,17 @@
-varying vec4 dist;
-
-const vec4 LINE_COLOR = vec4(1.0);
-const vec4 TRIANGLE_COLOR = vec4(0.0, 0.5, 0.8, 0.8);
-
-void main(void)
-{
- // Get the minimum distance of this fragment from a triangle edge.
- // We need to multiply with dist.w to undo the workaround we had
- // to perform to get linear interpolation (instead of perspective correct).
- float d = min(dist.x * dist.w, min(dist.y * dist.w, dist.z * dist.w));
-
- // Get the intensity of the wireframe line
- float I = exp2(-2.0 * d * d);
-
- gl_FragColor = mix(TRIANGLE_COLOR, LINE_COLOR, I);
-}
+varying vec4 dist;
+
+const vec4 LINE_COLOR = vec4(1.0);
+const vec4 TRIANGLE_COLOR = vec4(0.0, 0.5, 0.8, 0.8);
+
+void main(void)
+{
+ // Get the minimum distance of this fragment from a triangle edge.
+ // We need to multiply with dist.w to undo the workaround we had
+ // to perform to get linear interpolation (instead of perspective correct).
+ float d = min(dist.x * dist.w, min(dist.y * dist.w, dist.z * dist.w));
+
+ // Get the intensity of the wireframe line
+ float I = exp2(-2.0 * d * d);
+
+ gl_FragColor = mix(TRIANGLE_COLOR, LINE_COLOR, I);
+}
=== modified file 'data/shaders/buffer-wireframe.vert'
@@ -1,57 +1,57 @@
-// Wireframe shader based on:
-// J. A. Bærentzen, S. Munk-Lund, M. Gjøl, and B. D. Larsen,
-// “Two methods for antialiased wireframe drawing with hidden
-// line removal,” in Proceedings of the Spring Conference in
-// Computer Graphics, 2008.
-//
-// We are not using geometry shaders, though, as they are not
-// available in GLES 2.0.
-
-attribute vec3 position;
-// Coordinates of the triangle vertices this vertex belongs to
-attribute vec3 tvertex0;
-attribute vec3 tvertex1;
-attribute vec3 tvertex2;
-
-uniform vec2 Viewport;
-uniform mat4 ModelViewProjectionMatrix;
-
-varying vec4 dist;
-
-void main(void)
-{
- // Get the clip coordinates of all vertices
- vec4 pos = ModelViewProjectionMatrix * vec4(position, 1.0);
- vec4 pos0 = ModelViewProjectionMatrix * vec4(tvertex0, 1.0);
- vec4 pos1 = ModelViewProjectionMatrix * vec4(tvertex1, 1.0);
- vec4 pos2 = ModelViewProjectionMatrix * vec4(tvertex2, 1.0);
-
- // Get the screen coordinates of all vertices
- vec3 p = vec3(0.5 * Viewport * (pos.xy / pos.w), 0.0);
- vec3 p0 = vec3(0.5 * Viewport * (pos0.xy / pos0.w), 0.0);
- vec3 p1 = vec3(0.5 * Viewport * (pos1.xy / pos1.w), 0.0);
- vec3 p2 = vec3(0.5 * Viewport * (pos2.xy / pos2.w), 0.0);
-
- // Get the vectors representing the edges of the current
- // triangle primitive. 'vN' is the edge opposite vertex N.
- vec3 v0 = p2 - p1;
- vec3 v1 = p2 - p0;
- vec3 v2 = p1 - p0;
-
- // Calculate the distance of the current vertex from all
- // the triangle edges. The distance of point p from line
- // v is length(cross(p - p1, v)) / length(v), where
- // p1 is any of the two edge points of v.
- float d0 = length(cross(p - p1, v0)) / length(v0);
- float d1 = length(cross(p - p2, v1)) / length(v1);
- float d2 = length(cross(p - p0, v2)) / length(v2);
-
- // OpenGL(ES) performs perspective-correct interpolation
- // (it divides by .w) but we want linear interpolation. To
- // work around this, we premultiply by pos.w here and then
- // multiple with the inverse (stored in dist.w) in the fragment
- // shader to undo this operation.
- dist = vec4(pos.w * d0, pos.w * d1, pos.w * d2, 1.0 / pos.w);
-
- gl_Position = pos;
-}
+// Wireframe shader based on:
+// J. A. Bærentzen, S. Munk-Lund, M. Gjøl, and B. D. Larsen,
+// “Two methods for antialiased wireframe drawing with hidden
+// line removal,” in Proceedings of the Spring Conference in
+// Computer Graphics, 2008.
+//
+// We are not using geometry shaders, though, as they are not
+// available in GLES 2.0.
+
+attribute vec3 position;
+// Coordinates of the triangle vertices this vertex belongs to
+attribute vec3 tvertex0;
+attribute vec3 tvertex1;
+attribute vec3 tvertex2;
+
+uniform vec2 Viewport;
+uniform mat4 ModelViewProjectionMatrix;
+
+varying vec4 dist;
+
+void main(void)
+{
+ // Get the clip coordinates of all vertices
+ vec4 pos = ModelViewProjectionMatrix * vec4(position, 1.0);
+ vec4 pos0 = ModelViewProjectionMatrix * vec4(tvertex0, 1.0);
+ vec4 pos1 = ModelViewProjectionMatrix * vec4(tvertex1, 1.0);
+ vec4 pos2 = ModelViewProjectionMatrix * vec4(tvertex2, 1.0);
+
+ // Get the screen coordinates of all vertices
+ vec3 p = vec3(0.5 * Viewport * (pos.xy / pos.w), 0.0);
+ vec3 p0 = vec3(0.5 * Viewport * (pos0.xy / pos0.w), 0.0);
+ vec3 p1 = vec3(0.5 * Viewport * (pos1.xy / pos1.w), 0.0);
+ vec3 p2 = vec3(0.5 * Viewport * (pos2.xy / pos2.w), 0.0);
+
+ // Get the vectors representing the edges of the current
+ // triangle primitive. 'vN' is the edge opposite vertex N.
+ vec3 v0 = p2 - p1;
+ vec3 v1 = p2 - p0;
+ vec3 v2 = p1 - p0;
+
+ // Calculate the distance of the current vertex from all
+ // the triangle edges. The distance of point p from line
+ // v is length(cross(p - p1, v)) / length(v), where
+ // p1 is any of the two edge points of v.
+ float d0 = length(cross(p - p1, v0)) / length(v0);
+ float d1 = length(cross(p - p2, v1)) / length(v1);
+ float d2 = length(cross(p - p0, v2)) / length(v2);
+
+ // OpenGL(ES) performs perspective-correct interpolation
+ // (it divides by .w) but we want linear interpolation. To
+ // work around this, we premultiply by pos.w here and then
+ // multiple with the inverse (stored in dist.w) in the fragment
+ // shader to undo this operation.
+ dist = vec4(pos.w * d0, pos.w * d1, pos.w * d2, 1.0 / pos.w);
+
+ gl_Position = pos;
+}
=== modified file 'data/shaders/bump-normals.frag'
@@ -1,44 +1,44 @@
-uniform sampler2D NormalMap;
-uniform mat4 NormalMatrix;
-
-varying vec2 TextureCoord;
-
-void main(void)
-{
- const vec4 LightSourceAmbient = vec4(0.1, 0.1, 0.1, 1.0);
- const vec4 LightSourceDiffuse = vec4(0.8, 0.8, 0.8, 1.0);
- const vec4 LightSourceSpecular = vec4(0.8, 0.8, 0.8, 1.0);
- const vec4 MaterialAmbient = vec4(1.0, 1.0, 1.0, 1.0);
- const vec4 MaterialDiffuse = vec4(1.0, 1.0, 1.0, 1.0);
- const vec4 MaterialSpecular = vec4(0.2, 0.2, 0.2, 1.0);
- const float MaterialShininess = 100.0;
-
- // Get the raw normal XYZ data from the normal map
- vec3 normal_raw = texture2D(NormalMap, TextureCoord).xyz;
- // Map "color" range [0, 1.0] to normal range [-1.0, 1.0]
- vec3 normal_scaled = normal_raw * 2.0 - 1.0;
-
- // Convert the normal to eye coordinates. Note that the normal map
- // we are using is using object coordinates (not tangent!) for the
- // normals, so we can multiply by the NormalMatrix as usual.
- vec3 N = normalize(vec3(NormalMatrix * vec4(normal_scaled, 1.0)));
-
- // In the lighting model we are using here (Blinn-Phong with light at
- // infinity, viewer at infinity), the light position/direction and the
- // half vector is constant for the all the fragments.
- vec3 L = normalize(LightSourcePosition.xyz);
- vec3 H = normalize(LightSourceHalfVector);
-
- // Calculate the diffuse color according to Lambertian reflectance
- vec4 diffuse = MaterialDiffuse * LightSourceDiffuse * max(dot(N, L), 0.0);
-
- // Calculate the ambient color
- vec4 ambient = MaterialAmbient * LightSourceAmbient;
-
- // Calculate the specular color according to the Blinn-Phong model
- vec4 specular = MaterialSpecular * LightSourceSpecular *
- pow(max(dot(N,H), 0.0), MaterialShininess);
-
- // Calculate the final color
- gl_FragColor = ambient + specular + diffuse;
-}
+uniform sampler2D NormalMap;
+uniform mat4 NormalMatrix;
+
+varying vec2 TextureCoord;
+
+void main(void)
+{
+ const vec4 LightSourceAmbient = vec4(0.1, 0.1, 0.1, 1.0);
+ const vec4 LightSourceDiffuse = vec4(0.8, 0.8, 0.8, 1.0);
+ const vec4 LightSourceSpecular = vec4(0.8, 0.8, 0.8, 1.0);
+ const vec4 MaterialAmbient = vec4(1.0, 1.0, 1.0, 1.0);
+ const vec4 MaterialDiffuse = vec4(1.0, 1.0, 1.0, 1.0);
+ const vec4 MaterialSpecular = vec4(0.2, 0.2, 0.2, 1.0);
+ const float MaterialShininess = 100.0;
+
+ // Get the raw normal XYZ data from the normal map
+ vec3 normal_raw = texture2D(NormalMap, TextureCoord).xyz;
+ // Map "color" range [0, 1.0] to normal range [-1.0, 1.0]
+ vec3 normal_scaled = normal_raw * 2.0 - 1.0;
+
+ // Convert the normal to eye coordinates. Note that the normal map
+ // we are using is using object coordinates (not tangent!) for the
+ // normals, so we can multiply by the NormalMatrix as usual.
+ vec3 N = normalize(vec3(NormalMatrix * vec4(normal_scaled, 1.0)));
+
+ // In the lighting model we are using here (Blinn-Phong with light at
+ // infinity, viewer at infinity), the light position/direction and the
+ // half vector is constant for the all the fragments.
+ vec3 L = normalize(LightSourcePosition.xyz);
+ vec3 H = normalize(LightSourceHalfVector);
+
+ // Calculate the diffuse color according to Lambertian reflectance
+ vec4 diffuse = MaterialDiffuse * LightSourceDiffuse * max(dot(N, L), 0.0);
+
+ // Calculate the ambient color
+ vec4 ambient = MaterialAmbient * LightSourceAmbient;
+
+ // Calculate the specular color according to the Blinn-Phong model
+ vec4 specular = MaterialSpecular * LightSourceSpecular *
+ pow(max(dot(N,H), 0.0), MaterialShininess);
+
+ // Calculate the final color
+ gl_FragColor = ambient + specular + diffuse;
+}
=== modified file 'data/shaders/bump-normals.vert'
@@ -1,14 +1,14 @@
-attribute vec3 position;
-attribute vec2 texcoord;
-
-uniform mat4 ModelViewProjectionMatrix;
-
-varying vec2 TextureCoord;
-
-void main(void)
-{
- TextureCoord = texcoord;
-
- // Transform the position to clip coordinates
- gl_Position = ModelViewProjectionMatrix * vec4(position, 1.0);
-}
+attribute vec3 position;
+attribute vec2 texcoord;
+
+uniform mat4 ModelViewProjectionMatrix;
+
+varying vec2 TextureCoord;
+
+void main(void)
+{
+ TextureCoord = texcoord;
+
+ // Transform the position to clip coordinates
+ gl_Position = ModelViewProjectionMatrix * vec4(position, 1.0);
+}
=== modified file 'data/shaders/bump-poly.frag'
@@ -1,33 +1,33 @@
-varying vec3 Normal;
-
-void main(void)
-{
- const vec4 LightSourceAmbient = vec4(0.1, 0.1, 0.1, 1.0);
- const vec4 LightSourceDiffuse = vec4(0.8, 0.8, 0.8, 1.0);
- const vec4 LightSourceSpecular = vec4(0.8, 0.8, 0.8, 1.0);
- const vec4 MaterialAmbient = vec4(1.0, 1.0, 1.0, 1.0);
- const vec4 MaterialDiffuse = vec4(1.0, 1.0, 1.0, 1.0);
- const vec4 MaterialSpecular = vec4(0.2, 0.2, 0.2, 1.0);
- const float MaterialShininess = 100.0;
-
- vec3 N = normalize(Normal);
-
- // In the lighting model we are using here (Blinn-Phong with light at
- // infinity, viewer at infinity), the light position/direction and the
- // half vector is constant for the all the fragments.
- vec3 L = normalize(LightSourcePosition.xyz);
- vec3 H = normalize(LightSourceHalfVector);
-
- // Calculate the diffuse color according to Lambertian reflectance
- vec4 diffuse = MaterialDiffuse * LightSourceDiffuse * max(dot(N, L), 0.0);
-
- // Calculate the ambient color
- vec4 ambient = MaterialAmbient * LightSourceAmbient;
-
- // Calculate the specular color according to the Blinn-Phong model
- vec4 specular = MaterialSpecular * LightSourceSpecular *
- pow(max(dot(N,H), 0.0), MaterialShininess);
-
- // Calculate the final color
- gl_FragColor = ambient + specular + diffuse;
-}
+varying vec3 Normal;
+
+void main(void)
+{
+ const vec4 LightSourceAmbient = vec4(0.1, 0.1, 0.1, 1.0);
+ const vec4 LightSourceDiffuse = vec4(0.8, 0.8, 0.8, 1.0);
+ const vec4 LightSourceSpecular = vec4(0.8, 0.8, 0.8, 1.0);
+ const vec4 MaterialAmbient = vec4(1.0, 1.0, 1.0, 1.0);
+ const vec4 MaterialDiffuse = vec4(1.0, 1.0, 1.0, 1.0);
+ const vec4 MaterialSpecular = vec4(0.2, 0.2, 0.2, 1.0);
+ const float MaterialShininess = 100.0;
+
+ vec3 N = normalize(Normal);
+
+ // In the lighting model we are using here (Blinn-Phong with light at
+ // infinity, viewer at infinity), the light position/direction and the
+ // half vector is constant for the all the fragments.
+ vec3 L = normalize(LightSourcePosition.xyz);
+ vec3 H = normalize(LightSourceHalfVector);
+
+ // Calculate the diffuse color according to Lambertian reflectance
+ vec4 diffuse = MaterialDiffuse * LightSourceDiffuse * max(dot(N, L), 0.0);
+
+ // Calculate the ambient color
+ vec4 ambient = MaterialAmbient * LightSourceAmbient;
+
+ // Calculate the specular color according to the Blinn-Phong model
+ vec4 specular = MaterialSpecular * LightSourceSpecular *
+ pow(max(dot(N,H), 0.0), MaterialShininess);
+
+ // Calculate the final color
+ gl_FragColor = ambient + specular + diffuse;
+}
=== modified file 'data/shaders/bump-poly.vert'
@@ -1,16 +1,16 @@
-attribute vec3 position;
-attribute vec3 normal;
-
-uniform mat4 ModelViewProjectionMatrix;
-uniform mat4 NormalMatrix;
-
-varying vec3 Normal;
-
-void main(void)
-{
- // Transform the normal to eye coordinates
- Normal = normalize(vec3(NormalMatrix * vec4(normal, 1.0)));
-
- // Transform the position to clip coordinates
- gl_Position = ModelViewProjectionMatrix * vec4(position, 1.0);
-}
+attribute vec3 position;
+attribute vec3 normal;
+
+uniform mat4 ModelViewProjectionMatrix;
+uniform mat4 NormalMatrix;
+
+varying vec3 Normal;
+
+void main(void)
+{
+ // Transform the normal to eye coordinates
+ Normal = normalize(vec3(NormalMatrix * vec4(normal, 1.0)));
+
+ // Transform the position to clip coordinates
+ gl_Position = ModelViewProjectionMatrix * vec4(position, 1.0);
+}
=== modified file 'data/shaders/desktop.vert'
@@ -1,11 +1,11 @@
-attribute vec2 position;
-attribute vec2 texcoord;
-
-varying vec2 TextureCoord;
-
-void main(void)
-{
- gl_Position = vec4(position, 0.0, 1.0);
-
- TextureCoord = texcoord;
-}
+attribute vec2 position;
+attribute vec2 texcoord;
+
+varying vec2 TextureCoord;
+
+void main(void)
+{
+ gl_Position = vec4(position, 0.0, 1.0);
+
+ TextureCoord = texcoord;
+}
=== modified file 'data/shaders/effect-2d.vert'
@@ -1,10 +1,10 @@
-attribute vec3 position;
-
-varying vec2 TextureCoord;
-
-void main(void)
-{
- gl_Position = vec4(position, 1.0);
-
- TextureCoord = position.xy * 0.5 + 0.5;
-}
+attribute vec3 position;
+
+varying vec2 TextureCoord;
+
+void main(void)
+{
+ gl_Position = vec4(position, 1.0);
+
+ TextureCoord = position.xy * 0.5 + 0.5;
+}
=== modified file 'data/shaders/light-advanced.frag'
@@ -1,33 +1,33 @@
-varying vec3 Normal;
-
-void main(void)
-{
- const vec4 LightSourceAmbient = vec4(0.1, 0.1, 0.1, 1.0);
- const vec4 LightSourceDiffuse = vec4(0.8, 0.8, 0.8, 1.0);
- const vec4 LightSourceSpecular = vec4(0.8, 0.8, 0.8, 1.0);
- const vec4 MaterialAmbient = vec4(1.0, 1.0, 1.0, 1.0);
- const vec4 MaterialDiffuse = vec4(0.0, 0.0, 1.0, 1.0);
- const vec4 MaterialSpecular = vec4(1.0, 1.0, 1.0, 1.0);
- const float MaterialShininess = 100.0;
-
- vec3 N = normalize(Normal);
-
- // In the lighting model we are using here (Blinn-Phong with light at
- // infinity, viewer at infinity), the light position/direction and the
- // half vector is constant for the all the fragments.
- vec3 L = normalize(LightSourcePosition.xyz);
- vec3 H = normalize(LightSourceHalfVector);
-
- // Calculate the diffuse color according to Lambertian reflectance
- vec4 diffuse = MaterialDiffuse * LightSourceDiffuse * max(dot(N, L), 0.0);
-
- // Calculate the ambient color
- vec4 ambient = MaterialAmbient * LightSourceAmbient;
-
- // Calculate the specular color according to the Blinn-Phong model
- vec4 specular = MaterialSpecular * LightSourceSpecular *
- pow(max(dot(N,H), 0.0), MaterialShininess);
-
- // Calculate the final color
- gl_FragColor = ambient + specular + diffuse;
-}
+varying vec3 Normal;
+
+void main(void)
+{
+ const vec4 LightSourceAmbient = vec4(0.1, 0.1, 0.1, 1.0);
+ const vec4 LightSourceDiffuse = vec4(0.8, 0.8, 0.8, 1.0);
+ const vec4 LightSourceSpecular = vec4(0.8, 0.8, 0.8, 1.0);
+ const vec4 MaterialAmbient = vec4(1.0, 1.0, 1.0, 1.0);
+ const vec4 MaterialDiffuse = vec4(0.0, 0.0, 1.0, 1.0);
+ const vec4 MaterialSpecular = vec4(1.0, 1.0, 1.0, 1.0);
+ const float MaterialShininess = 100.0;
+
+ vec3 N = normalize(Normal);
+
+ // In the lighting model we are using here (Blinn-Phong with light at
+ // infinity, viewer at infinity), the light position/direction and the
+ // half vector is constant for the all the fragments.
+ vec3 L = normalize(LightSourcePosition.xyz);
+ vec3 H = normalize(LightSourceHalfVector);
+
+ // Calculate the diffuse color according to Lambertian reflectance
+ vec4 diffuse = MaterialDiffuse * LightSourceDiffuse * max(dot(N, L), 0.0);
+
+ // Calculate the ambient color
+ vec4 ambient = MaterialAmbient * LightSourceAmbient;
+
+ // Calculate the specular color according to the Blinn-Phong model
+ vec4 specular = MaterialSpecular * LightSourceSpecular *
+ pow(max(dot(N,H), 0.0), MaterialShininess);
+
+ // Calculate the final color
+ gl_FragColor = ambient + specular + diffuse;
+}
=== modified file 'data/shaders/light-advanced.vert'
@@ -1,16 +1,16 @@
-attribute vec3 position;
-attribute vec3 normal;
-
-uniform mat4 ModelViewProjectionMatrix;
-uniform mat4 NormalMatrix;
-
-varying vec3 Normal;
-
-void main(void)
-{
- // Transform the normal to eye coordinates
- Normal = normalize(vec3(NormalMatrix * vec4(normal, 1.0)));
-
- // Transform the position to clip coordinates
- gl_Position = ModelViewProjectionMatrix * vec4(position, 1.0);
-}
+attribute vec3 position;
+attribute vec3 normal;
+
+uniform mat4 ModelViewProjectionMatrix;
+uniform mat4 NormalMatrix;
+
+varying vec3 Normal;
+
+void main(void)
+{
+ // Transform the normal to eye coordinates
+ Normal = normalize(vec3(NormalMatrix * vec4(normal, 1.0)));
+
+ // Transform the position to clip coordinates
+ gl_Position = ModelViewProjectionMatrix * vec4(position, 1.0);
+}
=== modified file 'data/shaders/light-basic.frag'
@@ -1,7 +1,7 @@
-varying vec4 Color;
-varying vec2 TextureCoord;
-
-void main(void)
-{
- gl_FragColor = Color;
-}
+varying vec4 Color;
+varying vec2 TextureCoord;
+
+void main(void)
+{
+ gl_FragColor = Color;
+}
=== modified file 'data/shaders/light-basic.vert'
@@ -1,29 +1,29 @@
-attribute vec3 position;
-attribute vec3 normal;
-attribute vec2 texcoord;
-
-uniform mat4 ModelViewProjectionMatrix;
-uniform mat4 NormalMatrix;
-
-varying vec4 Color;
-varying vec2 TextureCoord;
-
-void main(void)
-{
- // Transform the normal to eye coordinates
- vec3 N = normalize(vec3(NormalMatrix * vec4(normal, 1.0)));
-
- // The LightSourcePosition is actually its direction for directional light
- vec3 L = normalize(LightSourcePosition.xyz);
-
- // Multiply the diffuse value by the vertex color (which is fixed in this case)
- // to get the actual color that we will use to draw this vertex with
- float diffuse = max(dot(N, L), 0.0);
- Color = diffuse * MaterialDiffuse;
-
- // Set the texture coordinates as a varying
- TextureCoord = texcoord;
-
- // Transform the position to clip coordinates
- gl_Position = ModelViewProjectionMatrix * vec4(position, 1.0);
-}
+attribute vec3 position;
+attribute vec3 normal;
+attribute vec2 texcoord;
+
+uniform mat4 ModelViewProjectionMatrix;
+uniform mat4 NormalMatrix;
+
+varying vec4 Color;
+varying vec2 TextureCoord;
+
+void main(void)
+{
+ // Transform the normal to eye coordinates
+ vec3 N = normalize(vec3(NormalMatrix * vec4(normal, 1.0)));
+
+ // The LightSourcePosition is actually its direction for directional light
+ vec3 L = normalize(LightSourcePosition.xyz);
+
+ // Multiply the diffuse value by the vertex color (which is fixed in this case)
+ // to get the actual color that we will use to draw this vertex with
+ float diffuse = max(dot(N, L), 0.0);
+ Color = diffuse * MaterialDiffuse;
+
+ // Set the texture coordinates as a varying
+ TextureCoord = texcoord;
+
+ // Transform the position to clip coordinates
+ gl_Position = ModelViewProjectionMatrix * vec4(position, 1.0);
+}
=== modified file 'data/shaders/light-phong.frag'
@@ -1,29 +1,29 @@
-varying vec3 vertex_normal;
-varying vec4 vertex_position;
-
-vec4
-compute_color(vec4 light_position, vec4 diffuse_light_color)
-{
- const vec4 lightAmbient = vec4(0.1, 0.1, 0.1, 1.0);
- const vec4 lightSpecular = vec4(0.8, 0.8, 0.8, 1.0);
- const vec4 matAmbient = vec4(0.2, 0.2, 0.2, 1.0);
- const vec4 matSpecular = vec4(1.0, 1.0, 1.0, 1.0);
- const float matShininess = 100.0;
- vec3 eye_direction = normalize(-vertex_position.xyz);
- vec3 light_direction = normalize(light_position.xyz/light_position.w -
- vertex_position.xyz/vertex_position.w);
- vec3 normalized_normal = normalize(vertex_normal);
- vec3 reflection = reflect(-light_direction, normalized_normal);
- float specularTerm = pow(max(0.0, dot(reflection, eye_direction)), matShininess);
- float diffuseTerm = max(0.0, dot(normalized_normal, light_direction));
- vec4 specular = (lightSpecular * matSpecular);
- vec4 ambient = (lightAmbient * matAmbient);
- vec4 diffuse = (diffuse_light_color * MaterialDiffuse);
- vec4 result = (specular * specularTerm) + ambient + (diffuse * diffuseTerm);
- return result;
-}
-
-void main(void)
-{
-$DO_LIGHTS$
-}
+varying vec3 vertex_normal;
+varying vec4 vertex_position;
+
+vec4
+compute_color(vec4 light_position, vec4 diffuse_light_color)
+{
+ const vec4 lightAmbient = vec4(0.1, 0.1, 0.1, 1.0);
+ const vec4 lightSpecular = vec4(0.8, 0.8, 0.8, 1.0);
+ const vec4 matAmbient = vec4(0.2, 0.2, 0.2, 1.0);
+ const vec4 matSpecular = vec4(1.0, 1.0, 1.0, 1.0);
+ const float matShininess = 100.0;
+ vec3 eye_direction = normalize(-vertex_position.xyz);
+ vec3 light_direction = normalize(light_position.xyz/light_position.w -
+ vertex_position.xyz/vertex_position.w);
+ vec3 normalized_normal = normalize(vertex_normal);
+ vec3 reflection = reflect(-light_direction, normalized_normal);
+ float specularTerm = pow(max(0.0, dot(reflection, eye_direction)), matShininess);
+ float diffuseTerm = max(0.0, dot(normalized_normal, light_direction));
+ vec4 specular = (lightSpecular * matSpecular);
+ vec4 ambient = (lightAmbient * matAmbient);
+ vec4 diffuse = (diffuse_light_color * MaterialDiffuse);
+ vec4 result = (specular * specularTerm) + ambient + (diffuse * diffuseTerm);
+ return result;
+}
+
+void main(void)
+{
+$DO_LIGHTS$
+}
=== modified file 'data/shaders/light-phong.vert'
@@ -1,23 +1,23 @@
-attribute vec3 position;
-attribute vec3 normal;
-
-uniform mat4 ModelViewProjectionMatrix;
-uniform mat4 NormalMatrix;
-uniform mat4 ModelViewMatrix;
-
-varying vec3 vertex_normal;
-varying vec4 vertex_position;
-
-void main(void)
-{
- vec4 current_position = vec4(position, 1.0);
-
- // Transform the normal to eye coordinates
- vertex_normal = normalize(vec3(NormalMatrix * vec4(normal, 1.0)));
-
- // Transform the current position to eye coordinates
- vertex_position = ModelViewMatrix * current_position;
-
- // Transform the current position to clip coordinates
- gl_Position = ModelViewProjectionMatrix * current_position;
-}
+attribute vec3 position;
+attribute vec3 normal;
+
+uniform mat4 ModelViewProjectionMatrix;
+uniform mat4 NormalMatrix;
+uniform mat4 ModelViewMatrix;
+
+varying vec3 vertex_normal;
+varying vec4 vertex_position;
+
+void main(void)
+{
+ vec4 current_position = vec4(position, 1.0);
+
+ // Transform the normal to eye coordinates
+ vertex_normal = normalize(vec3(NormalMatrix * vec4(normal, 1.0)));
+
+ // Transform the current position to eye coordinates
+ vertex_position = ModelViewMatrix * current_position;
+
+ // Transform the current position to clip coordinates
+ gl_Position = ModelViewProjectionMatrix * current_position;
+}
=== modified file 'data/shaders/pulsar-light.vert'
@@ -1,31 +1,31 @@
-attribute vec3 position;
-attribute vec3 normal;
-attribute vec4 vtxcolor;
-attribute vec2 texcoord;
-
-uniform mat4 ModelViewProjectionMatrix;
-uniform mat4 NormalMatrix;
-
-varying vec4 Color;
-varying vec2 TextureCoord;
-
-void main(void)
-{
- // Transform the normal to eye coordinates
- vec3 N = normalize(vec3(NormalMatrix * vec4(normal, 1.0)));
-
- // The LightSourcePosition is actually its direction for directional light
- vec3 L = normalize(LightSourcePosition.xyz);
-
- // Multiply the diffuse value by the vertex color
- // to get the actual color that we will use to draw this vertex with
- float diffuse = max(abs(dot(N, L)), 0.0);
- Color = diffuse * vtxcolor;
-
- // Set the texture coordinates as a varying
- TextureCoord = texcoord;
-
- // Transform the position to clip coordinates
- gl_Position = ModelViewProjectionMatrix * vec4(position, 1.0);
-}
-
+attribute vec3 position;
+attribute vec3 normal;
+attribute vec4 vtxcolor;
+attribute vec2 texcoord;
+
+uniform mat4 ModelViewProjectionMatrix;
+uniform mat4 NormalMatrix;
+
+varying vec4 Color;
+varying vec2 TextureCoord;
+
+void main(void)
+{
+ // Transform the normal to eye coordinates
+ vec3 N = normalize(vec3(NormalMatrix * vec4(normal, 1.0)));
+
+ // The LightSourcePosition is actually its direction for directional light
+ vec3 L = normalize(LightSourcePosition.xyz);
+
+ // Multiply the diffuse value by the vertex color
+ // to get the actual color that we will use to draw this vertex with
+ float diffuse = max(abs(dot(N, L)), 0.0);
+ Color = diffuse * vtxcolor;
+
+ // Set the texture coordinates as a varying
+ TextureCoord = texcoord;
+
+ // Transform the position to clip coordinates
+ gl_Position = ModelViewProjectionMatrix * vec4(position, 1.0);
+}
+
=== modified file 'data/shaders/pulsar.vert'
@@ -1,19 +1,19 @@
-attribute vec3 position;
-attribute vec4 vtxcolor;
-attribute vec2 texcoord;
-attribute vec3 normal;
-
-uniform mat4 ModelViewProjectionMatrix;
-
-varying vec4 Color;
-varying vec2 TextureCoord;
-
-void main(void)
-{
- Color = vtxcolor;
- TextureCoord = texcoord;
-
- // Transform the position to clip coordinates
- gl_Position = ModelViewProjectionMatrix * vec4(position, 1.0);
-}
-
+attribute vec3 position;
+attribute vec4 vtxcolor;
+attribute vec2 texcoord;
+attribute vec3 normal;
+
+uniform mat4 ModelViewProjectionMatrix;
+
+varying vec4 Color;
+varying vec2 TextureCoord;
+
+void main(void)
+{
+ Color = vtxcolor;
+ TextureCoord = texcoord;
+
+ // Transform the position to clip coordinates
+ gl_Position = ModelViewProjectionMatrix * vec4(position, 1.0);
+}
+