Shader Graphs

Shader graphs can be used to define the material of particles more precisely allowing you to fine-tune colors and even make materials react dynamically to particle properties like velocity and force influence. Such a shader graph consists of nodes that work together to define the final pixel color and opacity. Each nodes implements a specific function that computes an output value from its input values, which are supplied by other nodes. Some nodes also have additional parameters that influence their function.

One example is the Blend node, which mixes two colors together: The two colors are connected to the input pins of the blend node while the output pin, carrying the resulting color, is connected to other nodes in the graph. The parameter Mode determines how the colors are blended together.

Shader Node Blend

Eventually, all nodes run together into the Output node, which sets the final color of each pixel. Color values are stored in RGBA (Red, Green, Blue, Alpha) format, where each channel contains a number in the range [0, 1] defining the color intensity for that channel. The alpha component defines the opacity.

Shader Node Output

Creating Shader Graphs

The shader graph of a particle type can be modified in the shader graph window. To open this window, click Shader Graph... in the Material property of the particle type.

New Shader Graphs

Each particle type already has a default shader graph, which applies a texture and combines it with the color set in the particle properties. To assign a completely new shader graph to the object click New or select a preset from the drop-down menu.

Adding Nodes

New nodes can be added by right-clicking an empty space and selecting a node type, by dragging out an attribute pin and dropping it on an empty space or by clicking Add in the toolbar. The list of available nodes can be filtered by typing in the search box at the top.

Shader Graph Add

While right-clicking or dragging out a node pin, there are several keyboard shortcuts for creating common node types directly.

2Vector 2
3Vector 3
4Vector 4

Modifying Nodes

After adding a new node, connect its input and output pins to the rest of the graph by dragging out links from each pin. The pin color and shape denote the data type that is expected for the attribute. For example, the red color denotes a 4-component vector, which is used for color values. Most of the time, different data types can be converted into one another.

To remove a node, click Remove in the context menu of the node or select the node(s) and press Remove in the tool bar.

Applying Changes

In order to apply your changes to the particle type, click Apply in the toolbar. Otherwise, they are discarded when you close the window.

List of Available Nodes

Nodes: Constants

BooleanBoolean constant, which can be true or false.
IntegerInteger constant, which can be any positive or negative integer.
NumberNumber constant, which can be any rational number.
Vector 2Vector constant with two components.
Vector 3Vector constant with three components.
Vector 4Vector constant with four components.
ColorColor constant with four components (RGBA).

Nodes: Inputs

Input: Texture CoordinatePer-vertex texture coordinate for the current drawable. Used to sample textures.
Input: ColorColor of the particle. This input can be set with the Color attribute in the Visuals tab.
Input: VelocityVelocity vector of the particle.
Input: ForceForce vector of the particle.
Input: LifeLife left for the particle, from 1.0 (particle has just spawned) to 0.0 (particle is about to disappear).
Input: Object IDID of the current drawable, which can be used to differentiate individual particles, for example.
Effect TimeTime passed since the effect has started.
Object TimeTime passed since the particle emitter was instantiated.

Nodes: Colors

BlendA, BBlends colors A and B together using the specified blending mode.
Color RampValuePicks a color from the specified gradient using Value as an index between 0.0 and 1.0.
Adjust BrightnessColor, BrightnessIncreases the brightness of Color for Brightness > 0 and decreases it for Brightness < 0.
Adjust ExposureColor, ExposureIncreases the exposure of Color for Exposure > 0 and decreases it for Exposure < 0.
Adjust ContrastColor, ContrastIncreases the contrast of Color for Contrast > 0 and decreases it for Contrast < 0.
Adjust SaturationColor, SaturationIncreases the saturation of Color for Saturation > 0 and decreases it for Saturation < 0.
PosterizeColor, NumberReduces the number of available colors per channel to Number.

Nodes: Textures

Texture: ImageUVSamples the given image at texture coordinate UV.
Texture: Sprite SheetUV, FrameSamples the sprite at index Frame in the given sprite sheet at texture coordinate UV.
Tiling and OffsetUV, Tiling, OffsetTransforms texture coordinate UV by tiling it Tiling times and applying Offset.
TwirlUV, AmountTransforms texture coordinate UV by twirling it with strength Amount.

Nodes: Procedural

Circle MaskUV, Radius, SmoothnessGenerates a circular mask, where (0.5, 0.5) is the circle's center, Radius is its radius and Smoothness dictates how slowly the value falls off outside the radius. The circle is then sampled at coordinate UV.
Noise (2D)UV, Amplitude, Frequency, Persistence, LacunarityGenerates 2D Simplex noise with the given parameters. This noise is sampled at coordinate UV.

Nodes: Math

AddA, BAdds A and B (A + B).
SubtractA, BSubtracts B from A (A - B).
MultiplyA, BMultiplies A with B (A * B).
DivideA, BDivides A by B (A / B).
ModuloA, BComputes the modulus of A and B (A mod B).
PowerA, BRaises A to the power of B (AB).
Natural ExponentiationValueComputes the natural exponentiation of Value (exp(Value)).
Natural LogarithmValueComputes the natural logarithm of Value (ln(Value)).
SignValueReturns the sign of Value, i.e. +1 if Value is positive, -1 if Value is negative and 0 if Value is 0.
Absolute ValueValueReturns the absolute value of Value (|Value|).
MinA, BReturns the minimum of A and B (min(A, B)).
MaxA, BReturns the maximum of A and B (max(A, B)).
ClampValue, Min, MaxLimits Value to the range [Min, Max].
Linear InterpolationA, B, FactorInterpolations linearly between A and B using Factor (in the range [0, 1]).
FloorValueRounds Value down to the next integer.
CeilValueRounds Value up to the next integer.
RoundValueRounds Value to the nearest integer.
Square RootValueComputes the square root of Value.
SinValueComputes the sine of Value.
CosValueComputes the cosine of Value.
ArcsinValueComputes the arcus sine of Value.
ArccosValueComputes the arcus cosine of Value.
Dot ProductA, BComputes the dot product of vectors A and B.
Cross ProductA, BComputes the cross product of vectors A and B.
NormalizeVectorNormalizes Vector to a vector of length 1.
Vector LengthVectorReturns the length or magnitude of Vector.
StepValue, EdgeGenerates a step function by comparing Value to Edge. If Value < Edge, the output is 0 and otherwise 1.
Smooth StepValue, Edge 1, Edge 2Performs a smooth interpolation between 0 and 1 when Edge 1 < Value < Edge 2.
ThresholdValueReturns parameter Output if Value is smaller than parameter Threshold.

Nodes: Logic

Negation (NOT)ValueNegates the boolean Value.
Conjunction (AND)A, BOutputs true if and only if both A and B are true.
Disjunction (OR)A, BOutputs true if and only if A or B is true.
Exclusive Disjunction (XOR)A, BOutputs true if and only if either A or B is true.
BranchPredicate, True, FalseOutputs the value for True if Predicate evaluates to true and the value for False otherwise.

Nodes: Comparison

EqualA, BOutputs true if A = B and false otherwise.
Not EqualA, BOutputs true if A ≠ B and false otherwise.
Approximately EqualA, BOutputs true if A ≈ B (depending on given Epsilon) and false otherwise.
LessA, BOutputs true if A < B and false otherwise.
Less or EqualA, BOutputs true if A ≤ B and false otherwise.
GreaterA, BOutputs true if A > B and false otherwise.
Greater or EqualA, BOutputs true if A ≥ B and false otherwise.

Nodes: Utility

Frame AnimationTimeComputes the frame (in a sprite sheet, for example) that has been reached after time Time. The animation is characterized by the given parameters.
Value CurveValueDefines a graph using keyframes and samples this graph at position Value.
Split Vector (2)VectorSplits the two-dimensional vector Vector into its components.
Split Vector (3)VectorSplits the three-dimensional vector Vector into its components.
Split Vector (4)VectorSplits the four-dimensional vector Vector into its components.
Merge Vector (2)X, YCombines X, Y into a two-dimensional vector.
Merge Vector (3)X, Y, ZCombines X, Y, Z into a three-dimensional vector.
Merge Vector (4)X, Y, Z, WCombines X, Y, Z, W into a four-dimensional vector.