@@ -4,9 +4,8 @@
#define LOG2 1.442695
#define EPSILON 1e-6
-#define square(a) a * a
#define saturate(a) clamp( a, 0.0, 1.0 )
-#define whiteCompliment(a) 1.0 - saturate( a )
+#define whiteCompliment(a) ( 1.0 - saturate( a ) )
vec3 transformDirection( in vec3 normal, in mat4 matrix ) {
@@ -12,7 +12,7 @@
#ifdef FOG_EXP2
- float fogFactor = whiteCompliment( exp2( - square( fogDensity ) * square( depth ) * LOG2 ) );
+ float fogFactor = whiteCompliment( exp2( - fogDensity * fogDensity * depth * depth * LOG2 ) );
#else
@@ -59,7 +59,8 @@ varying vec3 vViewPosition;
vec3 calcCosineTerm( in vec3 normal, in vec3 lightDir ) {
- vec3 cosineTerm = vec3( saturate( dot( normal, lightDir ) ) );
+ float dotProduct = dot( normal, lightDir );
+ vec3 cosineTerm = vec3( saturate( dotProduct ) );
#ifdef WRAP_AROUND