4
\$\begingroup\$

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?

\$\endgroup\$
2
  • \$\begingroup\$ You can find lots of good info in this paper. \$\endgroup\$
    – MooseBoys
    Commented Oct 3, 2014 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\$ Commented Oct 3, 2014 at 6:58

1 Answer 1

0
\$\begingroup\$

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.

\$\endgroup\$
2
  • 1
    \$\begingroup\$ You absolutely need to read : aras-p.info/texts/CompactNormalStorage.html \$\endgroup\$
    – v.oddou
    Commented Oct 9, 2014 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\$ Commented Oct 9, 2014 at 13:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .