Small correction to lighting model in shaders. Light intensity is no longer clipped.

This commit is contained in:
Bart Trzynadlowski 2012-01-22 01:05:59 +00:00
parent b57ba51e44
commit 3315fb463b
5 changed files with 7 additions and 10 deletions

View file

@ -178,7 +178,7 @@ void main(void)
ellipse = (gl_FragCoord.xy-spotEllipse.xy)/spotEllipse.zw; ellipse = (gl_FragCoord.xy-spotEllipse.xy)/spotEllipse.zw;
insideSpot = dot(ellipse,ellipse); insideSpot = dot(ellipse,ellipse);
if ((insideSpot <= 1.0) && (fsViewZ>=spotRange.x) && (fsViewZ<spotRange.y)) if ((insideSpot <= 1.0) && (fsViewZ>=spotRange.x) && (fsViewZ<spotRange.y))
lightIntensity = min(fsLightIntensity+(1.0-insideSpot)*spotColor,1.0); lightIntensity = fsLightIntensity+(1.0-insideSpot)*spotColor;
else else
lightIntensity = fsLightIntensity; lightIntensity = fsLightIntensity;
fragColor.rgb *= lightIntensity; fragColor.rgb *= lightIntensity;

View file

@ -117,7 +117,7 @@ void main(void)
// Textured polygons: set fragment color to texel value // Textured polygons: set fragment color to texel value
{ {
fragColor = texture2D(textureMap,(fsSubTexture.xy+fsSubTexture.zw/2.0)/2048.0); fragColor = texture2D(textureMap,(fsSubTexture.xy+fsSubTexture.zw/2.0)/2048.0);
//fragColor += texture2D(textureMap,(fsSubTexture.xy+fsSubTexture.zw))/2048.0); //fragColor += texture2D(textureMap,(fsSubTexture.xy+fsSubTexture.zw)/2048.0);
} }
@ -125,11 +125,10 @@ void main(void)
ellipse = (gl_FragCoord.xy-spotEllipse.xy)/spotEllipse.zw; ellipse = (gl_FragCoord.xy-spotEllipse.xy)/spotEllipse.zw;
insideSpot = dot(ellipse,ellipse); insideSpot = dot(ellipse,ellipse);
if ((insideSpot <= 1.0) && (fsViewZ>=spotRange.x) && (fsViewZ<spotRange.y)) if ((insideSpot <= 1.0) && (fsViewZ>=spotRange.x) && (fsViewZ<spotRange.y))
lightIntensity = min(fsLightIntensity+(1.0-insideSpot)*spotColor,1.0); lightIntensity = fsLightIntensity+(1.0-insideSpot)*spotColor;
else else
lightIntensity = fsLightIntensity; lightIntensity = fsLightIntensity;
fragColor.rgb *= lightIntensity; fragColor.rgb *= lightIntensity;
fragColor.rgb *= fsLightIntensity;
// Translucency (modulates existing alpha channel for RGBA4 texels) // Translucency (modulates existing alpha channel for RGBA4 texels)
fragColor.a *= fsTransLevel; fragColor.a *= fsTransLevel;

View file

@ -183,7 +183,7 @@ void main(void)
ellipse = (gl_FragCoord.xy-spotEllipse.xy)/spotEllipse.zw; ellipse = (gl_FragCoord.xy-spotEllipse.xy)/spotEllipse.zw;
insideSpot = dot(ellipse,ellipse); insideSpot = dot(ellipse,ellipse);
if ((insideSpot <= 1.0) && (fsViewZ>=spotRange.x) && (fsViewZ<spotRange.y)) if ((insideSpot <= 1.0) && (fsViewZ>=spotRange.x) && (fsViewZ<spotRange.y))
lightIntensity = min(fsLightIntensity+(1.0-insideSpot)*spotColor,1.0); lightIntensity = fsLightIntensity+(1.0-insideSpot)*spotColor;
else else
lightIntensity = fsLightIntensity; lightIntensity = fsLightIntensity;
fragColor.rgb *= lightIntensity; fragColor.rgb *= lightIntensity;

View file

@ -126,7 +126,6 @@ void main(void)
// Total light intensity: sum of all components // Total light intensity: sum of all components
fsLightIntensity *= (sunFactor*lighting[1].x+lighting[1].y); fsLightIntensity *= (sunFactor*lighting[1].x+lighting[1].y);
fsLightIntensity = clamp(fsLightIntensity,0.0,1.0);
} }
// Fog // Fog

View file

@ -158,7 +158,6 @@ static const char vertexShaderSource[] =
" \n" " \n"
" // Total light intensity: sum of all components \n" " // Total light intensity: sum of all components \n"
" fsLightIntensity *= (sunFactor*lighting[1].x+lighting[1].y); \n" " fsLightIntensity *= (sunFactor*lighting[1].x+lighting[1].y); \n"
" fsLightIntensity = clamp(fsLightIntensity,0.0,1.0); \n"
" } \n" " } \n"
" \n" " \n"
" // Fog \n" " // Fog \n"
@ -355,7 +354,7 @@ static const char fragmentShaderSource[] =
" ellipse = (gl_FragCoord.xy-spotEllipse.xy)/spotEllipse.zw; \n" " ellipse = (gl_FragCoord.xy-spotEllipse.xy)/spotEllipse.zw; \n"
" insideSpot = dot(ellipse,ellipse); \n" " insideSpot = dot(ellipse,ellipse); \n"
" if ((insideSpot <= 1.0) && (fsViewZ>=spotRange.x) && (fsViewZ<spotRange.y)) \n" " if ((insideSpot <= 1.0) && (fsViewZ>=spotRange.x) && (fsViewZ<spotRange.y)) \n"
" lightIntensity = min(fsLightIntensity+(1.0-insideSpot)*spotColor,1.0); \n" " lightIntensity = fsLightIntensity+(1.0-insideSpot)*spotColor; \n"
" else \n" " else \n"
" lightIntensity = fsLightIntensity; \n" " lightIntensity = fsLightIntensity; \n"
" fragColor.rgb *= lightIntensity; \n" " fragColor.rgb *= lightIntensity; \n"