View Issue Details

IDProjectCategoryView StatusLast Update
0005189The Dark ModCodingpublic05.12.2023 01:20
Reporterstgatilov Assigned Tostgatilov  
PrioritynormalSeveritynormalReproducibilityN/A
Status assignedResolutionopen 
Product VersionTDM 2.08 
Target VersionTDM 2.13 
Summary0005189: noshadows mask spawnarg for shadows optimization
DescriptionThe engine has "noshadows" spawnarg for lights, which makes the light rays pass through everything.
This keyword is often used to optimize away shadows drawing, which is often pretty expensive, especially for complex geometry with stencil implementation.
However, this keyword makes the light pass through brush walls (which is undesirable for mappers) and hence disables some useful area/portals optimization (performance).

The new idea is to allow players define "groups" of entities (as well as have some builtin groups), and allow to disable shadow for every light+group individually.
So, the lights get a new spawnarg "noshadows_mask", which contains the set of groups to not cast shadows from.
And the entities get a new spawnarg "shadow_groups", which specifies one (or even several) groups the entity belongs to.

OLD:
The idea is to add "shadowworldonly" spawnarg for such optimization purposes.
For a light with this spawnarg, shadows from worldspawn brushes (and patches) are enabled, but shadows from any entities (and models) are disabled.
This greatly reduces shadow drawing complexity, makes lights behave in a well-defined way (stable w.r.t future engine changes), and allows to use visportal-related optimizations (like light flow and interaction culling, including 0005172).
Additional InformationSee discussion:
  https://forums.thedarkmod.com/index.php?/topic/21106-mirceakitsune-ambient-light-and-noshadows/
OLD:
  https://forums.thedarkmod.com/index.php?/topic/20224-arealock-keyword/&do=findComment&comment=444731
TagsNo tags attached.

Relationships

related to 0005880 resolvedstgatilov Shadow maps backend should use shadow surfaces 

Activities

Dragofer

Dragofer

30.09.2021 18:27

developer   ~0014381

The spawnarg could be renamed from shadowworldonly to i.e. noshadows_entities (1 = entities cast no shadows, but worldspawn still casts shadows).
Advantages:
- similar to the existing and commonly used "noshadows" spawnarg, so hopefully easier to remember
- imo it better indicates that, effectively, this new spawnarg turns off shadows for entities (technically worldspawn is entity 0, but I think mappers don't think of it as an entity)
stgatilov

stgatilov

01.10.2021 02:54

administrator   ~0014383

I have rewritten this proposal in terms of shadow masks.
Since world geometry would have built-in group 0, "noshadows_entities" will simply be "noshadows_mask" "0".
stgatilov

stgatilov

17.10.2022 06:28

administrator   ~0015340

Last edited: 17.10.2022 06:44

Found the same idea in Unigine Engine:
  https://www.youtube.com/watch?v=nI8Q3bANsM8
but on a larger scale =)
stgatilov

stgatilov

15.06.2023 11:06

administrator   ~0016018

Looking at this again, I don't like the idea of setting hex numbers, decimal number, or binary numbers (bits) to spawnargs.
Because it would be hell for mappers to work with, and most likely it would be hard to change with backwards compatibility in mind.
Better use strings as group names.

Also, I don't like the idea of simple collections like "noshadows_mask world,animated,custom1"
Because then we get a question of whether we should use "shadows_mask" spawnarg (i.e. cast shadows is entity belongs to any of the groups) or "noshadows_mask" (i.e. don't cast if entity belongs to any of the groups), or some kind of complementary, etc.

I think the best approach would be to have "shadows_mask" spawnargs as an arbitrary boolean formula that allows shadow groups as atoms.
So there are built in groups, e.g. "world", "animated", "static", and user can define custom ones by setting e.g. "shadows_group _my1" on entity.
Then he can write formulas like "world | _my1" or "static & !world", etc. to define which entities should cast shadows from given light.
When engine has a light + entity, it evaluates the formula to either true of false, where every atom is set to whether entity belongs to the corresponding shadows group.

As for group names, we can enforce convention that custom groups must start from underscore ('_'), where builtin one do not.
"world" must definitely be a group (includes only world area models, as generated by dmap from brushes, patches, and inline entities).
Also it would be great to have "animated" group which includes animated entities and everything bound/attached to them (it is really weird when AI does not cast shadows, but his hammer does).
Not sure about the rest...

Issue History

Date Modified Username Field Change
22.03.2020 02:19 stgatilov New Issue
22.03.2020 02:19 stgatilov Status new => assigned
22.03.2020 02:19 stgatilov Assigned To => stgatilov
22.03.2020 02:22 stgatilov Additional Information Updated
05.12.2020 12:33 stgatilov Target Version TDM 2.09 => TDM 2.10
30.09.2021 18:27 Dragofer Note Added: 0014381
01.10.2021 02:53 stgatilov Summary shadowworldonly light keyword for shadows optimization => noshadows mask spawnarg for shadows optimization
01.10.2021 02:53 stgatilov Description Updated
01.10.2021 02:53 stgatilov Additional Information Updated
01.10.2021 02:54 stgatilov Note Added: 0014383
22.11.2021 14:06 stgatilov Target Version TDM 2.10 => TDM 2.11
25.07.2022 18:02 stgatilov Relationship added related to 0005880
17.10.2022 06:28 stgatilov Note Added: 0015340
17.10.2022 06:44 stgatilov Note Edited: 0015340
05.12.2022 19:34 nbohr1more Target Version TDM 2.11 => TDM 2.12
15.06.2023 11:06 stgatilov Note Added: 0016018
05.12.2023 01:20 nbohr1more Target Version TDM 2.12 => TDM 2.13