Compiling Shaders

From Valve Developer Community
Jump to: navigation, search
English (en)
... Icon-Important.png

To compile FXC files, list them in a text file (one per line), then run src\materialsystem\stdshaders\buildshaders.bat on the text file. It will go process your .fxc code and compile all the combinations into your mod's directory. The syntax of the buildshaders.bat command line is:

buildshaders.bat [text filename] -game [mod directory] -source [source directory]

Example:

buildshaders.bat MyShaders -game "C:\Steam\SteamApps\SourceMods\MyMod" -source "C:\MyMod\Src"
Note.pngNote:The text file that lists the FXC files should be in the same directory as your shader DLL source code, because your shader DLL source code will need to refer to files that are generated by buildshaders.bat. Before building your shader DLL, you need to run buildshaders.bat, so it can generate include files that your shader DLL will need.

Refer to stdshaders_dx8.txt and stdshaders_dx9.txt as examples of how to set up your shaders text file. All the source code for the shader DLL should be in the same directory as the .fxc, .vsh, and .psh files. After buildshaders.bat runs, you can look in the fxctmp9 sub-directory to see the include files generated by the shader compiler.

Note.pngNote:Shader names should adhere to the same convention as the sample ones distributed in the SDK (e.g. *_ps20.fxc for pixel shaders conforming to the 2.0 spec, *_vs11.fxc for vertex shaders conforming to the 1.1 spec.)
Note.pngNote:A shader compile may fail for many reasons. One of these is a high number of static combinations. This may cause the shader compiler to stop working. It may also stop because of the termination the process externally. A shader compile may also stop if the user terminates the process. When a shader compile is stopped in an unhanded manor, it may cause an issue within the Windows file system on some machines. If you encounter this complication, there are a few steps you can take to fix it. The first step is terminate all instances of the shadercompile executable. This can be dof the executable.one with the following command: taskkill /IM shadercompile /F. This will terminate all instances of shadercompile.exe. The next step is deleting the following folder: %localappdata%/temp/shadercompiletemp. Finally, run the Windows Defragment and Optimize Drives utility and allow it to Defragment the hard drive where your User Directory and Source Code can be found. If you are using a Solid State Drive, use CHKDSK.