=== modified file 'data/brick.frag'
@@ -8,20 +8,8 @@
varying vec2 TextureCoord;
varying vec4 vertex_position;
-varying vec3 eye_direction;
varying vec4 light_position;
-vec3 unitvec(vec4 v1, vec4 v2)
-{
- if (v1.w == 0.0 && v2.w == 0.0)
- return vec3(v2 - v1);
- if (v1.w == 0.0)
- return vec3(-v1);
- if (v2.w == 0.0)
- return vec3(v2);
- return v2.xyz/v2.w - v1.xyz/v1.w;
-}
-
void main()
{
vec4 texel = texture2D(Texture0, TextureCoord);
@@ -31,12 +19,9 @@
position.x += 0.5;
}
position = fract(position);
- vec3 vertex_normal = vec3(0.0, 0.0, 1.0);
vec2 one = vec2(1.0, 1.0);
vec2 whereami = smoothstep(BrickPct, one, position);
- bvec2 inmortar = bvec2(whereami);
-
-
+ vec3 vertex_normal = vec3(0.0, 0.0, 1.0);
if (whereami.x > 0.0 && whereami.x < 0.5)
vertex_normal.x = (2.0 * pow(whereami.x, 2.0)) + 0.1;
else if (whereami.x > 0.0 && whereami.x < 1.0)
@@ -51,8 +36,9 @@
vec4 matAmbient = vec4(0.1, 0.1, 0.1, 1.0);
vec4 matDiffuse = vec4(texel.xyz, 0.5);
vec4 matSpecular = vec4(1.0, 1.0, 1.0, 1.0);
- float matShininess = 30.0;
- vec3 light_direction = normalize(unitvec(vertex_position, light_position));
+ float matShininess = 10.0;
+ vec3 eye_direction = normalize(-vertex_position.xyz);
+ vec3 light_direction = normalize(light_position.xyz);
vec3 normalized_normal = normalize(vertex_normal);
vec3 reflection = reflect(-light_direction, normalized_normal);
float specularTerm = pow(max(0.0, dot(reflection, eye_direction)), matShininess);
=== modified file 'data/brick.vert'
@@ -9,21 +9,9 @@
attribute vec2 texcoord;
varying vec4 vertex_position;
-varying vec3 eye_direction;
varying vec4 light_position;
varying vec2 TextureCoord;
-vec3 unitvec(vec4 v1, vec4 v2)
-{
- if (v1.w == 0.0 && v2.w == 0.0)
- return vec3(v2 - v1);
- if (v1.w == 0.0)
- return vec3(-v1);
- if (v2.w == 0.0)
- return vec3(v2);
- return v2.xyz/v2.w - v1.xyz/v1.w;
-}
-
void main()
{
vec4 curVertex = vec4(position.x, position.y, position.z, 1.0);
@@ -31,5 +19,4 @@
TextureCoord = texcoord;
light_position = modelview * LightPosition;
vertex_position = modelview * curVertex;
- eye_direction = normalize(unitvec(vertex_position, vec4(0.0, 0.0, 0.0, 1.0)));
}