Skip to content

Commit

Permalink
Merge pull request #14752 from greggman/non-overflowing-fog
Browse files Browse the repository at this point in the history
Make distance fog calculation overflow less in mediump
  • Loading branch information
mrdoob authored Aug 21, 2018
2 parents 4ab0e69 + 33f69d7 commit 508b82d
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/renderers/shaders/ShaderChunk/fog_fragment.glsl
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#ifdef USE_FOG

float fogDepth = length( vFogPosition );
// divide then multiply by max component to try to avoid saturating mediump precision
vec3 fogPositionAbs = abs( vFogPosition );
float fogMaxComponent = max( fogPositionAbs.x, max( fogPositionAbs.y, fogPositionAbs.z ) );
float fogDepth = length( vFogPosition / fogMaxComponent ) * fogMaxComponent;

#ifdef FOG_EXP2

Expand Down

0 comments on commit 508b82d

Please sign in to comment.