added fog.
This commit is contained in:
parent
85e1fe6325
commit
3de372f83f
@ -94,18 +94,29 @@ float snoise(vec3 v)
|
|||||||
dot(p2,x2), dot(p3,x3) ) );
|
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 teNormal;
|
||||||
smooth in vec3 tePosition;
|
smooth in vec3 tePosition;
|
||||||
|
smooth in float fogDist;
|
||||||
smooth in float gmix;
|
smooth in float gmix;
|
||||||
in vec4 teColor;
|
in vec4 teColor;
|
||||||
|
|
||||||
out vec4 fgColor;
|
out vec4 fgColor;
|
||||||
|
|
||||||
uniform mat4 ViewMatrix;
|
uniform mat4 ViewMatrix;
|
||||||
|
uniform mat4 ProjectionMatrix;
|
||||||
|
|
||||||
void main(void)
|
void main(void)
|
||||||
{
|
{
|
||||||
|
//fog color
|
||||||
|
vec4 fogColor = vec4(0.6,0.7,0.8,1.0);
|
||||||
|
|
||||||
//heliospheric lighting
|
//heliospheric lighting
|
||||||
vec4 light = vec4(1.0,1.0,1.0,1.0);
|
vec4 light = vec4(1.0,1.0,1.0,1.0);
|
||||||
vec4 dark = vec4(0.0,0.0,0.0,1.0);
|
vec4 dark = vec4(0.0,0.0,0.0,1.0);
|
||||||
@ -142,4 +153,5 @@ void main(void)
|
|||||||
vec4 Color = texColor;
|
vec4 Color = texColor;
|
||||||
|
|
||||||
fgColor = Color * mix(dark, light, a);
|
fgColor = Color * mix(dark, light, a);
|
||||||
|
fgColor = mix(fgColor,fogColor,fog(fogDist));
|
||||||
}
|
}
|
@ -9,6 +9,7 @@ in vec3 tcNormal[];
|
|||||||
out vec4 teColor;
|
out vec4 teColor;
|
||||||
smooth out vec3 tePosition;
|
smooth out vec3 tePosition;
|
||||||
smooth out vec3 teNormal;
|
smooth out vec3 teNormal;
|
||||||
|
out float fogDist;
|
||||||
smooth out float gmix; //mixture of gravel
|
smooth out float gmix; //mixture of gravel
|
||||||
//out vec3 tePatchDistance;
|
//out vec3 tePatchDistance;
|
||||||
//constant projection matrix
|
//constant projection matrix
|
||||||
@ -38,6 +39,7 @@ void main()
|
|||||||
float standout = i0+i1+i2;
|
float standout = i0+i1+i2;
|
||||||
tePosition = tePosition+tessNormal*standout;
|
tePosition = tePosition+tessNormal*standout;
|
||||||
gl_Position = ProjectionMatrix * ViewMatrix * vec4(tePosition, 1);
|
gl_Position = ProjectionMatrix * ViewMatrix * vec4(tePosition, 1);
|
||||||
|
fogDist = gl_Position.z;
|
||||||
|
|
||||||
//COLOR-BLENDING
|
//COLOR-BLENDING
|
||||||
vec4 c0 = sqrt(gl_TessCoord.x) * tcColor[0];
|
vec4 c0 = sqrt(gl_TessCoord.x) * tcColor[0];
|
||||||
|
@ -172,7 +172,7 @@ initHud = do
|
|||||||
|
|
||||||
initRendering :: IO ()
|
initRendering :: IO ()
|
||||||
initRendering = do
|
initRendering = do
|
||||||
clearColor $= Color4 0 0 0 0
|
clearColor $= Color4 0.6 0.7 0.8 1
|
||||||
depthFunc $= Just Less
|
depthFunc $= Just Less
|
||||||
glCullFace gl_BACK
|
glCullFace gl_BACK
|
||||||
checkError "initRendering"
|
checkError "initRendering"
|
||||||
|
Loading…
Reference in New Issue
Block a user