View Issue Details

IDProjectCategoryView StatusLast Update
0005106The Dark ModGraphicspublic09.03.2020 11:18
Reporterstgatilov Assigned Tostgatilov  
Status resolvedResolutionfixed 
Product VersionTDM 2.07 
Target VersionTDM 2.08Fixed in VersionTDM 2.08 
Summary0005106: dmap-optimized stencil shadows errors
DescriptionAs it is known, dmap computes some shadow volumes and puts them into .proc file.
When TDM renders such objects with stencil shadows, it takes these precomputed shadows instead of computing ones from scratch.
Supposedly, these "optimized shadows" are/were better for performance due to additional preprocessing.
It is possible to disable this optimization in-game by setting: r_useOptimizedShadows 0

Unfortunately, sometimes precomputed shadows are wrong.
It was reported by SteveL here:
"Piling lots of inlined models on top of one another (I did a pyramid of 500 barrels) causes shadow errors."

People bump into it from time to time on real maps too.
TagsNo tags attached.


related to 0003818 resolvedstgatilov Parallel lights glitch 




04.01.2020 04:30

administrator   ~0012051

Dragofer provided the real case (Perilous Refuge FM) where it caused problems:
See whole story in related issue 0003818.

I manage to reproduce the problem on beta version of the map:
At location: setviewpos 826.77 -1711.7 907.19
It is fixed by setting cvar: r_useOptimizedShadows 0


05.01.2020 03:42


peril_projected_buggyshot.jpg (98,985 bytes)   
peril_projected_buggyshot.jpg (98,985 bytes)   


05.01.2020 03:42

administrator   ~0012063

I have spent the whole day on this.
This might sound weird, but in the end it seems that ALL point lights with limited shadow frustum are completely buggy.
When shadow volumes are constructed in dmap, side faces are not added (i.e. the faces which are part of light frustum planes). This is an optimization which works perfectly well for full point lights: they have 6 different frustums, which together comprise the whole space. However, when there is only one light frustum, parts of its boundary must become the part of shadow volume. The flag which controls it is disabled for some reason.

Here are some screenshot showing the problem.
The "buggyshot" is created as usual. The "correct" is created by setting "r_useOptimizedShadows 0".
The "shadowvolume" shows precomputed shadow triangles of this only light source ("listEntities light_58", then "r_singleLight XXX", and "r_singleShadowEntity 123456789").
peril_projected_correct.jpg (94,358 bytes)   
peril_projected_correct.jpg (94,358 bytes)   
peril_projected_shadowvolume.jpg (168,723 bytes)   
peril_projected_shadowvolume.jpg (168,723 bytes)   


05.01.2020 03:43

administrator   ~0012064

BTW, there is a workaround for this issue, not as bad as "noShadows".
One can set "noPrelight 1" spawnarg on a light entity, then dmap won't precompute shadows for it. This will result in less time for dmapping, probably worse performance when rendering, and this bug will be avoided.
Anyway, I'll try to fix it now.


05.01.2020 05:26

administrator   ~0012069

After a full day of horrible debugging, I found the culprit.
The SIMD implementation of CullByFrustum2 added by Duzenko is buggy, that's why side faces are not added.
The SIMD implementation was added in middle of 2018, so the problem must have appeared at 2.07.


05.01.2020 05:41

administrator   ~0012070

The bug is present in AVX and AVX2 implementations.
So it happens if the person who dmaps the map has CPU supporting AVX, which are: Sandy bridge / Bulldozer (2011) and newer.


05.01.2020 06:16

administrator   ~0012071

Fixed in svn rev 8499.

It is recommended to re-dmap all the maps, which were dmapped with TDM 2.07.
At least if they had any projected/parallel lights.

Issue History

Date Modified Username Field Change
04.01.2020 04:27 stgatilov New Issue
04.01.2020 04:27 stgatilov Status new => assigned
04.01.2020 04:27 stgatilov Assigned To => stgatilov
04.01.2020 04:27 stgatilov Relationship added related to 0003818
04.01.2020 04:30 stgatilov Note Added: 0012051
05.01.2020 03:42 stgatilov File Added: peril_projected_buggyshot.jpg
05.01.2020 03:42 stgatilov File Added: peril_projected_correct.jpg
05.01.2020 03:42 stgatilov File Added: peril_projected_shadowvolume.jpg
05.01.2020 03:42 stgatilov Note Added: 0012063
05.01.2020 03:43 stgatilov Note Added: 0012064
05.01.2020 05:26 stgatilov Note Added: 0012069
05.01.2020 05:41 stgatilov Note Added: 0012070
05.01.2020 06:16 stgatilov Note Added: 0012071
05.01.2020 06:16 stgatilov Status assigned => resolved
05.01.2020 06:16 stgatilov Resolution open => fixed
05.01.2020 06:16 stgatilov Fixed in Version => TDM 2.08
09.03.2020 11:18 stgatilov Target Version => TDM 2.08