Source Shader Editor - Node types
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 . You can also hover with your mouse pointer over nodes to show a tooltip about their functionality ingame, the same text is available on the 'General' tab in the nodes properties.
- 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.
- 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
- Inverts an unsigned, normalized value:
1.0 - input.
- Combines two inputs into one. The output can not exceed a four component vector.
- 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.
- Build a matrix from input vectors.
- 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.
- 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".
- Creates a new sampler variable in the shader and links a texture to it just like the node Texture sample.
- Calculates new UVs based on a heightmap. Parallax occlusion and relief mapping are supported. The amount of samples can be defined in the node properties.
- Enabling the world space offset will allow you to override the depth value in post projection space and also update the general world pos for correct parallax'd fog or flashlight calculations.
- The gradient lookup will be more expensive but yields better results. It's also necessary if you want to vary the amount of samples for the linear search.
- The POM technique will solely work on flat geoemtry, while Relief mapping offers limited support for displacements. Make sure that your textures on the displacement are not stretched to achieve good results.
- Darkens the parallax'd texture based on a fast self occlusion approximation. This node does not utilize a ray intersection technique and therefore provides only rough results.
- Define a local value with up to four components. Supports token channels.
- Access a callback value defined by the client library.
- Read from a dynamic material parameter.
- 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.
- Supports 1D or 2D arrays of arbitrary size. You can autofill the whole array with gaussian weights or random values.
- Access data of the current view setup.
- Time in seconds, unaffected by host_timecale.
1.0 / backbuffersizefor 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.
- Current fog data.
- Scalar to adjust shader luminosity for HDR compatibility.
- The flashlight position. Only valid during the flashlight pass.
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.
- Execute or ignore the contained nodes depending on whether a combo fullfills the given requirements.
- The children of this node will only be executed when the input conditions evalutes to true.
- 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.
- Computes the fog factor.
- 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.
- Allows you to enter custom HLSL into the graph. You can create arbitrary inputs and outputs for the node and handle these inside your custom function. Furthermore it's possible to include headers and create global function/constants which can be referenced from other nodes of this type inside their functions too. Code can either be saved inside the graph file itself or in an external file, which you can include in other graphs.
Utility / Studio model
- Calculates either the per vertex attenuation for each dynamic light or does the whole lighting calculation per vertex.
- Generates the diffuse lighting per pixel.
- 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.
- Performs decompression of normal and tangent data if the geometry that is being used provides a compressed vertex format. A necessity for Swarm model shaders.