Skip to main content
1 of 5
philB
  • 159
  • 9

Using cubemap in view space for shadowing in deferred rendering

I want to render shadows for point lights with a cubemap. My shader uses view space for lighting (directinal and point). So I convert ligthposW/lightfocusW in world space to ligthposV/lightfocusV in view space by doing ligthposW x View and lightfocusW x view. ligthposV-lightfocusV gives me the direction of light and direction of pointlight to pixel in view space that I use for doting to normals in view space. Works fine.

I have difficulties to use the same idea for shadowcube mapping in view space. The idea is to use the same light to pixel direction calculated in viewspace to save some instructions.

Currently I'm falling back to world space for point lights shadows. Consequently the shadowcube is filled with depth of object in world space (World x LightViewProj)

so the goal is to do ShadowCubeMap.Sample(point, direction in view space).r.

philB
  • 159
  • 9