Source SDK 2013: Shader Authoring: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
(Created page with "= 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...")
 
No edit summary
Line 3: Line 3:


== Pre-requisites ==
== 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.
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 [http://www.activestate.com/activeperl/downloads 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:
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 [http://www.activestate.com/activeperl/downloads 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:
<pre>perl -v</pre>
<pre>perl -v</pre>
Line 24: 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 number of advantages to this approach. The first advantage is that you no longer have to build all of the base shaders that ship with the Source SDK (such as vertexlitgeneric) which can number in the hundreds of thousands of combos. Your build would be constrained to shaders you've written. The second advantage is that you can override stock SDK shaders with your own as the game shader module is loaded after all of the stdshader_dxX modules.
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 number of advantages to this approach. The first advantage is that you no longer have to build all of the base shaders that ship with the Source SDK (such as vertexlitgeneric) which can number in the hundreds of thousands of combos. Your build would be constrained to shaders you've written. The second advantage is that you can override stock SDK shaders with your own as the game shader module is loaded after all of the stdshader_dxX modules.
=== Creating your game_shader_dx9 project ===
Navigate to <code>src/materialsystem/stdshaders</code> and perform the following steps:
# 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.
# Create a batch file that actually generates the <code>shaders</code> project group.

Revision as of 16:20, 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.

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 number of advantages to this approach. The first advantage is that you no longer have to build all of the base shaders that ship with the Source SDK (such as vertexlitgeneric) which can number in the hundreds of thousands of combos. Your build would be constrained to shaders you've written. The second advantage is that you can override stock SDK shaders with your own as the game shader module is loaded after all of the stdshader_dxX modules.

Creating your game_shader_dx9 project

Navigate to src/materialsystem/stdshaders and perform the following steps:

  1. Copy the game_shader_dx9_episodic.vpc file and rename it to game_shader_dx9_<modname>.vpc.
  2. Modify the game_shader_dx9 section in src/vpc_scripts/projects.vgc so that it points to the game_shader_dx9_<modname>.vpc file you created in step 1.
  3. Create a batch file that actually generates the shaders project group.