diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/renderergl2/glsl/fogpass_vp.glsl | 17 | ||||
-rw-r--r-- | src/renderergl2/glsl/generic_vp.glsl | 15 |
2 files changed, 13 insertions, 19 deletions
diff --git a/src/renderergl2/glsl/fogpass_vp.glsl b/src/renderergl2/glsl/fogpass_vp.glsl index f18bc707..40d14d9f 100644 --- a/src/renderergl2/glsl/fogpass_vp.glsl +++ b/src/renderergl2/glsl/fogpass_vp.glsl @@ -85,16 +85,13 @@ float CalcFog(vec4 position) float s = dot(position, u_FogDistance) * 8.0; float t = dot(position, u_FogDepth); - if (t < 1.0) - { - t = step(step(0.0, -u_FogEyeT), t); - } - else - { - t /= t - min(u_FogEyeT, 0.0); - } - - return s * t; + bool eyeOutside = u_FogEyeT < 0.0; + float t2 = float(t >= float(eyeOutside)); + + if (eyeOutside) + t2 *= t / (t - u_FogEyeT); + + return s * t2; } void main() diff --git a/src/renderergl2/glsl/generic_vp.glsl b/src/renderergl2/glsl/generic_vp.glsl index 67360b1b..9ad4489b 100644 --- a/src/renderergl2/glsl/generic_vp.glsl +++ b/src/renderergl2/glsl/generic_vp.glsl @@ -194,16 +194,13 @@ float CalcFog(vec4 position) float s = dot(position, u_FogDistance) * 8.0; float t = dot(position, u_FogDepth); - if (t < 1.0) - { - t = step(step(0.0, -u_FogEyeT), t); - } - else - { - t /= t - min(u_FogEyeT, 0.0); - } + bool eyeOutside = u_FogEyeT < 0.0; + float t2 = float(t >= float(eyeOutside)); + + if (eyeOutside) + t2 *= t / (t - u_FogEyeT); - return s * t; + return s * t2; } #endif |