Constant Expressions

Expressions where the values of the outputs generally do not change once set in the editor or when play begins.

Choose your operating system:

Windows

macOS

Linux

Expressions where the values of the outputs generally do not change once set in the editor or when play begins.

Constant

The Constant expression outputs a single float value. It is one of the most commonly used expressions and can be connected to any input, regardless of the number of channels the input expects. For instance, if you connect a Constant to an input expecting a 3 Vector, the constant value will be used for all 3 elements. When supplying a single number, it can be useful to collapse the node using the small triangle icon in the description area.

Item

Description

Properties

R

Specifies the float value the expression outputs.

Examples: 0.7, -0.24, 1.1

ConstantExample.png

You can quickly create a Constant node by holding the 1 key and Left Mouse Click in the graph area of the Material Editor.

Constant2Vector

The Constant2Vector expression outputs a two-channel vector value, in other words, two constant numbers.

Item

Description

Properties

R

Specifies the float value of the red (first) channel of the vector the expression outputs.

G

Specifies the float value of the green (second) channel of the vector the expression outputs.

Examples: (0.4, 0.6), (1.05, -0.3)

Example Usage: The Constant2Vector is useful for modifying texture coordinates, as they are two-channel values as well.

Constant2Example.png

You can quickly create a Constant2Vector node by holding the 2 key and Left Mouse Click in the graph area of the Material Editor.

Constant3Vector

The Constant3Vector expression outputs a three-channel vector value, in other words, three constants numbers. An RGB color can be thought of as a Constant3Vector, where each channel is assigned to a color (red, green, blue).

Item

Description

Properties

R

Specifies the float value of the red (first) channel of the vector the expression outputs.

G

Specifies the float value of the green (second) channel of the vector the expression outputs.

B

Specifies the float value of the blue (third) channel of the vector the expression outputs.

Examples: (0.4, 0.6, 0.0), (1.05, -0.3, 0.3)

Constant3Example.png

You can quickly create a Constant3Vector node by holding the 3 key and Left Mouse Click in the graph area of the Material Editor.

Constant4Vector

The Constant4Vector expression outputs a four-channel vector value, in other words, four constants numbers. An RGBA color can be thought of as a Constant4Vector, where each channel is assigned to a color (red, green, blue, alpha).

Item

Description

Properties

R

Specifies the float value of the red (first) channel of the vector the expression outputs.

G

Specifies the float value of the green (second) channel of the vector the expression outputs.

B

Specifies the float value of the blue (third) channel of the vector the expression outputs.

A

Specifies the float value of the alpha (fourth) channel of the vector the expression outputs.

Examples: (0.4, 0.6, 0.0, 1.0), (1.05, -0.3, 0.3, 0.5)

Constant4Example.png

You can quickly create a Constant4Vector node by holding the 4 key and Left Mouse Click in the graph area of the Material Editor.

Distance Cull Fade

The DistanceCullFade expression outputs a scalar value that fades from black to white and can be used to fade an object in once it comes within the cull distance. It should be noted that it does not fade the object out.

DistanceCullFadeExample.png

This network will cause the object to fade in (instead of "popping") once the camera comes within the cull distance.

ParticleColor

The ParticleColor expression ties into the current color of a given particle based on any per-particle color data defined within Cascade . This must be plugged into the appropriate channel (Emissive Color).

Item

Description

Outputs

RGB

Outputs the combined RGB vector data.

R

Outputs the red channel data.

G

Outputs the green channel data.

B

Outputs the blue channel data.

A

Outputs the alpha channel data.

ParticleColorExample.png

In this example, you can see where the ParticleColor expression is providing color to the particles as defined within the particle system.

ParticleDirection

The ParticleDirection expression outputs Vector3 (RGB) data on a per-particle basis, representing the direction a given particle is currently traveling.

ParticleDirectionExample.png

You can see in this image how the color of the particles is changing based on the current direction each particle is traveling.

ParticleMotionBlurFade

The ParticleMotionBlurFade expression outputs a value representing the amount of fade on a particle as a result of motion blur. A value of 1 represents no blur, black represents complete blur.

ParticleMotionBlurFade.png

ParticleRadius

The ParticleRadius expression outputs the radius in Unreal units of each particle individually. This allows, for example, for changes to be made to a material once the radius has reached a certain point.

ParticleRadiusExample.png

In this image, the particles are shifting from green to red as their radius exceeds 7 units.

ParticleRelativeTime

The ParticleRelativeTime expression outputs a number between 0 and 1 representing a particle's age, with 0 being the moment of birth and 1 being the moment of death.

ParticleRelativeTimeExample.png

In this example, you can see the particle relative time fed into the emissive color, resulting in particles that are fading from black at the moment of birth to white as they approach death.

ParticleSize

The Particle Size expression outputs the X and Y size of a particle sprite. This can then be used to drive some aspect of a Material.

ParticleSize.png

Click image for full view.

In the example above, Particle Size is being multiplied into Particle Color. Notice that we are masking the output so that we only use the Green channel, which corresponds to the Y-Axis, or the length of the particles. This means that as the particles stretch out, they become brighter in color. As they shrink, they will become dimmer.

ParticleSpeed

ParticleSpeed outputs the current speed each particle is traveling, measured in Unreal units per second.

ParticleSpeedExample.png

In this example, particle speed is feeding the color of the particles, which is then divided by 10 provide more meaningful results. The particles become black as they slow down.

PerInstanceFadeAmount

The PerInstanceFadeAmount expression outputs a float value associated with the amount of fade applied to an instanced Static Mesh, such as foliage. It is constant, but can be a different number for each individual instance of a mesh.

This only works when applied to an InstancedStaticMesh Actor or other Actor which utilizes InstancedStaticMeshComponents.

PerInstanceRandom

The PerInstanceRandom expression outputs a different random float value per Static Mesh instance to which the material is applied. InstancedStaticMeshComponent sets a random float for instance, which is exposed so that it can be used for whatever is desired (e.g. random light level behind a window). It is constant, but different, for each instance of the mesh.

The output value will be a whole number between 0 and RAND_MAX for the target platform.

PerInstRandomResult.png PerInstanceRandomGraph.png

This only works when applied to an InstancedStaticMesh Actor or other Actor which utilizes InstancedStaticMeshComponents.

Time

The Time node is used to add the passage of time to a material, such as a Panner , Cosine , or other time-dependent operation.

Item

Description

Properties

Ignore Pause

If true , time will continue to march on even if the game is paused.

Period

If true , this will be the amount at which to wrap around time. On Mobile Materials, this will perform the Period computation on the CPU at full-precision, whereas on the GPU it will run at half precision (potentially having issues on periods longer than a minute).

TimeExample.png

The network described in the image above would create a Material that would change over time, constantly exhibiting a sinusoidal transition between white and black. If you enable period, setting period to 0 will effectively stop the transition and 1 will be as if period was false . Setting the number closer to 0 will make the material change at a more rapid pace.

TwoSidedSign

The TwoSidedSign expression is useful for flipping the normal on backfaces of two sided custom lighting materials to match the functionality of Phong. +1 for frontfaces, -1 for backfaces of a twosided material.

exp_twosidedsign.png

VertexColor

The VertexColor expression is the access point for the material to the outputs of color modules affecting sprite particles emitters.

Item

Description

Outputs

RGB

Outputs the three-channel RGB vector value of the color.

R

Outputs the red channel of the color.

G

Outputs the green channel of the color.

B

Outputs the blue channel of the color.

A

Outputs the alpha channel of the color.

VertexColorExample.png

The network above would utilize color and alpha data directly from a Particle System. Such networks are ideal for special effects such as sparks.

View Property

The ViewProperty expression outputs a view dependant constant property such as the field of view or the render target size. The view property to be accessed can be configured, and the type of the output depends on the configured accessed property.

ViewPropertyExample.png

Here is the example with a field of view of 50 degrees.

ViewPropertyExampleFOV50.png

Here is the same example with a field of view of 90 degrees.

ViewPropertyExampleFOV90.png

Precomputed AO Mask

The PrecomputedAOMask node lets you access Lightmass-calculated ambient occlusion (AO) in your Material, which can be useful for procedural texturing or for adding in aging effects and dirt in areas where it would slowly accumulate over time.

Before you can see the results of the Precomputed AO Mask, you will need to build the lighting of the level you are working in using Lightmass.

PrecompitedAOMas_00.png

The above screenshot uses an AO mask to blend a dirt layer automatically into corners of the environment. To use AO masks, you'll need to enable both Use Ambient Occlusion and Generate Ambient Occlusion Material Mask under World Settings -> Lightmass settings , and then build lighting. The other AO controls like Max Occlusion Distance can be useful to tweak the look of the AO. Also make sure to set both Direct and Indirect Occlusion Fraction to 0 , so that this AO will not be applied to the actual level lighting.

PrecompitedAOSettings_00.png

You can access the AO in any Material by using the PrecomputedAOMask Material Expression node. The PrecomputedAOMask works as a 0 to 1 mask with 1 providing areas that are affected by AO and 0 for areas that are not. In the image below you can see how how to set up a Material to make use of the Precomputed AO Mask.

PrecomputedAO_Material_00.png

Help shape the future of Unreal Engine documentation! Tell us how we're doing so we can serve you better.
Take our survey
Dismiss