My GLSL shader is not outputting the correct attenuation onto my terrain. My terrain is green(0.1,0.6,0.0), and I want the color of the terrain to go from dark green to bright green as the light gets closer to each on the terrain, as it should in attenuation.
When my terrain's color = {0.1, 0.6, 0.0}, I see a very rapid color change from green->yellow as pixels on the terrain get closer to the light, when it should be going green->bright green instead of yellow.
*light is located above the player's head(camera).
When my terrain's color = {0.0, 0.0, 0.0}, the terrain color is perfectly calculated with attenuation, no problems.
*light is located above the player's head(camera).
Question: I can't understand why the 0.1 in the RED color spot has so much impact when terrain pixels get closer to the light(ie: attenuation value gets closer to 1.0)?
Here's the basis of the final generation of color in my pixel shader:
varying vec4 color;
float constantAttenuationPlayer=0.0;
float linearAttenuationPlayer=0.0;
float quadraticAttenuationPlayer=0.009;
float dist = length(gl_LightSource[2].position - v);
float att = 1.0/(constantAttenuationPlayer + (linearAttenuationPlayer * dist) + (quadraticAttenuationPlayer * dist * dist));
gl_FragColor = color * att;