View Issue Details

IDProjectCategoryView StatusLast Update
0006076The Dark ModGraphicspublic03.09.2022 09:39
Reporterstgatilov Assigned Tostgatilov  
Status resolvedResolutionfixed 
Product VersionTDM 2.10 
Target VersionTDM 2.11Fixed in VersionTDM 2.11 
Summary0006076: Optimize soft stencil shadows limit expensive sampling for near-penumbra regions
DescriptionRight now when user enables soft stencil shadows, expensive stencil + depth sampling is performed for all fragment of the surfaces being rendered.
Most of the surfaces are fully lit of fully unlit and far enough from penumbra, so if we can detect such state, we can cull away this expensive sampling.

The idea is to divide screen into "tiles", and for each tile precompute if it only has "lit" or "unlit" values.
Then pass this tile texture into interaction shader, sample it there. If it says 0.0 or 1.0, then just use this value and avoid sampling.

Note that in order to make it work, we need hard upper bound on sampling radius in screen pixels.
Luckily, the original implementation of soft stencil shadows already have one.
Additional InformationInternal discussion:
TagsNo tags attached.




03.09.2022 09:39

administrator   ~0015223

Committed in svn rev 10107.
Enabled by cvar r_softShadowsMipmaps: but only for stencil shadows, and only with new backend.

And interesting thing is that we now have a file used both from C++ and GLSL.
It's called tdm_shadowstencilsoft_shared.glsl and contains just a tiny function.
But this is first precedent, and I think such usage will increase in future.

It seems that this optimization is not always good.
Even though filling tiled mipmaps takes only 20 us, it causes performance degradation when there are many shadow-casting lights.
Attached Tracy view of single frame on New Job (on street near tavern entrance).

Issue History

Date Modified Username Field Change
21.08.2022 15:40 stgatilov New Issue
21.08.2022 15:40 stgatilov Status new => assigned
21.08.2022 15:40 stgatilov Assigned To => stgatilov
03.09.2022 09:39 stgatilov Note Added: 0015223
03.09.2022 09:39 stgatilov File Added: Newjob_TiledScencilShadows.png
03.09.2022 09:39 stgatilov Status assigned => resolved
03.09.2022 09:39 stgatilov Resolution open => fixed
03.09.2022 09:39 stgatilov Fixed in Version => TDM 2.11