Important Additions & Fixes to LPP Implementation


I have finally tracked down an issue that I was having with the Light Pre Pass implementation, and as a result have had to make some changes to the implementation.

Firstly, I would recommend ensuring RenderState.AlphaTestEnable is false before rendering materials, it appears this is set (at least in my sample) somewhere and it corrupts the light buffer.

Secondly, move the postProjToScreen and halfPixel calls from the vertex shader in blinnphong.fx, to the pixel shader. Some GPUs (like my laptop’s) do not correctly interpolate the adjusted screen coordinates, and this ensures it is correctly interpolated per pixel.

gfx.SetRenderTarget(0, light);
gfx.SetRenderTarget(1, null);
depthImage = depth.GetTexture();
normImage = normals.GetTexture();
gfx.RenderState.AlphaTestEnable = false;

Finally, when writing the Normal in the vertex shader for def_depthnorm.fx, swap the parameters of mul(input.Normal, World) to mul(World, input.Normal).

That should be all, if you notice any other issues, feel free to post them in the comments, it would be greatly appreciated.

  • I hate render states too :D

    Nice work and well done tracking those issues down :)
  • Thanks Michael for the clarification and keep up this great job!
blog comments powered by Disqus