diff --git a/src/renderers/shaders/ShaderChunk/fog_fragment.glsl b/src/renderers/shaders/ShaderChunk/fog_fragment.glsl index 8307a32478817b..22151b85de386d 100644 --- a/src/renderers/shaders/ShaderChunk/fog_fragment.glsl +++ b/src/renderers/shaders/ShaderChunk/fog_fragment.glsl @@ -1,5 +1,7 @@ #ifdef USE_FOG + float fogDepth = length(fogPosition); + #ifdef FOG_EXP2 float fogFactor = whiteCompliment( exp2( - fogDensity * fogDensity * fogDepth * fogDepth * LOG2 ) ); diff --git a/src/renderers/shaders/ShaderChunk/fog_pars_fragment.glsl b/src/renderers/shaders/ShaderChunk/fog_pars_fragment.glsl index 26c4093c6db3f1..8b78270a8f4c13 100644 --- a/src/renderers/shaders/ShaderChunk/fog_pars_fragment.glsl +++ b/src/renderers/shaders/ShaderChunk/fog_pars_fragment.glsl @@ -1,7 +1,7 @@ #ifdef USE_FOG uniform vec3 fogColor; - varying float fogDepth; + varying vec3 fogPosition; #ifdef FOG_EXP2 diff --git a/src/renderers/shaders/ShaderChunk/fog_pars_vertex.glsl b/src/renderers/shaders/ShaderChunk/fog_pars_vertex.glsl index d27a1a1ea5f4d6..91a42390eba3c2 100644 --- a/src/renderers/shaders/ShaderChunk/fog_pars_vertex.glsl +++ b/src/renderers/shaders/ShaderChunk/fog_pars_vertex.glsl @@ -1,5 +1,5 @@ #ifdef USE_FOG - varying float fogDepth; + varying vec3 fogPosition; #endif diff --git a/src/renderers/shaders/ShaderChunk/fog_vertex.glsl b/src/renderers/shaders/ShaderChunk/fog_vertex.glsl index 4ac023c0590d58..6b741cc5dca731 100644 --- a/src/renderers/shaders/ShaderChunk/fog_vertex.glsl +++ b/src/renderers/shaders/ShaderChunk/fog_vertex.glsl @@ -1,4 +1,4 @@ #ifdef USE_FOG -fogDepth = -mvPosition.z; +fogPosition = mvPosition.xyz; #endif \ No newline at end of file