Virtual Ambient Light Textures: Difference between revisions

From The DarkMod Wiki
Jump to navigationJump to search
Tels (talk | contribs)
m update for v1.03
Peter spy (talk | contribs)
mNo edit summary
 
(6 intermediate revisions by 3 users not shown)
Line 1: Line 1:
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, so those with faster machines can use the true ambient light which gives better quality.
Edited by peter_spy, 2020<br><br>
As of TDM 2.08 none of the below is needed, as TDM uses ambient lights to calculate this instead of textures. The option to switch between this and legacy system is no longer in the menu, but you can type '''tdm_ambient_method 0''' in the game console to make sure you use the correct system.<br>
<br><br>
'''OLD VERSION:'''<br>
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:'''
'''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]])''


<pre>
<pre>
Line 8: Line 14:
                 if (global5 == 1)
                 if (global5 == 1)
                 blend add
                 blend add
                 map                             textures/darkmod/yourname
                 map                     textures/darkmod/yourname                         // Diffuse
                 scale                  1, 1
                 scale                  1, 1
                 red                             global2
                 red                     global2
                 green                  global3
                 green                  global3
                 blue                    global4
                 blue                    global4
         }
         }
         {
     
                if (global5 == 2)
</pre>
                blend add
 
                program ambientEnvironment.vfp
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.
                vertexParm             0               1, 1, 1, 1             // UV Scales for Diffuse and Bump
 
                vertexParm             1               1, 1, 1, 1     // (X,Y) UV Scale for specular
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".
                vertexParm             2              global2, global3, global4, 1
 
'''For [[DrVertexBlend (tutorial)|vertex-blended materials]], the ambient stages have to be altered in the following way:'''
<pre>
         // 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
}
</pre>
 
AS OF TDM 2.0 the old Enhanced Ambient Stages:
 
<pre>
 
{
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
}


                fragmentMap            0              cubeMap env/gen1
                fragmentMap            1              textures/darkmod/yourname_local                  // Bump
                fragmentMap            2              textures/darkmod/yourname                        // Diffuse
                fragmentMap            3              _black                  // Specular
        }
</pre>
</pre>
are '''no longer needed''' as the Ambient light now has it's own dedicated render path.


[[Category:Textures]]
[[Category:Textures]]
[[Category:Ambient Light]]
[[Category:Lighting]]

Latest revision as of 07:35, 11 December 2020

Edited by peter_spy, 2020

As of TDM 2.08 none of the below is needed, as TDM uses ambient lights to calculate this instead of textures. The option to switch between this and legacy system is no longer in the menu, but you can type tdm_ambient_method 0 in the game console to make sure you use the correct system.


OLD VERSION:
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
        }
       

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		
	}							
	

AS OF TDM 2.0 the old Enhanced Ambient Stages:


{							
		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
	}

are no longer needed as the Ambient light now has it's own dedicated render path.