Source SDK 2013: Shader Authoring: Difference between revisions
Deniz Sezen (talk | contribs) m (Finished off the section.) |
Deniz Sezen (talk | contribs) m (Made wording clearer.) |
||
Line 26: | Line 26: | ||
== Setting up the build == | == Setting up the build == | ||
Previous versions of the Source SDK used to ship all of the code for the stdshader_dx9 module. This paradigm was abandoned in favor of using a custom game shader module approach. There are | Previous versions of the Source SDK used to ship all of the code for the stdshader_dx9 module. This paradigm was abandoned in favor of using a custom game shader module approach. There are two advantages with this approach: | ||
# You no longer need to build all of the base shaders that ship with the Source SDK. | |||
#* Like <code>vertexlitgeneric</code> which had thousands of shader combinations. | |||
# You can replace stock SDK shaders with your own implementation. | |||
#* In theory all you'd need to do is create a shader with the same name. | |||
=== Creating your game_shader_dx9 project === | === Creating your game_shader_dx9 project === | ||
Line 32: | Line 36: | ||
# Copy the <code>game_shader_dx9_episodic.vpc</code> file and rename it to <code>game_shader_dx9_<modname>.vpc</code>. | # Copy the <code>game_shader_dx9_episodic.vpc</code> file and rename it to <code>game_shader_dx9_<modname>.vpc</code>. | ||
# Modify the <code>game_shader_dx9</code> section in <code>src/vpc_scripts/projects.vgc</code> so that it points to the game_shader_dx9_<modname>.vpc file you created in step 1. | # Modify the <code>game_shader_dx9</code> section in <code>src/vpc_scripts/projects.vgc</code> so that it points to the game_shader_dx9_<modname>.vpc file you created in step 1. | ||
# Create a batch file that actually generates the <code>shaders</code> project group. | # Create a batch file that actually generates a solution/makefile for the <code>shaders</code> project group. | ||
=== Creating a batch file to build shaders === | |||
You'll need to create a batch file that calls <code>buildsdkshaders.bat</code> in order to compile your shaders. Luckily, you can just re-use the batch files shipped with the SDK. Navigate to <code>src/materialsystem/stdshaders</code> and perform the following steps to create your batch file: | |||
# Copy <code>buildepisodicshaders.bat</code> and rename it to <code>build<modname>shaders.bat</code>. | |||
# Open up <code>build<modname>shaders.bat</code> in notepad and modify the following: | |||
## Change '''GAMEDIR''' to wherever your mod directory is located at. | |||
## Change '''SDKBINDIR''' to point to the \bin directory of the variant of the Source SDK Base 2013 you're basing your mod off of. | |||
You should now have a batch file that is capable of building shaders for your mod. |
Revision as of 16:34, 26 December 2014
Introduction
Shaders are an important part of Source development. They allow you to create and utilize complex graphical effects that would not be possible with art assets alone. This intention of this page will be to serve as both an introduction to and a gateway for shader development using the Source 2013 SDK.
Pre-requisites
Assumptions
In order to avoid cluttering this page with tons of information, this guide assumes you've already checked out the Source 2013 SDK from GitHub. If you haven't, please follow the instructions on the Source SDK 2013 page. This guide will further assume that you've built the SDK successfully before reading this page.
Installing Perl
The Source SDK contains a bunch of perl scripts that are run during the shader compile process. Naturally, to run these, you'll need to install ActivePerl. You should grab the 64-bit version from here and install it. When the installation completes, you will need to install the String-CRC32 Perl module using the Perl Package Manager which you can find via the start menu. When both products are installed, open up a command prompt window and type:
perl -v
You should see output similar to the following:
This is perl 5, version 18, subversion 4 (v5.18.4) built for MSWin32-x64-multi-thread (with 1 registered patch, see perl -V for more detail) Copyright 1987-2013, Larry Wall Binary build 1803 [298573] provided by ActiveState http://www.ActiveState.com Built Oct 20 2014 10:19:51 Perl may be copied only under the terms of either the Artistic License or the GNU General Public License, which may be found in the Perl 5 source kit. Complete documentation for Perl, including FAQ lists, should be found on this system using "man perl" or "perldoc perl". If you have access to the Internet, point your browser at http://www.perl.org/, the Perl Home Page.
If you see output similar to the above, it means Perl was installed successfully and you can continue.
Setting up the build
Previous versions of the Source SDK used to ship all of the code for the stdshader_dx9 module. This paradigm was abandoned in favor of using a custom game shader module approach. There are two advantages with this approach:
- You no longer need to build all of the base shaders that ship with the Source SDK.
- Like
vertexlitgeneric
which had thousands of shader combinations.
- Like
- You can replace stock SDK shaders with your own implementation.
- In theory all you'd need to do is create a shader with the same name.
Creating your game_shader_dx9 project
Navigate to src/materialsystem/stdshaders
and perform the following steps:
- Copy the
game_shader_dx9_episodic.vpc
file and rename it togame_shader_dx9_<modname>.vpc
. - Modify the
game_shader_dx9
section insrc/vpc_scripts/projects.vgc
so that it points to the game_shader_dx9_<modname>.vpc file you created in step 1. - Create a batch file that actually generates a solution/makefile for the
shaders
project group.
Creating a batch file to build shaders
You'll need to create a batch file that calls buildsdkshaders.bat
in order to compile your shaders. Luckily, you can just re-use the batch files shipped with the SDK. Navigate to src/materialsystem/stdshaders
and perform the following steps to create your batch file:
- Copy
buildepisodicshaders.bat
and rename it tobuild<modname>shaders.bat
. - Open up
build<modname>shaders.bat
in notepad and modify the following:- Change GAMEDIR to wherever your mod directory is located at.
- Change SDKBINDIR to point to the \bin directory of the variant of the Source SDK Base 2013 you're basing your mod off of.
You should now have a batch file that is capable of building shaders for your mod.