View Issue Details

IDProjectCategoryView StatusLast Update
0005459The Dark ModCodingpublic15.11.2022 17:08
Reporterstgatilov Assigned Tostgatilov  
Status assignedResolutionopen 
Product VersionTDM 2.09 
Target VersionTDM 2.12 
Summary0005459: Optimize idRenderWorldLocal::CreateLightDefInteractions for ambient_world light
DescriptionThe function idRenderWorldLocal::CreateLightDefInteractions searches for interactions of light like this:
    foreach area having light:
      foreach entity in area:
        if light is noshadows and entity not visible:
        ... # complicated code here

Ambient world light is noshadows and covers the whole map.
So all entities in the map are traversed every frame, just to see that they are not in the view and should be discarded.

I tried to profile game on Painter's Wife FM.
6.7% of time is spent on this function, most of which wasted on entity visibility check.
If I add this hack:
    volatile bool skipAmbientWorld = true;
    void idRenderWorldLocal::CreateLightDefInteractions( idRenderLightLocal *ldef ) {
      if (skipAmbientWorld && idStr::Icmp(gameLocal.entities[ldef->parms.entityNum]->spawnArgs.GetString("classname"), "atdm:ambient_world") == 0) {
        skipAmbientWorld = !!skipAmbientWorld;
Then only 1.4% is spent in this function. And all of it does into complicated logic of searching/adding interactions in the interaction table.

The idea of optimization is to extract light/entity processing into a separate function, then write second traversal.
The first traversal goes over all lights, then goes over their areas and entities.
The second traversal should go over visible entities, then go over lights in their areas.
The second approach should handle only specific class of lights, which are noshadows and large enough --- all the other lights should be handled with the first approach.
Additional InformationOriginally reported here, noticed during 100K entities experiment:
TagsNo tags attached.




15.11.2022 17:08

developer   ~0015432

A different approach might be planned for this. Tentatively moving to 2.12

Issue History

Date Modified Username Field Change
25.12.2020 16:31 stgatilov New Issue
27.02.2021 08:57 stgatilov Assigned To => stgatilov
27.02.2021 08:57 stgatilov Status new => assigned
27.02.2021 08:57 stgatilov Target Version TDM 2.10 =>
08.02.2022 14:54 nbohr1more Target Version => TDM 2.11
15.11.2022 17:08 nbohr1more Note Added: 0015432
15.11.2022 17:08 nbohr1more Target Version TDM 2.11 => TDM 2.12