Difference between revisions of "Shader Authoring"

From Valve Developer Community
Jump to: navigation, search
(Setting The Path)
(removed outdated link, removed "outdated programming articles" category)
Line 53: Line 53:
 
* You can get more information about HLSL and shader assembly programming in [http://msdn2.microsoft.com/en-us/library/bb509561.aspx the online MSDN docs].
 
* You can get more information about HLSL and shader assembly programming in [http://msdn2.microsoft.com/en-us/library/bb509561.aspx the online MSDN docs].
 
* [[:Category:Material System]] -- for more general information on the usage of shaders in materials.
 
* [[:Category:Material System]] -- for more general information on the usage of shaders in materials.
* [http://www.wraiyth.com/index.php?q=node/5 Wraiyths Shader Tutorials]
 
  
 
{{otherlang:en}}
 
{{otherlang:en}}

Revision as of 09:27, 6 May 2010

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.

Getting Started

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 Perl

To install Perl, go to the download page on http://www.perl.com , download, and install Perl - a recommended version of Perl for windows is ActivePerl.

The Orange Box SDK also relies on the non-standard perl package, String-CRC32. If you are using Active Perl, you can install it through the Perl Package Manager which can be launched from <PerlDir>\bin\ppm.bat

Note: The String-CRC32 package is hidden by default. Show all packages via the view menu to find it.

Installing DirectX

To install the November 2008 DirectX SDK, go to Microsoft's DirectX site, download, and install the DirectX SDK. Be sure to get the November 2008 version of the SDK.

Note:Just having DirectX 9.x installed is not sufficient, the DirectX SDK must be installed!
Note:It is recommended that you use the November 2008 SDK as needed binaries have been removed from newer releases

Setting The Path

With Perl and the DirectX SDK installed, make sure your "Path" environmental variable has been updated appropriately. In Windows, you can check this by right clicking on My Computer -> properties, going to the Advanced tab, and clicking on "Environment Variables". Assuming that Perl is installed into C:\Perl, and DirectX into C:\DXSDK, your "Path" variable should contain both C:\Perl\bin and C:\DXSDK\Utilities\bin\x86 in a semicolon delimited list.

By setting up the Environmental Variable in this way, you can update the Perl and DirectX sdk as you please without having to copy files. If for some reason you do not wish to do this, you can simply copy the required files into a different directory and add that to your path instead.

Note that you may need to restart your computer for these changes to the environment to take full effect.

Modify buildsdkshaders.bat path

open MyMod\src\materialsystem\stdshaders\buildsdkshaders.bat and set the GAMEDIR AND SDKBINDIR as instructed.

rem == Set the absolute path to your mod's game directory here ==
rem == Note that this path needs does not support long file/directory names ==
rem == So instead of a path such as "C:\Program Files\Steam\steamapps\mymod" ==
rem == you need to find the 8.3 abbreviation for the directory name using 'dir /x' ==
rem == and set the directory to something like C:\PROGRA~2\Steam\steamapps\sourcemods\mymod ==
set GAMEDIR= YOUR PATH HERE
rem == Set the relative path to SourceSDK\bin\orangebox\bin ==
rem == As above, this path does not support long directory names or spaces ==
rem == e.g. ..\..\..\..\..\PROGRA~2\Steam\steamapps\<USER NAME>\sourcesdk\bin\orangebox\bin ==
set SDKBINDIR= YOUR PATH HERE

See also

Template:Otherlang:en Template:Otherlang:en:ru