added fog.

This commit is contained in:
Nicole Dresselhaus 2014-04-21 15:55:22 +02:00
parent 85e1fe6325
commit 3de372f83f
3 changed files with 15 additions and 1 deletions

View File

@ -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));
}

View File

@ -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];

View File

@ -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"