1
0
Fork 0

Standardized fog

Signed-off-by: Vivian Meazza <vivian.meazza@lineone.net>
This commit is contained in:
Vivian Meazza 2011-12-01 20:52:59 +00:00
parent 0adb61f2a7
commit 06e0e5a057
2 changed files with 33 additions and 10 deletions

View file

@ -1,9 +1,22 @@
#version 120
uniform sampler2D baseTexture;
varying float fogFactor;
//varying float fogFactor;
//varying vec4 PointPos;
//varying vec4 EyePos;
////fog "include" /////
uniform int fogType;
vec3 fog_Func(vec3 color, int type);
//////////////////////
void main(void)
{
vec4 base = texture2D( baseTexture, gl_TexCoord[0].st);
vec4 finalColor = base * gl_Color;
gl_FragColor = mix(gl_Fog.color, finalColor, fogFactor );
if (base.a <= 0.01)
discard;
vec4 fragColor = base * gl_Color;
//gl_FragColor = vec4(mix(gl_Fog.color.rgb, finalColor.rgb, fogFactor ), finalColor.a);
fragColor.rgb = fog_Func(fragColor.rgb, fogType);
gl_FragColor = fragColor;
}

View file

@ -3,8 +3,15 @@
// normal - x y scaling, z number of varieties
// fog coord - rotation
// color - xyz of tree quad origin, replicated 4 times.
#version 120
//varying float fogCoord;
varying vec3 PointPos;
//varying vec4 EyePos;
////fog "include"////////
uniform int fogType;
varying float fogFactor;
void fog_Func(int type);
/////////////////////////
void main(void)
{
@ -30,7 +37,10 @@ void main(void)
vec4 ambientColor = gl_FrontLightModelProduct.sceneColor + gl_LightSource[0].ambient * gl_FrontMaterial.ambient;
gl_FrontColor = ambientColor + gl_LightSource[0].diffuse * vec4(diffuse, 1.0);
float fogCoord = abs(ecPosition.z);
fogFactor = exp( -gl_Fog.density * gl_Fog.density * fogCoord * fogCoord);
fogFactor = clamp(fogFactor, 0.0, 1.0);
//fogCoord = abs(ecPosition.z);
//fogFactor = exp( -gl_Fog.density * gl_Fog.density * fogCoord * fogCoord);
//fogFactor = clamp(fogFactor, 0.0, 1.0);
// fog_Func(fogType);
PointPos = ecPosition;
//EyePos = gl_ModelViewMatrixInverse * vec4(0.0,0.0,0.0,1.0);
}