diff mbox

[Branch,~glcompbench-dev/glcompbench/trunk] Rev 59: Update the brick shaders to avoid conditionals and extra function calls.

Message ID 20110905142013.21285.32586.launchpad@ackee.canonical.com
State Accepted
Headers show

Commit Message

alexandros.frantzis@linaro.org Sept. 5, 2011, 2:20 p.m. UTC
------------------------------------------------------------
revno: 59
author: Jesse Barker <jesse.barker@linaro.org>
committer: Alexandros Frantzis <alexandros.frantzis@linaro.org>
branch nick: brick2
timestamp: Fri 2011-07-29 13:28:24 -0700
message:
  Update the brick shaders to avoid conditionals and extra function calls.
modified:
  data/brick.frag
  data/brick.vert


--
lp:glcompbench
https://code.launchpad.net/~glcompbench-dev/glcompbench/trunk

You are subscribed to branch lp:glcompbench.
To unsubscribe from this branch go to https://code.launchpad.net/~glcompbench-dev/glcompbench/trunk/+edit-subscription
diff mbox

Patch

=== modified file 'data/brick.frag'
--- data/brick.frag	2011-07-18 17:14:16 +0000
+++ data/brick.frag	2011-07-29 20:28:24 +0000
@@ -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'
--- data/brick.vert	2011-07-18 17:14:16 +0000
+++ data/brick.vert	2011-07-29 20:28:24 +0000
@@ -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)));
 }