iOS: fix shaders fog issue

master
Maksim 2020-11-18 23:10:42 +01:00
parent 001207a014
commit 67457532d7
2 changed files with 4 additions and 4 deletions

View File

@ -3,12 +3,11 @@ uniform sampler2D normalTexture;
uniform sampler2D textureFlags;
uniform vec4 skyBgColor;
uniform float fogDistance;
uniform vec3 eyePosition;
varying mediump vec4 varColor;
varying mediump vec2 varTexCoord;
varying mediump vec3 eyeVec;
varying mediump vec3 eyeVec; // divided by fogDistance
const float e = 2.718281828459;
const float BS = 10.0;
@ -75,7 +74,7 @@ void main(void)
// should be more efficient as well.
// Note: clarity = (1 - fogginess)
float clarity = clamp(fogShadingParameter
- fogShadingParameter * length(eyeVec) / fogDistance, 0.0, 1.0);
- fogShadingParameter * length(eyeVec), 0.0, 1.0);
col = mix(skyBgColor, col, clarity);
col = vec4(col.rgb, base.a);

View File

@ -1,6 +1,7 @@
// Color of the light emitted by the sun.
uniform highp mat4 mWorld;
uniform vec3 dayLight;
uniform float fogDistance;
uniform float animationTimer;
varying mediump vec4 varColor;
@ -74,7 +75,7 @@ float disp_z;
gl_Position = mWorldViewProj * inVertexPosition;
#endif
eyeVec = -(mWorldView * inVertexPosition).xyz;
eyeVec = -(mWorldView * inVertexPosition).xyz / fogDistance;
// Calculate color.
// Red, green and blue components are pre-multiplied with