Source SDK 2013: Your Third Shader: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
(Created page with "= Introduction = Welcome to the third tutorial in the Source SDK 2013 shader tutorial series. This article will walk you through loading textures into your shader and perf...")
 
Line 7: Line 7:
# [[Source SDK 2013: Your First Shader]]
# [[Source SDK 2013: Your First Shader]]
# [[Source SDK 2013: Your Second Shader]]
# [[Source SDK 2013: Your Second Shader]]
If you haven't read through these, please do before continuing. This article will also assume you were able to get the code from the '''first''' shader tutorial built and working. We'll be using that code as the starting point for this article. You should have the following files on hand and ready to modify:
If you haven't read through these, please do before continuing. This article will also assume you were able to get the code from the [[[[Source SDK 2013: Your First Shader|first]] shader tutorial built and working. We'll be using that code as the starting point for this article. You should have the following files on hand and ready to modify:
{| class="standard-table"
{| class="standard-table"
|-
|-

Revision as of 11:39, 28 December 2014

Introduction

Welcome to the third tutorial in the Source SDK 2013 shader tutorial series. This article will walk you through loading textures into your shader and performing various operations on them.

Prerequisites

This tutorial builds on material covered in previous tutorials which are the following:

  1. Source SDK 2013: Shader Authoring
  2. Source SDK 2013: Your First Shader
  3. Source SDK 2013: Your Second Shader

If you haven't read through these, please do before continuing. This article will also assume you were able to get the code from the [[first shader tutorial built and working. We'll be using that code as the starting point for this article. You should have the following files on hand and ready to modify:

File path Purpose
src/materialsystem/stdshaders/MyShader.cpp This is the C++ code for the shader we'll be building.
src/materialsystem/stdshaders/my_pixelshader_ps2x.fxc This is the pixel shader code we'll be modifying.
game/<modname>/materials/mymaterial.vmt This is the material we'll be modifying with new parameters.

This article also assumes you know C++.

Overview

What are textures?

You can think of a texture as a 2D array which has both a width and a height property. Each array element consists of data which can represent anything. The most intuitive use of a texture is to store RGBA color data in each array element. However, you can encode all kinds of information other than color in a texture. For example, a bumpmap texture encodes 3D height values into the RGBA components instead of a color. A specular mask texture encodes the intensity of reflected light from a given pixel on a texture. The possibilities are endless.

Note.pngNote:Textures in Source are stored in a proprietary format called the Valve Texture Format.