mirror of https://github.com/minetest/minetest.git
Optimize bumpmapping mathematics
This commit is contained in:
parent
c367f7301a
commit
acb22b4597
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue