diff --git a/shaders/map/fragment.shader b/shaders/map/fragment.shader index 285afcc..01649cb 100644 --- a/shaders/map/fragment.shader +++ b/shaders/map/fragment.shader @@ -94,18 +94,29 @@ float snoise(vec3 v) dot(p2,x2), dot(p3,x3) ) ); } +float fog(float dist) { + dist = max(0,dist - 50); + dist = dist * 0.05; + dist = dist; + return 1-exp(-dist); +} smooth in vec3 teNormal; smooth in vec3 tePosition; +smooth in float fogDist; smooth in float gmix; in vec4 teColor; out vec4 fgColor; uniform mat4 ViewMatrix; +uniform mat4 ProjectionMatrix; void main(void) { + //fog color + vec4 fogColor = vec4(0.6,0.7,0.8,1.0); + //heliospheric lighting vec4 light = vec4(1.0,1.0,1.0,1.0); vec4 dark = vec4(0.0,0.0,0.0,1.0); @@ -142,4 +153,5 @@ void main(void) vec4 Color = texColor; fgColor = Color * mix(dark, light, a); + fgColor = mix(fgColor,fogColor,fog(fogDist)); } \ No newline at end of file diff --git a/shaders/map/tessEval.shader b/shaders/map/tessEval.shader index 09f6483..11feec1 100644 --- a/shaders/map/tessEval.shader +++ b/shaders/map/tessEval.shader @@ -9,6 +9,7 @@ in vec3 tcNormal[]; out vec4 teColor; smooth out vec3 tePosition; smooth out vec3 teNormal; +out float fogDist; smooth out float gmix; //mixture of gravel //out vec3 tePatchDistance; //constant projection matrix @@ -38,6 +39,7 @@ void main() float standout = i0+i1+i2; tePosition = tePosition+tessNormal*standout; gl_Position = ProjectionMatrix * ViewMatrix * vec4(tePosition, 1); + fogDist = gl_Position.z; //COLOR-BLENDING vec4 c0 = sqrt(gl_TessCoord.x) * tcColor[0]; diff --git a/src/Render/Render.hs b/src/Render/Render.hs index dd8678a..1171d60 100644 --- a/src/Render/Render.hs +++ b/src/Render/Render.hs @@ -172,7 +172,7 @@ initHud = do initRendering :: IO () initRendering = do - clearColor $= Color4 0 0 0 0 + clearColor $= Color4 0.6 0.7 0.8 1 depthFunc $= Just Less glCullFace gl_BACK checkError "initRendering"