Shader authoring/Compiling Shaders: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
mNo edit summary
No edit summary
Line 7: Line 7:


=Compiling .FXC Files=
=Compiling .FXC Files=
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:  
To compile .FXC files, list them in a text file (one per line), then run src\materialsystem\stdshaders\buildsdkshaders.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 buildsdkshaders.bat command line is:  


<pre>
<pre>
BuildShaders.bat [text filename] -game [mod directory] -source [source directory]
buildsdkshaders.bat [text filename] -game [mod directory] -source [source directory]
</pre>
</pre>


Line 16: Line 16:


<pre>
<pre>
BuildShaders.bat MyShaders.txt -game C:\Steam\SteamApps\SourceMods\MyMod -source C:\MyMod\Src
buildsdkshaders.bat MyShaders.txt -game C:\Steam\SteamApps\SourceMods\MyMod -source C:\MyMod\Src
</pre>
</pre>


{{note|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.  
{{note|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 buildsdkshaders.bat.  


Before building your shader DLL, you need to run BuildShaders.bat, so it can generate include files that your shader DLL will need.}}
Before building your shader DLL, you need to run buildsdkshaders.bat, so it can generate include files that your shader DLL will need.}}


You can look in src\sdkshaders\build_sample_shaders.bat for an example of how it's setup. sdk_shaders.txt specifies all the .FXC files, all the source code for the shader DLL is in the same directory, and the .INC files are placed in the fxctmp9 directory. After BuildShaders.bat runs, you can look in the fxctmp9 directory to see the include files generated by the shader compiler.
Refer to <code>stdshaders_dx8.txt</code> and <code>stdshaders_dx9.txt</code> 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 <code>buildsdkshaders.bat</code> runs, you can look in the <code>fxctmp9</code> sub-directory to see the include files generated by the shader compiler.


Important note: shader have to be named something like for example xxxxxxxx_ps20.fxc or xxxxxxxxx_ps11.fxc
{{note|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)}}

Revision as of 17:25, 13 September 2006

Broom icon.png
This article or section needs to be cleaned up to conform to a higher standard of quality.
For help, see the VDC Editing Help and Wikipedia cleanup process. Also, remember to check for any notes left by the tagger at this article's talk page.

Compiling .FXC Files

To compile .FXC files, list them in a text file (one per line), then run src\materialsystem\stdshaders\buildsdkshaders.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 buildsdkshaders.bat command line is:

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

Example:

buildsdkshaders.bat MyShaders.txt -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 buildsdkshaders.bat. Before building your shader DLL, you need to run buildsdkshaders.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 buildsdkshaders.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)