I'm trying to implement deferred lighting and I have done the first and second pass but I'm stuck on the third as I don't know how to map from the current pixel being drawn to the generated texture with the light.

Generated texture with light calculated enter image description here

Current picture enter image description here

I would appreciate it if someone could help me figure out how to map my generated texture with the current pixel I'm drawing.

I don't know if it matters, but I'm working with DirectX but an explantion with OpenGL would also be welcomed.


You just need to load the lighting value at the position of the pixel.

// Example pixel shader DX11
float4 PixelShader(PixelLocation : SV_Position) : SV_Target0

     int3 SampleIndex = int3(PixelLocation.xy, 0);
     float4 lighting = LightingBuffer.Load(SampleIndex);


Info on Load here.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.