View Issue Details

IDProjectCategoryView StatusLast Update
0005449The Dark ModTexturespublic29.12.2020 20:57
Reporterstgatilov Assigned Tostgatilov  
Status resolvedResolutionfixed 
Product VersionSVN 
Target VersionTDM 2.09Fixed in VersionTDM 2.09 
Summary0005449: Remove obsolete "Ambient Method" stages form materials
DescriptionMost of the materials have stages which look like this:
        // TDM Ambient Method Related
        if (global5 == 1)
        blend add
        map models/md5/chars/animals/horse
        scale 1, 1
        red global2
        green global3
        blue global4
        if (global5 == 2)
        blend add
        program ambientEnvironment.vfp
        vertexParm 0 1, 1, 1, 1 // UV Scales for Diffuse and Bump
        vertexParm 1 1, 1, 1, 1 // (X,Y) UV Scale for specular
        vertexParm 2 global2, global3, global4, 1
        fragmentMap 0 cubeMap env/gen1
        fragmentMap 1 models/md5/chars/animals/horse2/horse_local // Bump
        fragmentMap 2 models/md5/chars/animals/horse // Diffuse
        fragmentMap 3 models/md5/chars/animals/horse_s // Specular

The parameter global5 is passed from "tdm_ambient_method" cvar, which used to be tweakable in menu as Ambient method: Simple / Enhanced of something similar.
Nobody actually used this switch, and we removed it in 2.08, leaving tdm_ambient_method at its default value 0.
With such default value, the additional blocks are never used.

The goal of this task is to remove these stages from stock material, and remove associated code.
Additional InformationSee also:
TagsNo tags attached.


related to 0003122 closednbohr1more Add ambient and frobhighlight macros to the material parser 




19.12.2020 06:35

administrator   ~0013162

Last edited: 19.12.2020 06:36

View 2 revisions

  r9044. Removed tdm_ambient_method cvar and associated code.
  r16038. Added script for automatic removal of "ambient method" stages from materials.
  r16039. Removed "ambient method" stages from all materials.

The script removes two types of strings:
1) a line with "// TDM Ambient Method Related" and optional spaces/tabs at the beginning and at the end
2) a block starting with "{ if (global5" and ending with "}", with some optional spaces at various places
It leaves some excessive EOLs intact, but I guess it would be hard to remove them automatically.
Also, it reads/writes file in text mode, so it converts all EOL style to Windows (for some reason, half of .mtr files have EOL style set to LF in SVN, half of them don't).

I have applied the script to our material files.
Then I looked through all the diffs to make sure nothing bad happened (at pretty fast speed sometimes).
Also removed a few additional comments about ambient method (manually).
The total size of material files has reduced in almost two times =)

I have verified that there are NO remaining occurences of "Ambient Method" and "global5" in material directory.


19.12.2020 06:39

administrator   ~0013163

During manual review I have noticed two types of suspicious cases.

1) There is "// TDM Ambient Method Related" comment, but the following block does not have "if global5" check.
However, the block looks like ambient method-related. The script have not removed such blocks.
Here is the list:

2) Sometimes there is standard ambient method block PLUS one more block which looks like ambient block too.
List of materials:


19.12.2020 06:44

administrator   ~0013164

Actually, there are much more blocks from p.1, I could not notice them they don't have the comment, so they are not visible in diffs.
Searching for "global2" allows to find many more.


19.12.2020 16:06

administrator   ~0013165

Some more commits:
  r16040. Added regexp to remove ambient stages without "if global5".
  r16041. Removed more ambient stages (now without if) by the devel/ script.
  r16042. Removed some more ambient stages manually.
Basically, I removed some more blocks which don't have "if global5" but have "red global2" + "green global3" + "blue global4".

The only remaining occurence of global2-global5 is this one:
  // uses global parms
          map lights/spot01.tga
          red parm0 * global0
          green parm1 * global1
          blue parm2 * global2
I guess it is something old from D3, which does not work in TDM.


29.12.2020 20:57

developer   ~0013311

r16051 fixed dynamic ambient lights in Location System

Issue History

Date Modified Username Field Change
19.12.2020 06:12 stgatilov New Issue
19.12.2020 06:12 stgatilov Status new => assigned
19.12.2020 06:12 stgatilov Assigned To => stgatilov
19.12.2020 06:35 stgatilov Note Added: 0013162
19.12.2020 06:36 stgatilov Note Edited: 0013162 View Revisions
19.12.2020 06:39 stgatilov Note Added: 0013163
19.12.2020 06:44 stgatilov Note Added: 0013164
19.12.2020 16:06 stgatilov Note Added: 0013165
19.12.2020 16:06 stgatilov Status assigned => resolved
19.12.2020 16:06 stgatilov Resolution open => fixed
19.12.2020 16:06 stgatilov Fixed in Version => TDM 2.09
19.12.2020 20:51 nbohr1more Relationship added related to 0003122
29.12.2020 20:57 nbohr1more Note Added: 0013311