summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Anholt <eric@anholt.net>2009-08-07 14:56:40 -0700
committerEric Anholt <eric@anholt.net>2009-08-07 14:57:40 -0700
commit1f1c9552340400b618f0cd9c25db256c62be7e62 (patch)
tree53472098b7f77fc8de06a4cf500675cca9831568
parent0d8ee697506809635cefa2bbf43f1e968fb752b2 (diff)
Clean up n_dot_l and n_dot_v < 0 clamping.
This is actually a significant performance improvement, by reducing extra comparisons and multiplies.
-rw-r--r--glass.frag5
1 files changed, 1 insertions, 4 deletions
diff --git a/glass.frag b/glass.frag
index 17fc9ad..0d5c129 100644
--- a/glass.frag
+++ b/glass.frag
@@ -61,9 +61,6 @@ void main()
Rs = 2 * schlick_fresnel(n_dot_l) * D /
sqrt(n_dot_l * n_dot_v) / (ward_m * ward_n);
- Rs *= step(0, n_dot_l);
- Rs *= step(0, n_dot_v);
-
float Rd = (1 - F0) * 2;
/* Ambient occlusion factor -- sample the height map we
* used to generate the normal map, and reduce intensity in
@@ -72,7 +69,7 @@ void main()
float heightmap = texture2D(heightmap_sampler, texcoord).x;
float Ra = Rd * (.8 + .2 * heightmap);
- gl_FragColor = n_dot_l * step(0, n_dot_l) *
+ gl_FragColor = max(0, n_dot_l) * step(0, n_dot_v) *
vec4(material_color.xyz *
((Rd * d + Rs * s) * Ii * shadow),
material_color.w) +