TDM Material Batch Conversion

From The DarkMod Wiki
Revision as of 13:21, 27 December 2010 by Stifu (talk | contribs)
Jump to navigationJump to search

Some of the ambient rendering methods available in TDM require ambient stages in all the material definitions (see Virtual Ambient Light Textures). Since TDM 1.03, there is a command that automatically converts materials to be compatible with all the ambient methods. This command is called tdm_batchConvertMaterials.

Explanation of the command

The command tdm_batchConvertMaterials analyses a defined number of materials and alters them according to the requirements imposed by TDM 1.03. Its console explanation reads:

Usage: tdm_batchConvertMaterials <StartIndex> <nMaterials> [forceUpdateAll]

StartIndex is a number that defines at what material the command is supposed to start processing and nMaterials defines how many successive materials should be processed. TDM currently consists of about 9000+ materials, so one would probably go ahead and just run the command with the parameters: tdm_batchConvertMaterials 0 10000. The problem is that all materials are parsed into RAM which will eventually lead to malloc errors, when the RAM is full.

If forceUpdateAll is also set, the command will update all materials, independent of the results of the analysis.

Proper usage of the command

In order to run the command without running into malloc errors, one has to successively execute it on different partitions of the materials. If you choose nMaterials=1000 (which appears to be a good value), you'll have to start the command multiple times while increasing the StartIndex and restarting TDM after each execution (in order to free the memory again). Here is an example:

tdm_batchConvertMaterials 0 1000
*Wait for finish and restart TDM*
tdm_batchConvertMaterials 1000 1000
*Wait for finish and restart TDM*
tdm_batchConvertMaterials 2000 1000
...


Eventually the console will say "0 Materials processed and changed in total.", which means you're done.

I followed the above instructions but still ran into malloc errors

It may occur that you run into malloc errors, although the first executions of the command were successful. This is due to the fact that some materials are more complex than others and require more RAM for that reason. Remember the last StartIndex and re-execute the command with that index, but a decreased nMaterials. Say for example, you received a malloc error after executing "tdm_batchConvertMaterials 4000 1000". You would now go ahead and do the following:

tdm_batchConvertMaterials 4000 500
*Wait for finish and restart TDM*
tdm_batchConvertMaterials 4500 500
...

After those two executions, you can actually try to raise nMaterials again to a higher value, in order to reduce the required user-input.

Known issues