@@ -1,6 +1,8 @@
#ifdef USE_FOG
- // divide then multiply by max component to try to avoid saturating mediump precision
+ // float fogDepth = length( vFogPosition );
+ // mediump support: divide then multiply by max component
+
vec3 fogPositionAbs = abs( vFogPosition );
float fogMaxComponent = max( fogPositionAbs.x, max( fogPositionAbs.y, fogPositionAbs.z ) );
float fogDepth = length( vFogPosition / fogMaxComponent ) * fogMaxComponent;