Tutorials – UE3 Material Expressions
About : A list of all available and useful material expressions and a short explanation on what each of them does.
Target Audience : Unreal Engine users – Beginners and Intermediate
Platform : Unreal Engine 3.
Latest Update : November 2010
The Expressions
# Color
- Desaturation – Used Often
As the name implies, this expression can desaturate its input. - DestColor
Takes over the color of what is behind this material. Must be used on translucent materials. For example: if the environment behind a window is red, the window will take over that red color.
# Constants
- Constant (Constant1Vector) – Used Often
This is the most commonly used expression. Constant is a single number. - Constant2Vector – Used Often
Identical to a regular Constant, only this one features a Red and Green channel. A Constant2Vector can create red, yellow, and green, but no blue. - Constant3Vector – Used Often
This expression features all three color channels and is thus capable of generating any color available. - Constant4Vector
A Constant3Vector plus a 4th value: Alpha - MeshEmitterVertexColor
For materials that are used on meshes spawned by particles. Allows the particle editor to modify things like the color of the mesh through the curve editor. - TwosidedSign
To improve two sided lighting on materials that use a custom lighting setup. This expression is used very rarily – highly specific use. - VertexColor – Used Often
Allows you access to any vertexcolors that may be available on a mesh. This will not do anything if the mesh has no VTX colors defined.
# Coordinates
- CameraWorldPosition
Moves the image dependent on the position and rotation of the camera. Good to fake reflections with and other effects that are dependent on the camera angle. - CameraVector
Similar to CameraWorldPosition. - FoliageImpulseDirection
Used for Interactive Foliage meshes. Hooks into the gameplay and will apply an impulse when a player or object touches the actor the material is assigned to. This expression is used very rarily – highly specific use. - FoliageNormalizedRotationAxisAngAngle
Used for Interactive Foliage meshes. Controls the rotation and angle of the impulse applied by FoliageImpulseDirection. This expression is used very rarily – highly specific use. - LightMapUVs
Allows access to the lightmap coordinates that were generated by the engine for the mesh the material is assigned to. - ObjectOrientation
The orientation of the object the material is assigned to. Uses Object Space. - ObjectRadius
The size of the object the material is assigned to. If the object is large, it will input a large number into the material that uses this expression. - ObjectWorldPosition
The position of the object the material is assigned to. Very useful to alter an object or its material dependent on its location in the world. The higher it is in the world, the blue’er the color for example. Uses Object Space. - Panner – Used Often
Simply continuously pans something. - Rotator – Used Often
Rotates something. - ScreenPosition
Takes over the angle of the camera. - TextureCoordinate – Used Often
Controls the scale of a texture, and what UV Channel/Set it uses. - WindDirectionalAndSpeed
Controls the scale of a texture, and what UV Channel/Set it uses. - WorldNormal
Similar to ObjectOrientation but using the World Space. - WorldPosition
Similar to ObjectWorldPosition but using the World Space.
# Custom
- Custom
Allows you to write custom HLSL shader code. This expression is used very rarily – highly specific use. - CustomTexture
To be used together with Custom. Allows you to refer to a texture inside Custom. This expression is used very rarily – highly specific use.
# Depth
- DepthBiasedAlpha – Used Often
Fades out the material when it intersects with geometry. Used for Soft Particles, water, smoke, and so on. - DestDepth
Distance between te camera and a certain point. The further away something is, the greater the value that is send to the material. Can be used to fake distance fog and such. Must be used on Translucent or Additive surfaces. - PixelDepth – Used Often
Similar to DestDepth. Ideal for anything that has to alter over a certain range. For example fading in a detail texture as you come close to a wall. Fading out smoke as you move through it. And so on. - SceneDepth
Similar to DestDepth, although SceneDepth is a little more powerful. Calculates the distance between the camera and any pixel currently in view.
# Destination
- DestColor
Takes over the color of what is behind this material. Must be used on translucent materials. For example: if the environment behind a window is red, the window will take over that red color. - DestDepth
Distance between te camera and a certain point. The further away something is, the greater the value that is send to the material. Can be used to fake distance fog and such. Must be used on Translucent or Additive surfaces.
# Font
- FontSample
Allows you to use a font as a texture in a material. This expression is used very rarily – highly specific use. - FontSampleParameter
Like FontSample, but as Parameter instead.
# HighLevel
- AntialiasedTextureMask
Blends two textures together with improved quality. - Distance
Outputs the distance between two pre-defined points. For example the camera and an object. The further away the object goes from the camera, the higher the value that Distance outputs. That value can then in turn be used to alter for example the color of the object. This expression is used very rarily – highly specific use. - SphereMask
Calculates the distance between two pre-defined points and compares its to the radius of itself. If the value is outside its radius it will return the value 0, if it is within its radius it will return 1. Similar to Distance, but with more control of the drop-off range. Possible use would be to quite suddenly change the color of an aircraft as soon as it leaves a certain region. This expression is used very rarily – highly specific use.
# Layer Coords
- TerrainLayerCoords
Part of the new Terrain system. Controls planar mapping orientation and scale of the material on the terrain.
# Layer Weight
- TerrainLayerWeight
Part of the new Terrain system.
# LensFlare
- LensFlareIntensity
Used for LensFlare materials. This expression is used very rarily – highly specific use. - LensFlareRadiaDistance
Used for LensFlare materials. This expression is used very rarily – highly specific use. - LensFlareRayDistance
Used for LensFlare materials. This expression is used very rarily – highly specific use. - LensFlareSourceDistance
Used for LensFlare materials. This expression is used very rarily – highly specific use. - OcclusionPercentage
Used for LensFlare materials. This expression is used very rarily – highly specific use.
# Math
- Abs
Inverts only the negative values. Positive values are not affected. -1 will become 1, but all other numbers higher than 0 will remain untouched. Handy to force values to always be higher than zero. This expression is used very rarily – highly specific use. - Add – Used Often
Adds two inputs together. - Ceil
Ceil rounds off values. 0.6 and 1.4 become 1.0; 4.7 becomes 5, and so on. This expression has limited use but can be of great use for flickering lights, for example. Where as the regular Time-Sine setup creates soft fading flashes, adding a Ceil to the setup will remove the fading and make it harsher. - Cosine
Animates a value, it continuously alternates between two values. To be used together with Time in particularly. - Crossproduct
Blends two inputs together in a specific way. This expression is used very rarily – highly specific use. - Divide
A simple mathematical operation. A value is divided by another value, what remains forms the new color. - DotProduct
Creates a gradient. If a CameraVector and a ReflectionVector are used as input it creates a gradient dot. Can be used to fake phong highlights, among other things. - Floor
Very similar to Ceil with the difference that Floor only rounds off values downwards. Where as Ceil rounds off values like 1.7 to 2.0; Floor will round 1.7 into 1.0. - Frac
Transforms all values into something less than 1.0; example: 4.6 becomes 0.6; 1.0 becomes 0.0; 0.4 remains unchanged. - LinearInterpolate – LERP – Used Often
It blends two different inputs on top of each other by using a third input (usually an alpha map). Similar to two layers and a MaskMap in Photoshop. - Multiply – Used Often
Will multiply any value by any other value. - Normalize
Helps to bring a value to another scale. Wikipedia explains this pretty well “If the intensity range of the image is 50 to 180 and the desired range is 0 to 255 the process entails subtracting 50 from each of pixel intensity, making the range 0 to 130. Then each pixel intensity is multiplied by 255/130, making the range 0 to 255.“ - OneMinus – 1-X
This simply inverts the input. Black becomes white, yellow becomes blue, and so on. - Power – Used Often
Controls brightness/contrast. Good to alter a washed out texture or to derive specularity of a diffuse texture. - RotateAboutAxis
Rotates something around an axis. - Sine
Very similar to Cosine. - SquareRoot
Simple mathematical expression that alters entered values through a square root. - Subtract
Another simple mathematical expression. Subtracts a value of another, usually resulting into a darker material but it can also be used to filter out a given color in an image.
# Parameters
- AntialiasedTextureMask
Blends two textures together with improved quality. - FontSampleParameter
Like FontSample, but as Parameter instead. - ScalarParameter – Used Often
Basically a Constant, but as an parameter instead. A single value, that can be accessed through a material instance. - StaticComponentMaskParameter
Like a regular ComponentMask, but as parameter. This parameter is static, it cannot be set during gameplay. - StaticSwitchParameter
Kind of like a bool. If true, it uses input B. If set to false it uses input A. Static, cannot be modified during gameplay. - TextureSampleParameter2D – Used Often
Allows the texture/bitmap to be accessed and modified via a material instanced. - TextureSampleParameterCube/Movie/Normal/SubUV/And so on
Identical to TextureSampleParameter2D but instead for all kinds of content. - VectorParameter – Used Often
Much like ScalarParameter, but VectorParameter features 4 values instead. Basically a Constant4Vector.
# Particles
- MeshEmitterVertexColor
For materials that are used on meshes spawned by particles. Allows the particle editor to modify things like the color of the mesh through the curve editor. - MeshSubUV
Similar to ParticleSubUV but for meshparticles. - MeshSubUVBlend
Similar to MeshSubUV but with blending. - ParticleMacroUV
Macro textures on particles are projected over all the particles within that system, the ParticleMacroUV expression allows a material to be set up for this. This is useful to fight tiling in a particle system by ensuring that every particle looks different. - ParticleSubUV
Creates a flipbook. Allows a particle to divide up a texture into X parts, and play through that series of images, essentially creating an animation. Most explosions and such are done this way. - VertexColor – Used Often
Allows a particle to be modified through the curve editor, which allows Cascade to modify the color and opacity of the material a particle uses.
# Terrain
- TerrainLayerCoords
Part of the new Terrain system. Controls planar mapping orientation and scale of the material on the terrain. - TerrainLayerWeight
Part of the new Terrain system.
# Texture
- FlipBookSample
A FlipBookSample expression allows a single texture to be subdivided into multiple frames, and to play those frame creating an animation. - FluidNormal
To be used on a FluidSurfaceActor. Allows access to the normal map that is generated by the FluidSurfaceActor, in order to blend the generated normal map with a pre-existing normal map for example. - FontSample
Allows you to use a font as a texture in a material. This expression is used very rarily – highly specific use. - MeshSubUV
Similar to ParticleSubUV but for meshparticles. - MeshSubUVBlend
Similar to MeshSubUV but with blending. - ParticleSubUV
Creates a flipbook. Allows a particle to divide up a texture into X parts, and play through that series of images, essentially creating an animation. Most explosions and such are done this way. - SceneTexture
This is everything currently being rendered by the viewport. It is basically whatever you are seeing. This is used in Post Process materials where you take the current image on your screen (SceneTexture) and modify it, by for example distorting it. By applying that material in a Post Process Chain the entire screen will receive whatever modification you did on SceneTexture. - TextureSampleParameter2D – Used Often
Allows the texture/bitmap to be accessed and modified via a material instanced. - TextureSampleParameterCube/Movie/Normal/SubUV/And so on
Identical to TextureSampleParameter2D but instead for all kinds of content.
# Utility
- AppendVector
Reassembles individual color channels. All images are made up of three layers. Red, Green and Blue. AppendVector allows you to merge previously separated layers back into a single image. This is especially handy when you need to modify each layer individually and then want to merge all of it back into a single image. Another example: AppendVector can turn two separate Constant(1Vector) expressions into something that behaves as a single Constant2Vector. - BumpOffset – Used Often
Offsets pixels to emulate a parallax effect, where one part of an image seems to be in front of the rest. BumpOffset uses a grayscale Height input, the whiter the pixel, the higher it will be raised. This is purely a camera effect, the expression will not truly deform geometry. This can also be used to emulate reflection. - Clamp
Allows you to limit the input to a Max and Min value. If the Max is 1 and the Min 0, then all values that come in via the input that are greater or smaller than either 0 or 1, will be clamped to 0 or 1. Values in between Max and Min are not modified. - ComponentMask
This is the opposite of AppendVector. Where as AppendVector allows you to merge different color channels into a single image, ComponentMask allows you to filter out color channels you don’t want. If a yellow texture is entered into a ComponentMask, and it is set to only allow through Red and Blue, the texture will become red as yellow is made by mixing Green and Red, and if there is no more Green, only Red is left. - ConstantBiasScale
Adds a value to the input (Bias), and multiplies that input (Scale). - ConstantClamp – Used Often
Similar to Clamp, but easier to use. Where as Clamp requires Constants for Max and Min, ConstantClamp does not. - Desaturation – Used Often
As the name implies, this expression can desaturate its input. - If
Simple mathematical function, although it may be hard for some to imagine exactly how it can benefit a material. Its use is restricted to complex materials where certain effects are only allowed to be displayed once they conform to certain requirements. If the input is greater than X, display texture A. If the input is equal to, display texture B. If the input is smaller than, display texture C. And so on. - LightmassReplace
Used to fixed certain problems related to Lightmass lighting calculations. This expression is used very rarily – highly specific use. - LinearInterpolate – LERP – Used Often
It blends two different inputs on top of each other by using a third input (usually an alpha map). Similar to two layers and a MaskMap in Photoshop. - PerInstanceRandom
This outputs a different value for every object the material is applied to. This value can then be used to color each instance of the object differently for example. It basically allows the material to be different on every object it is used. - Time – Used Often
The time, often used together with Sine or Cosine. A simple expression that can be of great use for things that only have to occur every now and then. Think of lightning, animations that need to be inverted after a while, and so on.
# VectorOps
- AppendVector
Reassembles individual color channels. All images are made up of three layers. Red, Green and Blue. AppendVector allows you to merge previously separated layers back into a single image. This is especially handy when you need to modify each layer individually and then want to merge all of it back into a single image. Another example: AppendVector can turn two separate Constant(1Vector) expressions into something that behaves as a single Constant2Vector. - Crossproduct
Blends two inputs together in a specific way. This expression is used very rarily – highly specific use. - DeriveNormalZ
Derives the Z value of the X and Y values of a Normal Map. This essentially allows you to use 2 channel normal maps, and then generate the third channel on the fly in the engine by comparing the X and Y channel, saving valuable memory. - DotProduct
Creates a gradient. If a CameraVector and a ReflectionVector are used as input it creates a gradient dot. Can be used to fake phong highlights, among other things. - Fresnel – Used Often
Creates rim lighting. Highlights the edges of whatever object it is assigned to, or if you wish, highlights the inner areas. - Normalize
Helps to bring a value to another scale. Wikipedia explains this pretty well “If the intensity range of the image is 50 to 180 and the desired range is 0 to 255 the process entails subtracting 50 from each of pixel intensity, making the range 0 to 130. Then each pixel intensity is multiplied by 255/130, making the range 0 to 255.“ - Transform
Allows values to be converted to and from tangent space, world-space, local-space, view-space coordinate systems. - TransformPosition
Old. Do not use.
# Vectors
- CameraWorldPosition
Moves the image dependent on the position and rotation of the camera. Good to fake reflections with and other effects that are dependent on the camera angle. - CameraVector
Similar to CameraWorldPosition. - Constant (Constant1Vector) – Used Often
This is the most commonly used expression. Constant is a single number. - Constant2Vector – Used Often
Identical to a regular Constant, only this one features a Red and Green channel. A Constant2Vector can create red, yellow, and green, but no blue. - Constant3Vector – Used Often
This expression features all three color channels and is thus capable of generating any color available. - Constant4Vector
A Constant3Vector plus a 4th value: Alpha - FoliageImpulseDirection
Used for Interactive Foliage meshes. Hooks into the gameplay and will apply an impulse when a player or object touches the actor the material is assigned to. This expression is used very rarily – highly specific use. - FoliageNormalizedRotationAxisAngAngle
Used for Interactive Foliage meshes. Controls the rotation and angle of the impulse applied by FoliageImpulseDirection. This expression is used very rarily – highly specific use. - LightVector
Takes the angle of nearby lights. Highly specific in use. - ObjectOrientation
The orientation of the object the material is assigned to. Uses Object Space. - ObjectRadius
The size of the object the material is assigned to. If the object is large, it will input a large number into the material that uses this expression. - ObjectWorldPosition
The position of the object the material is assigned to. Very useful to alter an object or its material dependent on its location in the world. The higher it is in the world, the blue’er the color for example. Uses Object Space. - ReflectionVector
Similar to CameraVector, only difference is that ReflectionVector operates on a different axis. - WorldNormal
Allows access to the Wind speed and direction present in the level. - WorldNormal
Similar to ObjectOrientation but using the World Space.