Hi to all, I've been interested in game development for quite some time now and found this forum. Since it seems there are helpful people here, I thought I'd try my luck asking for help for a problem I'm having.
Without further ado, the problem is that I'm drawing some models using D3D11 and recently started using normals and texture coordinates for drawing (I'm just a beginner) in addition to just using vertice positions. I am trying to implement very simple lighting. The problem is, that when run, all objects appear completely black, even though I set my ambient light to completely white. Playing around with light values has no change at all - everything is black.
Pixel shader:
float4 PS( VS_OUTPUT input ) : SV_Target
{
return ObjTexture.Sample(ObjSamplerState, input.TexCoord );
input.normal = normalize(input.normal);
float4 diffuse = ObjTexture.Sample(ObjSamplerState, input.TexCoord );
float3 finalColor = diffuse*light.ambient;
finalColor += saturate(dot(light.dir,input.normal)*light.diffuse*diffuse);
return float4(finalColor,diffuse.a);
}
When I comment out the first line (return), all objects are black, otherwise everything is drawn without lighting. This is weird because even if my normals are wrong, ambient light should still light up the objects, right?
Thanks in advance.