Im trying to get a simple deferred shading working.
I have GBuffer with 3 textures ( image, position, normal ).
Image :
http://c.wrzuta.pl/w...shading_gbuffer
Normal :
http://c.wrzuta.pl/w...shading_gbuffer
Position:
http://c.wrzuta.pl/w...shading_gbuffer
I'm trying to compute point light ( when i was used directional light i almost work ) like that :
// Fragment Shader //
#version 330 core
out vec4 outputColor;
in block
{
vec2 TexCoord;
vec3 Normal;
} In;
uniform sampler2D gDiffuseSampler;
uniform sampler2D gPositionSampler;
uniform sampler2D gNormalSampler;
uniform vec3 lightPosition;
uniform vec3 lightColor;
uniform float lightRadius;
void main()
{
vec4 image = texture( gDiffuseSampler, In.TexCoord );
vec4 position = texture( gPositionSampler, In.TexCoord );
vec4 normal = texture( gNormalSampler, In.TexCoord );
vec3 lightDir = lightPosition - position.xyz ;
normal = normalize(normal);
lightDir = normalize(lightDir);
float att = clamp(1.0f-length(lightDir)/lightRadius,0.0,1.0);
float diff = max(dot(normal,lightDir), 0);
outputColor = att * vec4(diff * lightColor,1.0);
}
i'm binding it on fullscreen quad.
Result :
http://c.wrzuta.pl/w...50a554e2/result
It is looking like "camera is center of point light ;| dafuq? i write about ten different shaders ;| on every the same - "camera is point light center", if you set camera closer to object, light get stronger ;o? i dont know, what im doing wrong. Sorry for my bad english.
I will by grateful for your help.