TheOverfloater / pathos-public

Public release of Pathos Engine
MIT License
39 stars 9 forks source link

Suggestion: Cascaded Shadow Mapping #17

Closed valina354 closed 4 months ago

valina354 commented 4 months ago

i dont know if suggestions are allowed here but if they are a suggestion i have is csm, the engine already has dynamic lighting but its not too important indoors at least for some, csm fixes that as csm is used for sun lighting, i would do it myself but i dont know how to do shadow mapping so i kinda cant, it shouldnt be too complex as its similar to shadow mapping except uses 4/3 cascades and is done from the sun lighting, its possible to fake it rn by placing 3 dlights in the sky but it just looks bad unless you have a box skybox

TheOverfloater commented 4 months ago

Currently CSM is out of scope for Pathos, as it would require a level of rework of the engine that I do not have the capacity for, and I cannot afford to overload myself at this time. If it happens, it's far off into the future.

valina354 commented 4 months ago

Currently CSM is out of scope for Pathos, as it would require a level of rework of the engine that I do not have the capacity for, and I cannot afford to overload myself at this time. If it happens, it's far off into the future.

ok, im wondering what exactly engine rework means? or does that mainly mean the rendering code for csm or something else?

TheOverfloater commented 4 months ago

It means needing to rewrite portions of the engine to support cascaded shadow mapping. The current setup is already quite convoluted, and compiles down to a high number of shader permutations. Adding CSM would not just be a significant amount of time, but also to be considered is the time required for bugfixing, playesting, and most of all optimization, so the feature is actually viable from a performance standpoint.

valina354 commented 4 months ago

It means needing to rewrite portions of the engine to support cascaded shadow mapping. The current setup is already quite convoluted, and compiles down to a high number of shader permutations. Adding CSM would not just be a significant amount of time, but also to be considered is the time required for bugfixing, playesting, and most of all optimization, so the feature is actually viable from a performance standpoint.

i have been wondering since shadow mapping is already done for env_dlights if it would be possible to maybe instead make it so like dynamic dlight light comes from a sky texture and uses params of light_enviorment with of course toggleable functionality, could that work instead of just writing bunch of new code for csm or something

TheOverfloater commented 4 months ago

Cascaded shadow mapping is more complicated than just regular shadow maps. The visible and non-visible outside parts of the level need to be re-rendered, and currently there's no real way to tell outside leaves from inside ones, so the whole map would essentially be re-rendered for the cascaded shadowmap. This would require BSP compiler-level modifications to enable an efficient and easy way of telling which parts of the map that the "outside" can see, and I don't even know how I would accomplish this task because I am not good at that type of math. Second, CSM relies on the shadowmap having multiple mip-levels based on distance, which is yet again going to be a performance concern because I might need to re-render the world for each of these mip levels. Also a way to separate light_environment info in the lightmap data if CSM is used or not, as it would need to be toggleable via a cvar. Optimizing such an implementation would significantly lengthen the time needed to add it, along with researching how to do it in a fast way, and the amount of bugfixing and testing required is something at this time I am not willing to expend time on.

valina354 commented 4 months ago

Cascaded shadow mapping is more complicated than just regular shadow maps. The visible and non-visible outside parts of the level need to be re-rendered, and currently there's no real way to tell outside leaves from inside ones, so the whole map would essentially be re-rendered for the cascaded shadowmap. This would require BSP compiler-level modifications to enable an efficient and easy way of telling which parts of the map that the "outside" can see, and I don't even know how I would accomplish this task because I am not good at that type of math. Second, CSM relies on the shadowmap having multiple mip-levels based on distance, which is yet again going to be a performance concern because I might need to re-render the world for each of these mip levels. Also a way to separate light_environment info in the lightmap data if CSM is used or not, as it would need to be toggleable via a cvar. Optimizing such an implementation would significantly lengthen the time needed to add it, along with researching how to do it in a fast way, and the amount of bugfixing and testing required is something at this time I am not willing to expend time on.

ok, i guess i will try doing it myself and seeing actual performance drop by just making csm come from a sky texture as that seems like big issue

valina354 commented 4 months ago

whoops should have been closed as not planned