1
0
Fork 0

Standardize fog

Signed-off-by: Vivian Meazza <vivian.meazza@lineone.net>
This commit is contained in:
Vivian Meazza 2011-12-01 21:05:05 +00:00
parent 47ec25ba08
commit a37de2ec49
2 changed files with 133 additions and 115 deletions

View file

@ -18,8 +18,14 @@ uniform float snowlevel; // From /sim/rendering/snow-level-m
const float scale = 1.0; const float scale = 1.0;
int linear_search_steps = 10; int linear_search_steps = 10;
////fog "include" /////
uniform int fogType;
vec3 fog_Func(vec3 color, int type);
//////////////////////
float ray_intersect(sampler2D reliefMap, vec2 dp, vec2 ds) float ray_intersect(sampler2D reliefMap, vec2 dp, vec2 ds)
{ {
float size = 1.0 / float(linear_search_steps); float size = 1.0 / float(linear_search_steps);
float depth = 0.0; float depth = 0.0;
@ -50,10 +56,10 @@ float ray_intersect(sampler2D reliefMap, vec2 dp, vec2 ds)
} }
return(best_depth); return(best_depth);
} }
void main (void) void main (void)
{ {
float bump = 1.0; float bump = 1.0;
if ( quality_level >= 3.0 ) { if ( quality_level >= 3.0 ) {
@ -63,7 +69,7 @@ void main (void)
vec2 uv, dp = vec2(0, 0), ds = vec2(0, 0); vec2 uv, dp = vec2(0, 0), ds = vec2(0, 0);
vec3 N; vec3 N;
float d = 0; float d = 0;
if ( bump > 0.9 && quality_level >= 2.0 && quality_level < 3.5) if ( bump > 0.9 && quality_level > 2.0 && quality_level <= 4.0)
{ {
vec3 V = normalize(ecPosition.xyz); vec3 V = normalize(ecPosition.xyz);
float a = dot(VNormal, -V); float a = dot(VNormal, -V);
@ -136,8 +142,11 @@ void main (void)
c1 *= ambient_light; c1 *= ambient_light;
vec4 finalColor = c1; vec4 finalColor = c1;
if(gl_Fog.density == 1.0) //if(gl_Fog.density == 1.0)
fogFactor=1.0; // fogFactor=1.0;
gl_FragColor = mix(gl_Fog.color ,finalColor, fogFactor); // gl_FragColor = mix(gl_Fog.color ,finalColor, fogFactor);
} finalColor.rgb = fog_Func(finalColor.rgb, fogType);
gl_FragColor = finalColor;
}

View file

@ -9,8 +9,15 @@ varying vec4 constantColor;
attribute vec3 tangent; attribute vec3 tangent;
attribute vec3 binormal; attribute vec3 binormal;
////fog "include" /////
uniform int fogType;
void fog_Func(int type);
//////////////////////
void main(void) void main(void)
{ {
rawpos = gl_Vertex; rawpos = gl_Vertex;
ecPosition = gl_ModelViewMatrix * rawpos; ecPosition = gl_ModelViewMatrix * rawpos;
Normal = normalize(gl_Normal); Normal = normalize(gl_Normal);
@ -23,4 +30,6 @@ void main(void)
+ gl_FrontColor * (gl_LightModel.ambient + gl_LightSource[0].ambient); + gl_FrontColor * (gl_LightModel.ambient + gl_LightSource[0].ambient);
gl_Position = ftransform(); gl_Position = ftransform();
gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0; gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
}
fog_Func(fogType);
}