I've managed to implement shadow mapping to a scene. However, I had problems using a cube map so I eventually gave it up and used 6 2D texture maps instead. To make this work with 6 2D maps, during the rendering process I have to identify in which texture of the 6 each fragment belongs. I'm afraid this could be dropping my frames significantly.

I'm not gonna go into many details for now. I will upload the relevant code if necessary. My main concern is if this method makes my program slower.Will my fps increase using a cube map?

  • 1
    \$\begingroup\$ It probably will. \$\endgroup\$ Dec 30 '18 at 12:45
  • \$\begingroup\$ Yes; it's a single texture and there's no branching logic required in your pixel/fragment shader. You should ask a new question about the problems you had with cube maps rather than editing or adding to this one, however. \$\endgroup\$ Dec 30 '18 at 13:15
  • \$\begingroup\$ There are no answers here yet, so I see no harm in editing the question to ask about the problems you've had implementing a cube map version instead. \$\endgroup\$
    – DMGregory
    Dec 30 '18 at 13:35
  • \$\begingroup\$ I've already uploaded a question on the problems I've had. Actually, I have followed tutorials right on point and I don't know why it's not working. gamedev.stackexchange.com/questions/166342/… I'll give it a shot again since it will be faster. I will soon delete this question, thank you. \$\endgroup\$ Dec 30 '18 at 13:56

There is no need to use 6 individual textures as you can just use one big 2D strip with the dimensions x=shadowmap_width y= 6*shadowmap_height and then do 6 renderpasses adjusting the viewport to draw at the right place of the texture. (glViewport + glScissor in openGL).

That way you only have one texture sampler in your shaders and don't need 12 rebindings per render iteration. Also PCF using poisson disk sampling gets a lot easier since you have 2D texture coordinates.

This blog goes a bit deeper in how to do this and also points out potential issues and how you could solve them: https://kosmonautblog.wordpress.com/2017/03/25/shadow-filtering-for-pointlights/


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.