JoeyDeVries / LearnOpenGL

Code repository of all OpenGL chapters from the book and its accompanying website https://learnopengl.com
https://learnopengl.com
Other
11.11k stars 2.81k forks source link

Cascaded shadow mapping tutorial has disappearing shadows #405

Open enginmanap opened 1 month ago

enginmanap commented 1 month ago

In the following part of the example: https://github.com/JoeyDeVries/LearnOpenGL/blob/a545a703f95893258d16dbe32f5ccbb6400fd213/src/8.guest/2021/2.csm/shadow_mapping.cpp#L703

MinZ/MaxZ is calculated based on the player perspective, but if the resulting min/max is between -1 and 0, then the operation makes the orthogonal matrix smaller than player visible area, resulting in missing shadows, only on specific view angles + positions, as resulting frustum corner has to be (-1,0).