Hi
I'm working on a little project to learn about deferred lighting in GLSL. So far I can render to textures, and display them as can be seen in the screenshot. But I am stuck at the lighting part - I can display the scene by just referencing the 'Diffuse' image texture, but that ignores any lighting I am attempting. I have looked at lots of examples but can't work it out. Any help would be great please.
Screenshot - the black square in the middle will display the final image: I am trying to display a light above the scene.
This is the lightPass fragment shader:
#version 330
uniform sampler2D tDiffuse;
uniform sampler2D tPosition;
uniform sampler2D tNormals;
uniform vec3 cameraPosition;
uniform vec4 lightPosition;
in vec2 fragTexCoord0;
out vec4 outColor;
void main( void )
{
vec4 image = texture2D( tDiffuse, fragTexCoord0 );
vec4 position = texture2D( tPosition, fragTexCoord0 );
vec4 normal = texture2D( tNormals, fragTexCoord0 );
vec3 light = vec3(0,50,0);
vec3 lightDir = light.xyz - position.xyz;
normal = normalize(normal);
lightDir = normalize(lightDir);
vec3 eyeDir = normalize(cameraPosition-position.xyz);
vec3 vHalfVector = normalize(lightDir.xyz+eyeDir);
float diffuse = max(dot(vec3(normal),lightDir),0);
float specular = pow(max(dot(vec3(normal),vHalfVector),0.0), 100) * 1.5;
outColor = diffuse * image + specular;
// This displays the Diffuse texture
// outColor = image;
}