   Deferred lighting shader issue
  Hi,after a whole lot of trying around I finally mananged to get my deferred lighting shader to work like I expected it. Well, almost. Everything works fine as long as all directional-lights direction components are values <= 0. If I set the direction to anything like (0.0f, 1.0f, 0.0f), then Diffuse & Specular components aren't shown anymore. After a few hours of trying to find out whats going on I'm pretty much at a dead end. So far I only found out that if my light comes from a positiv direction, the dot-product calculated with the normals is not a negative value, but simple 0. Thats somewhat confusing any way, isn't the dot-product supposed to give negative values if the vectors show in different directions? Anyway I can't get it to work, I already set my light to rotate around the whole scene, as soon as one component of the direction gets negativ, it's effect is denided (strangely, the light still behaves like it would come from the others components direction, like a light with (1.0, -1.0, 1.0) will work like a light (0.0, -1.0, 0.0). Here is my shader:float4 psLighting(PS_INPUT_LIGHT i) : COLOR0{float3 vDiffuseMaterial = tex2D(SceneMaterialSampler, i.vTex0).rgb;float3 vSpecularMaterial = tex2D(SceneMaterialSampler, i.vTex0).a;float4 vWorldNrm = tex2D(SceneNormalSampler, i.vTex0);float3 vWorldPos = tex2D(ScenePositionSampler, i.vTex0).rgb;float3 vCameraDir = CameraPos - vWorldPos;float3 vLightDir = normalize(LightDir);float3 vDiffuseIntensity = max(0, dot(vLightDir, vWorldNrm));float3 Reflect = normalize(2 * -vDiffuseIntensity * vWorldNrm - vLightDir);float shadow = saturate(4* vDiffuseIntensity);float4 specular = pow(saturate(dot(Reflect, normalize(-vCameraDir))), 8); float4 color;color.rgb = 0.2* vDiffuseMaterial + shadow * ( vDiffuseIntensity * LightDiffuse.xyz * vDiffuseMaterial +  specular * LightSpecular.xyz);//color.rgb = vDiffuseIntensity;color.a = vSpecularMaterial.x;return color;};Can somebody tell just from readin gover it if there is anything wrong? I can't imagine, as already this line: float3 vDiffuseIntensity = max(0, dot(vLightDir, vWorldNrm)); produces just 0 values. If needed, this is how I render to my g-buffer:VS_OUTPUT_BUILD vsBuild(VS_INPUT_BUILD i){VS_OUTPUT_BUILD o;o.vWorldPos = mul(float4(i.vPos, 1), World);o.vPos = mul(float4(o.vWorldPos, 1), ViewProjection);o.vTex0 = i.vTex0;float3 vWorldNrm = mul(i.vNrm, World);o.fDepth = mul( i.vPos, LightWorldViewProj ).z;o.vTexCoord = mul( i.vPos, matTexture);float3 N = normalize(vWorldNrm);float3 T = normalize(mul(i.vTan, World));float3 B = normalize(mul(i.vBin, World));o.mTBN = float3x3(T, B, N);return o;};PS_OUTPUT_BUILD psBuild(VS_OUTPUT_BUILD i){PS_OUTPUT_BUILD o;float4 vDiffuseMaterial = tex2D(DiffuseSampler, i.vTex0);o.vMaterial.rgb = vDiffuseMaterial;o.vMaterial.a = 1.0;float3 bumpNormal = tex2D(BumpSampler, i.vTex0).rgb;bumpNormal = 2.0* bumpNormal - 1.0;bumpNormal = mul(bumpNormal, i.mTBN);o.vWorldNrm.xyz = bumpNormal;o.vWorldNrm.w = 1.0;o.vWorldPos = float4(i.vWorldPos.xyz, 0);}I already testes if there is anything wrong the way I set up the g-buffer, but when I show the content of the render targets everything seem to be fine. Can somebody please give me at least some hints what could be wrong? I know its not that easy to debug someone elses shader, and nobody probably wants to do it, but I'm pretty much stuck. I can't debug that shader too as PIX is always crashing for me. Thansk in advance for any suggestions!   
  Are you storing the normals in a floating point texture, or a regular color texture? If you try to stuff a normal value into an RGBA8 texture, it will clamp all negative values to zero. This sounds like it could fit with the problem you're describing (failing positive lights imply negative signed normals could be not working). A common trick for this would be to normalize your normal, before writing, then scale the values from (-1/1) to (0/1), and then do the reverse operation from reading from the texture.   ;Are you storing the normals in a floating point texture, or a regular  color texture? If you try to stuff a normal value into an RGBA8 texture,  it will clamp all negative values to zero. This sounds like it could  fit with the problem you're describing (failing positive lights imply  negative signed normals could be not working). A common trick for this would be to normalize your normal, before  writing, then scale the values from (-1/1) to (0/1), and then do the  reverse operation from reading from the texture.    [/quote]Ah, I was storing them in a regular color texture. That obviously was the error, thanks for telling me! I already knew that trick for conversion, but somehow I kept getting wrong results, so I stopped using it. Well now it is finally working, thanks a lot.