This document describes how to author shaders in the Source SDK, for further information on what a shader is and how they can be used, please see Shader.
Every material that is used in Source specifies which shader it uses to render itself. The shader contains the logic and equations to take the source artwork and lighting, and produce the final rendered color for every pixel that the shader is used on.
The Source SDK fully supports Microsoft DirectX HLSL (High Level Shading Language) and shader assembly languages for writing shaders. It is recommended to use HLSL whenever possible and to only write shader assembly as a last resort.
There are a number of external tools required to compile shaders for use in the Source SDK, the following sections detail the tools and provides links for download along with brief instructions on installation and usage.
The tools used are Perl, the DirectX SDK and make, the following processes, in general, only have to be performed once before the process of compiling shaders can begin.
Installing SCell555's Shader Compile
To install Scell555's Shader Compile tools, you must download the zip file which they provide with every release.
Once you have downloaded the zip file, open it up and you should see the following folders:
place "bin" into "devtools\" and place "stdshaders" into "materialsystem\". If you are using visual studio 2013, then place "headers\VS2013\cshader.h" into "puplic\"; I have not tested other versions of Visual Studio, but I assume that you would use "headers\cshader.h" instead.
Open "materialsystem\stdshaders\buildepisodicshaders.bat" and set the GAMEDIR AND SDKBINDIR as instructed.
You might also need to modify the call to vsvars32.bat on line 7 of "buildsdkshaders.bat". If you are using Visual Studio 2013 it should point to %VS120COMNTOOLS% instead.
@echo off setlocal rem ================================ rem ==== MOD PATH CONFIGURATIONS === rem == Set the absolute path to your mod's game directory here == set GAMEDIR="E:\Half Life 2 Zero\Half Life 2 Zero Game" rem == Set the relative or absolute path to Source SDK Base 2013 Singleplayer\bin == set SDKBINDIR="D:\Steam\steamapps\common\Source SDK Base 2013 Singleplayer\bin" rem == Set the Path to your mod's root source code == rem This should already be correct, accepts relative paths only! set SOURCEDIR="E:\Half Life 2 Zero\Half Life 2 Zero Source" rem ==== MOD PATH CONFIGURATIONS END === rem ==================================== call buildsdkshaders.bat
Note: You must put quotation marks around paths with spaces in.
Open up "materialsystem/stdshaders/stdshader_dx9_20b.txt" and comment out all of the lines which compile shaders like so:
// // Standard shaders collection // // These shaders are compiled as the following shader models: // _ps20.vcs // _ps20b.vcs // _vs20.vcs // //example_model_ps20b.fxc //example_model_vs20.fxc //SDK_Bloom_ps2x.fxc //SDK_screenspaceeffect_vs20.fxc //SDK_bloomadd_ps2x.fxc
Click on the path bar in the "materialsystem/stdshaders" folder, and type "cmd". Next, type in the name of the bat file for compiling your shaders; it will probably be "buildepisodicshaders.bat". If you did everything correctly, it should compile with no issues.