Source Shader Editor - Node types

From Valve Developer Community
Revision as of 00:22, 21 July 2011 by Biohazard 90 (talk | contribs) (typos)

Jump to: navigation, search

This article will provide an overview of nodes that are specific to the shader editor. For a general reference of HLSL arithmetics refer to microsofts official documentation [1].


VS Input

Provides the input data for the vertex shader. Use the node properties dialog to define which semantics should be available. The shader implementation will only request the respective data from the mesh if you actually connect the output jacks with anything. Trying to read something that is not actually provided by the mesh will result in errors when rendering with that shader.

VS Output and PS Input

These nodes are dependent from one another. The data you provide for VS Output node will be linearly interpolated and accessible from the PS Input node. Use the properties dialog of either node to define the datatype per jack and set a custom name if you like for easier readability. If you want to use datatypes that require multiple rows, make sure that you enabled them via the sliders at the top first, otherwise they won't be accessible.

PS Output

The final pixel color of your shader will be sent to this node. You will usually only write to the semantic Color 0, the other three color semantics can allow you to write data to MRTs. The depth output semantic can be used to manipulate the z position (in post-projection space) on pixel shader level, its default is projpos.z/projpos.w.



Inverts an unsigned, normalized value: 1.0 - input.

Append (Vectors)

Combines two inputs into one. The output can not exceed a four component vector.

Swizzle (Vectors)

Uses arbitrary swizzling on a vector. You can also swizzle with constants and change the vector dimensions as you see fit. Use the properties dialog to define the swizzle operation, supports token channels.



The model view projection matrix will instantly transform your mesh into projection space, this is the fastest way to project a vertex into the scene.


Transforms a vector from object to world space. Use this operation if you want a straight world transform and read the world position for usage elsewhere.


Transforms a vector from world into projection space. You will usually multiply with this matrix after transforming into world space.


View matrix inverse. To do: Confirm.

Matrix compose

Build a matrix from input vectors.


Texture sample

Samples color from a texture. You can define a custom name for a parameter to use in the vmt or choose from existing ones.
  • The demo texture you can load will be used for the in-editor previews, not when previewing shaders in the scene or using the shader in a vmt.
  • The fallback texture will be used when the actual material parameter is undefined, this counts for previewing shaders in the scene and actual finalized shaders referenced by vmts.
  • Choosing auto select as lookup mode will either require you to pass a two component vector for UVs or a three component vector for a cubemap dependent from the parameter type and the demo texture you specified. Change the lookup function as you see fit.

Texture transform

Transforms UVs by a matrix. This node is rather expensive and should be used sparingly. Supports the following matrix operations: Scale, translation, rotation. Use its properties dialog to hide the operations that you won't need. You can specifiy a custom center if you want, the default center is at "0.5 0.5".


Local constants

Define a local value with up to four components. Supports token channels.

Callback constant

Access a callback value defined by the client library.

VParam static

Read from a custom material parameter. Supports token channels for the default values.

VParam mutable

Read from a dynamic material parameter.

Random float

Access a random value with up to four components from the shader implementation library. You can define the amount of components and the min/max value in the node properties.

View data

Access data of the current view setup.


Time in seconds, unaffected by host_timecale.

FB texelsize

Returns 1.0 / backbuffersize for width and height. Useful when mapping textures onto the screen or using uv offsets that are supposed to be a multiple of the texel size.

Fog params

Current fog data.


Scalar to adjust shader luminosity for HDR compatibility.

Bump basis

Necessary when using normalmaps on brushes.

Control flow

Refer to [*] for a detailed explanation on how to correctly implement these nodes.


Iterate the child nodes of the Loop node a given amount of times.

Shader combo

Execute or ignore the contained nodes depending on whether a combo fullfills the given requirements.



Re-declare a variable in the current scope.


Write the value of the second input into the variable of the first one. Doesn't solve if the variable of input one is read-only.

Pixel fog

Computes the fog factor.

Final output

Blends with fog, writes depth to the alpha channel and scales the color by a lighting scale.


Projects the flashlight onto your geometry. This is meant to replace diffuse (and specular) lighting for the flashlight pass.

Utility / Studio model

Vertex lighting

Calculates either the per vertex attenuation for each dynamic light or does the whole lighting calculation per vertex.

Pixelshader lighting

Generates the diffuse lighting per pixel.

Pixelshader specular

Calculates the specular lighting per pixel.


A necessarity for (animated) models. Transforms each vertex based on bone weights and replaces the object to world transformation.


Applies the morphing deltas in object space, used for vertex animations.