Virtual Ambient Light Textures
To improve performance on some low-end systems, Dark Mod textures can simulate the main ambient light. This feature pre-calculates how much textures should be illuminated once only instead of continuously. Players can select between three methods for ambient rendering, so those with faster machines can use the true ambient light which gives better quality.
So all textures should include these two stages:
Please note that there is also a command for automatically converting all materials to fulfill the TDM 1.03 requirements called tdm_batchConvertMaterials (see TDM Material Batch Conversion)
// TDM Ambient Method Related { if (global5 == 1) blend add map textures/darkmod/yourname // Diffuse 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 textures/darkmod/yourname_local // Bump fragmentMap 2 textures/darkmod/yourname // Diffuse fragmentMap 3 textures/darkmod/yourname_s // Specular }
The first stage is for the simple ambient method, whereas the second one is for enhanced ambient rendering, which obviously also processes the normal- and specularmap of the material.
If a material does not contain a specularmap, the fragmentMap parameter 3 in the enhanced ambient rendering stage has to be changed to _black, e.g. "textures/darkmod/yourname_s" becomes "_black". If on the contrary a material does not contain a normalmap, the proper replacement is "_flat", meaning a flat surface, e.g. "textures/darkmod/yourname_local" becomes "_flat".
For vertex-blended materials, the ambient stages have to be altered in the following way:
// TDM Ambient Method Related { if (global5 == 1) blend add map textures/darkmod/materialA // Diffuse A scale 1, 1 red global2 green global3 blue global4 vertexColor } { if (global5 == 1) blend add map textures/darkmod/materialB // Diffuse B scale 1, 1 red global2 green global3 blue global4 inverseVertexColor } { if (global5 == 2) blend add program ambientEnvVertexBlend.vfp vertexParm 0 1, 1, 1, 1 // UV Scales for Diffuse A and Bump A resp. vertexParm 1 1, 1, 1, 1 // UV Scale for specular A and Diffuse B resp. vertexParm 2 1, 1, 1, 1 // UV Scale for Bump B and specular B resp. vertexParm 3 global2, global3, global4, 1 //----------- VertexColored ------------------- fragmentMap 0 cubeMap env/gen1 fragmentMap 1 textures/darkmod/materialA_local // Bump A fragmentMap 2 textures/darkmod/materialA // Diffuse A fragmentMap 3 textures/darkmod/materialA_s // Specular A //----------- InverseVertexColored ------------ fragmentMap 4 textures/darkmod/materialB_local // Bump B fragmentMap 5 textures/darkmod/materialB // Diffuse B fragmentMap 6 textures/darkmod/materialB_s // Specular B }