aboutsummaryrefslogtreecommitdiff
path: root/client/shaders/water_surface_shader/opengl_fragment.glsl
diff options
context:
space:
mode:
authorLoic Blot <loic.blot@unix-experience.fr>2015-01-15 23:11:56 +1000
committerCraig Robbins <kde.psych@gmail.com>2015-01-15 23:12:45 +1000
commit148fffb0f23fa437c67639ff3cc69177fb71d76a (patch)
treea121b619c9ebf6a087148a6426cfc0f2d3f9ede0 /client/shaders/water_surface_shader/opengl_fragment.glsl
parentbd0d7865909d2c7f3f2b0b1ba4900d763642af35 (diff)
downloadminetest-148fffb0f23fa437c67639ff3cc69177fb71d76a.tar.gz
minetest-148fffb0f23fa437c67639ff3cc69177fb71d76a.tar.bz2
minetest-148fffb0f23fa437c67639ff3cc69177fb71d76a.zip
Optimize bumpmapping mathematics
OpenGL_vertex: * bufferize a duplicate calcul * Factorize vertexes
Diffstat (limited to 'client/shaders/water_surface_shader/opengl_fragment.glsl')
-rw-r--r--client/shaders/water_surface_shader/opengl_fragment.glsl7
1 files changed, 6 insertions, 1 deletions
diff --git a/client/shaders/water_surface_shader/opengl_fragment.glsl b/client/shaders/water_surface_shader/opengl_fragment.glsl
index 2a1cbc568..7ef30cc52 100644
--- a/client/shaders/water_surface_shader/opengl_fragment.glsl
+++ b/client/shaders/water_surface_shader/opengl_fragment.glsl
@@ -87,7 +87,12 @@ vec4 base = texture2D(baseTexture, uv).rgba;
vec3 E = normalize(eyeVec);
float specular = pow(clamp(dot(reflect(L, bump.xyz), E), 0.0, 1.0),0.5);
float diffuse = dot(E,bump.xyz);
- color = 0.05*base.rgb + diffuse*base.rgb + 0.2*specular*base.rgb;
+ /* Mathematic optimization
+ * Original: color = 0.05*base.rgb + diffuse*base.rgb + 0.2*specular*base.rgb;
+ * This optimization save 2 multiplications (orig: 4 multiplications + 3 additions
+ * end: 2 multiplications + 3 additions)
+ */
+ color = (0.05 + diffuse + 0.2 * specular) * base.rgb
} else {
color = base.rgb;
}