I'm implementing a deferred shading technique and the following question arose:

When storing the normals, should I transform to view space, or may I keep them in world space? Why?

Will any of the alternatives be better than the other for calculating lighting?

  • \$\begingroup\$ You can find lots of good info in this paper. \$\endgroup\$
    – MooseBoys
    Oct 3 '14 at 0:44
  • 2
    \$\begingroup\$ As long as the normals for all pixels in the view are in the same space, then it'll be fine. If you find yourself multiplaying every normal by a camera matrix on its way to lighting, well, that would be suggestive... \$\endgroup\$ Oct 3 '14 at 6:58

I found the answer to my question by experiencing. Take a look here to learn how to reconstruct position from depth buffer. As you can see, converting do view-space is a little cheaper. So that's what I chose. Position and Normals on view space. The only drawback is having to project your lights position from world to view space, but that's done only once per frame on GPU, is kinda MUCH better than once per pixel.

  • 1
    \$\begingroup\$ You absolutely need to read : aras-p.info/texts/CompactNormalStorage.html \$\endgroup\$
    – v.oddou
    Oct 9 '14 at 8:02
  • \$\begingroup\$ Yup, that's one of the reasons too. View-space normals allow you to omit the normal Z and recalc it from X and Y. Thus using a single R16G16 to store normals efficiently and with more precision. \$\endgroup\$ Oct 9 '14 at 13:09

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.