distance fog
@@ -1,5 +1,7 @@
#ifdef USE_FOG
+ float fogDepth = length(fogPosition);
+
#ifdef FOG_EXP2
float fogFactor = whiteCompliment( exp2( - fogDensity * fogDensity * fogDepth * fogDepth * LOG2 ) );
@@ -1,7 +1,7 @@
uniform vec3 fogColor;
- varying float fogDepth;
+ varying vec3 fogPosition;
@@ -1,5 +1,5 @@
#endif
@@ -1,4 +1,4 @@
-fogDepth = -mvPosition.z;
+fogPosition = mvPosition.xyz;