I am using the GLSL shader from this link, slightly modified and i got it working. The shader code is the following:
VS:
vPosition = uMVMatrix * vec4(aVertexPosition, 1.0);
vTransformedNormal = uNMatrix * aVertexNormal;
gl_Position = uPMatrix * vPosition;
FS:
float minLight = 0.01f;
float radius = sqrt(1.0 / (uAttenuationFactor * minLight));
float lightAdd = 0.0f;
float dist = distance(vPosition.xyz, (uMat4Identity * vec4(uLightPosition, 1.0)).xyz);
float att = clamp(1.0 - dist/radius, 0.0, 1.0);
vec3 surf2light = normalize((uMat4Identity * vec4(uLightPosition, 1.0)).xyz - vPosition.xyz);
vec3 norm = normalize(vTransformedNormal);
float diffuseCoefficient = max(0.0, dot(norm, surf2light));
lightAdd += att * (diffuseCoefficient + uSourceIntensity);
vec4 textureColor = texture2D(uTex0, vec2(vTextureCoord.s, vTextureCoord.t));
vec3 torch_output = lightAdd * uColorLight;
vec4 final_color = (vec4(torch_output, 1.0f) * textureColor) * vVertexColor;
gl_FragColor = final_color;
The shader computes point lighting with attenuation and give very satisfactory results. Look at the pic:
I give uAttenuationFactor = 0.4f and uSourceIntensity = 0.2f to get this result and it satisfies me. However, besides setting the light color, how i could modify the shader to fade-out to another color than black?? Anything i tried it just modifies the visible parts of the screen i.e. walls but the black remains unchanged. I would had liked to be able to set a grey color for rain or whitish for fog effect etc.
Thanx.