2
\$\begingroup\$

after reading about CSM, I have a few questions about the implementation that I can't find the answer to.

  1. According to the wiki, an FBO can only take 1 depth attachment, so in order to render cascaded shadowmaps in one pass, I would have to use TEXTURE_2D_ARRAY or TEXTURE_3D, correct?

  2. This would force me to use a geometry shader. Would this have a performance hit vs. an alternative method?

  3. The other problem is that I have to define gl_Layer per primative. Could it be possible that a primitive is not fully covered by any single ortho projection? e.g. the camera fov is subdivided, then an ortho projection from the sun is created for each subdivision. If the camera normal is aligned with the sun normal, then the projections' bounds would barely overlap. If a primitive isn't fully covered by either projection, then I can't calculate the depth for that primitive using gl_Layer.

\$\endgroup\$
  • \$\begingroup\$ You have overlooked a simple solution: If an FBO can only have one depth attachment, then create multiple FBO objects. \$\endgroup\$ – Ian Young Feb 6 '18 at 10:28
  • \$\begingroup\$ Yes, but I am trying to render in one pass to avoid re-tesselating the entire terrain. It's okay though, I figured it out on my own :) \$\endgroup\$ – Kyy13 Feb 6 '18 at 19:09
  • \$\begingroup\$ You should have mentioned in your original question, that you were doing tesellation. Additional shader stages makes quite a difference, as your obviously aware. \$\endgroup\$ – Ian Young Feb 7 '18 at 9:53
0
\$\begingroup\$

Answer for anyone who want to know...

  1. In order to render to multiple depth layers in one pass, a 2d texture array or 3d texture is needed.

  2. Geometry shader is needed. It slows down performance, but it is needed anyway for multiple ortho projections and to duplicate geometry that falls within the bounds of 2 layers.

  3. Per #2.. if primitive is in multiple boundaries, then duplicate it and set gl_Layer separately for both.

If there is a more optimal way to do it, then please let me know!

\$\endgroup\$

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.