Render back faces to shadow map

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By gammaker
:warning: Old Version Published before Godot 3 was released.

I have some optimized level that doesn’t contain any faces that player can’t see. So if this level is rendered from outside, some walls will be invisible, because back faces are not drawn.

But it is a problem for sun, that is always outside. Back faces are not rendered to the shadow map, so they doesn’t cast shadows. I tried to make material Double Sided, but it doesn’t affect the shadow map rendering. Is there a way to render both faces to shadow map in godot 2.1.3?

If the player can see shadows… then he/she can see these faces. Why hide them? Note that realtime shadow mapping accounts for 75% of the draw calls when activated (redraws the scene for each cascade), so if you use this technique, manually hiding surfaces the player “can’t see” won’t yield that much performance imo.

Zylann | 2017-08-11 20:06

Player in level can see only front faces, but for sun they are back faces. So they doesn’t render to shadow map and player doesn’t see shadow casted by wall that player can see inside the level. In other words, level is not a closed mesh.
I downloaded this level from Internet and loaded it in Godot. It was already optimized, so it is not my idea to hide back faces.

gammaker | 2017-08-11 20:20

Shadow mapping does inverts backfaces to project shadows, that’s how this technique actually works. I don’t know what could be going on, then :confused:
If you have an example project you could try submitting it here so I could have a look, or an issue on Github showing the problem to the devs.

Zylann | 2017-08-12 16:15

Really? I thought that face inversion is not necessary for shadow map, but sometimes it may be useful option. Both options should work well for closed meshes. But my level is not closed mesh, so both sides must be rendered.

Here is my project where you can see problem:
https://drive.google.com/open?id=0B0wvbicW8OQINXRROUJ3cnFrZTQ

gammaker | 2017-08-13 09:24

Have a look at my project, please. Did you see it?

gammaker | 2017-08-17 09:59

To be honest, I created a simple map recently, and noticed every tunnel was not in shadow, similar to yours. I’ll try to find out which backfaces in particular have this issue (or maybe it’s all of them?) and I’ll open a Github issue

Edit: oh my god… Godot implements shadow mapping the other way around. Backfaces are completely ignored.
I opened a thread Shadow mapping ignores backfaces · Issue #10404 · godotengine/godot · GitHub

Zylann | 2017-08-17 20:55