Glitter Shader
User Guide
User guide version 00.01 for Glitter Shader for UE5.4, available on Fab (Unreal Engine Marketplace).
Table of Contents
Introduction
Glitter Shader is a stylized emissive shader for Unreal Engine 5.4 and above. The material functions included generate medium to large size glitter procedurally and then use emissive to simulate sparkle and shine.
Click here to get Glitter Shader on Fab (Unreal Engine Marketplace).
Features
-
Material functions included to:
-
Create a glitter material to use as an Overlay Material.
-
Add glitter to an existing material as a material layer.
-
Add glitter to an existing material by merging material attributes.
-
-
Glitter is generated procedurally using Voronoi 3D noise.
-
The shape of each glitter is a dot which can be scaled up to fill the entire Voronoi noise pattern.
-
Generate glitter in Local 3D Space (independent of UVs)
-
Generate glitter in UV Space (for skinned mesh such as characters).
-
Change the size and amount of glitter.
-
Change the brightness and sparkliness of glitter.
Important Notes
-
Mobile platforms are NOT supported due to the use of procedural noise.
-
Use on Landscapes is NOT supported. See the FAQ section for details.
-
This is largely an Emissive effect and does NOT change based on lighting or shadows.
-
Settings must be adjusted manually in the material to match an environment's lighting.
-
Settings must be adjusted through script by adding a Custom Primitive Data parameter to the material and using trigger volumes if it is desired that the glitter get darker when in shadow. See the Tutorials section below for more info.
-
-
Anti-Aliasing method must be TAA or TSR. Other methods, including none, are NOT supported.
-
Known Shading Models that are NOT supported are Hair, SingleLayerWater, Thin Translucent, and Material Expression.
-
The larger the glitter size, the more sparkly! Small size glitter may appear noisy and flickering.
-
It is recommended to use the Convolution Bloom method in Post Process for the most sparkly results.
Contents Included
Required Content
Content/GlitterShader/Shader
This folder contains materials with prefix "M_GlitterExample_" which implement Glitter Shader in each of the different ways possible. The Material Functions Usage section below describes how each material has implemented the required material functions.
Content/GlitterShader/Shader/MaterialFunctions
Within the Shader folder is a folder that contains the material functions required to implement Glitter Shader. The Material Functions Usage section below describes the material functions you will need to use inside materials.
Optional Content
Content/GlitterShader/Demo
This folder contains a level named GlitterDemo which showcases the major features and usage of the Glitter Shader. Each object in the level has a material or material instance assigned as either a Material or an Overlay Material. The master materials used will have comments describing the implementation of Glitter Shader. The Demo Content Breakdown section below describes each area of the level in detail.
Material Functions Usage
The material functions with the prefix "MF_Glitter_" are the nuts and bolts of the shader and are all you need to add glitter to your own materials. There are 3 main material functions that you will need to use.
MF_Glitter_MakeGlitter
Use this to make an Overlay Material or a Decal Material.
The materials M_GlitterExample_OverlayMasked and M_GlitterExample_OverlayTranslucent show how this material function can be used.
MF_Glitter_MakeGlitterLayer
Use this to add glitter as a Material Layer to an existing material. The output Material goes into the input for a MatLayerBlend_Standard node, and Alpha goes into Alpha.
The material M_GlitterExample_Layer shows how this material function can be used.
MF_Glitter_MergeGlitter
Use this to merge glitter with material attributes of an existing material. Existing material attributes go into the left side. Glitterized versions of those attributes come out of the right side.
The material M_GlitterExample_Merge shows how this material function can be used.
There are additional material functions in the Math folder which perform the operations to generate glitter. These are not described here as these should NOT be used individually or modified in any way.
For detailed instructions on how to implement Glitter Shader, see the Tutorials section.
Material Instance Parameters
Once Glitter Shader has been added to a material, create a material instance of that material and apply that to an object. The material instance is where the parameters for the shader will be exposed for the user to modify and customize the look of the glitter. Below is a screenshot of the parameters and definitions of each. All Glitter Shader parameters are in groups G1 through G8.
Glitter Shader Parameters
G1. Glitter Generation
-
Gen using UV space?
-
Default: False. Glitter is generated in Local 3D Space and is independent of UVs. Glitter will move with the object, but not deform with skinned mesh.
-
If True, glitter is generated in UV Space. It will be dependent on the object’s UVs. The glitter will move with animated skinned mesh as if it is a texture.
-
-
Density (3D): How densely packed the glitter is (or how dense the Voronoi noise pattern is). More dense means glitter is closer together, and less dense means farther apart.
-
Density (UV Tiling): If “Gen using UV space?” is True, then Density will be how much to tile the glitter based on UVs.
-
Size (Fill Cell): The size of each piece of glitter. Glitter is masked out within each Voronoi noise pattern cell as a dot. Size determines the size of that dot within the cell. If the dot is large enough, it will be the shape of the Voronoi cell, an irregular shape.
G2. Glitter Scale
These parameters will differ based on whether “Gen using UV space?” is True or False.
-
Scale Along Object’s X: Scale the glitter along the local X axis of the object.
-
Scale Along Object’s Y: Scale the glitter along the local Y axis of the object.
-
Scale Along Object’s Z: Scale the glitter along the local Z axis of the object.
-
Scale Along U: Scale the glitter along the UV’s U if using UV space.
-
Scale Along V: Scale the glitter along the UV’s V if using UV space.
G3. Glitter Color
These parameters will differ based on whether “Use MultiColor?” is True or False.
-
Use MultiColor?
-
Default: False: Glitter is only one color.
-
If True, glitter is a range of 3 colors, chosen as a lerp between all 3.
-
-
Color: Color of the glitter if not using MultiColor.
-
RandomColor1: First color in the ramp to randomly choose from.
-
RandomColor2: Second color in the ramp to randomly choose from.
-
RandomColor3: Third color in the ramp to randomly choose from.
G4. Glitter Metallic/Roughness
Metallic and Roughness of each Voronoi cell before each is masked out as glitter and Emissive Effects are applied. This really only applies if “Use Opacity?” below is False.
-
Glitter Metallic: Metalness of each Voronoi cell before any effects applied.
-
Glitter Roughness: Roughness of each Voronoi cell before effects applied.
G5a. Glitter Emissive
The majority of the Glitter Shader effects happen in this section. Since Unreal Engine does not expose lighting information in materials, calculations are made manually and then applied as Emissive using the parameters below.
-
Use Emissive Effects (Simulated Reflections)?
-
Default: True. This should almost always be True. This will add sparkliness as Emissive based on a combination of the “sunlight” in the scene and 2 additional fake camera lights.
-
If False, no Emissive is used. This should not be used unless there is a need to save on rendering instructions and “Use Opacity?” is False, in which case the material is basically rendering as a reflective material with fragmented normals.
-
-
Emissive Effects: Scattering: How different each piece of glitter’s reflection is from the surface it’s on. 0 matches geometry. 1 is completely random.
-
Emissive Effects: Sparkle Gradient Frequency: A sine wave is passed through each piece of glitter affecting brightness based on distance, location, and camera angle. This adds addtional sparkle when you move torwards the object and when the object moves. Increasing the frequency means it sparkles more, although values too high will make the pattern noticeable and distracting.
-
Emissive Effects: Sparkle Gradient Brightness: The sine wave’s effect on brightness is multiplied by this value.
-
Emissive Effects: Ambient Color: This is an ambient color that is added to the final result of all Emissive Effects, i.e., this color is the darkest each glitter can get.
G5b. Glitter Emissive: Additional Sun Light Reflection
These settings simulate additional reflectivity from the “sun light” in the scene, i.e., the Directional Light in the scene that has “Atmosphere Sun Light” checked, if any. If one does not exist or if the light is turned off, the coordinate (0, 0, 1) is used as the direction to this light for calculations.
-
Simulate Additional Sun Light Reflection?
-
Default: True. Wherever the sun is reflecting on the object, addtional sparkliness is added.
-
If False, no additional sparkle is added. Set this to False if there is no Directional Light in the scene flagged as “Atmosphere Sun Light” or if that light is turned off.
-
-
Simulated Sun Reflection: Color: The color of the additional sparkles.
-
Simulated Sun Reflection: Emissive: The brightness of the additional sparkles.
-
Simulated Sun Reflection: Spread: How far out the additional sparkles can be from the point of reflection on the object.
G5c. Glitter Emissive: Simulate Additional Light 1
Imagine if a light were attached to the camera. The glitter would reflect light from this light source. By specifying an imaginary light source attached to the camera, the glitter always reflects something and sparkles to some degree. By default, this imaginery light is to the left of the camera, simulating a pink bounce light on the object.
-
Simulate Additional Light 1?: Whether to simulate this light source and add it to Emissive.
-
Simulated Light 1: X: The relative horizontal offset from the camera (in view space).
-
Simulated Light 1: Y: The relative vertical offset from the camera (in view space).
-
Simulated Light 1: Z: The relative forward offset from the camera (in view space).
-
Simulated Light 1: Reflection Color: The color of the additional sparkles.
-
Simulated Light 1: Reflection Emissive: The brightness of the additional sparkles.
-
Simulated Light 1: Reflection Spread: How far out the additional sparkles can be from the point of reflection on the object.
G5d. Glitter Emissive: Simulate Additional Light 2
Similar to Simulate Additional Light 1. By default, this imaginery light is to the right of the camera, simulating a blue bounce light on the object.
-
Simulate Additional Light 2?: Whether to simulate this light source and add it to Emissive.
-
Simulated Light 2: X: The relative horizontal offset from the camera (in view space).
-
Simulated Light 2: Y: The relative vertical offset from the camera (in view space).
-
Simulated Light 2: Z: The relative forward offset from the camera (in view space).
-
Simulated Light 2: Reflection Color: The color of the additional sparkles.
-
Simulated Light 2: Reflection Emissive: The brightness of the additional sparkles.
-
Simulated Light 2: Reflection Spread: How far out the additional sparkles can be from the point of reflection on the object.
G6. Glitter Opacity
-
Use Opacity?
-
Default: True. Mask out each piece of glitter in the shape of a dot.
-
If False, the entire Voronoi noise pattern is used and none of the original object’s material is visible. This will give the effect of a shiny, reflective object faceted in the shape of the Voronoi noise.
-
-
Use Emissive as Alpha?
-
Default: False. All pieces of glitter are always visible whether they are reflecting light or not.
-
If True, each piece of glitter will only be visible when it is reflecting light. This can create the appearance that the glitter is part of the object rather than on top of the object.
-
The first image (Quinn) shows "Use Emissive as Alpha?" set to True. Only glitter that is bright is visible.
The second image (drapery) shows "Use Emissive as Alpha?" set to False. All pieces of glitter are visible regardless of brightness.
G7. Glitter Normal
This is for the Normals of the Voronoi noise pattern before any effects are applied to it. This mainly applies to if “Use Opacity?” is False, where the entirety of the Voronoi pattern is visible without any Emissive Effects.
-
Scattering: How different each Voronoi cell’s normal direction is from the object’s surface. 0 matches the geo. 1 is completely random.
G8. World Position Offset
This only applies if the material is used as an Overlay Material. If this is the case, the material’s World Position Offset must be greater than 0 so that the glitter sits above the surface of the object.
-
Offset from Surface: The amount the glitter renders above the surface of the object.
Demo Content Breakdown
Demo content is provided to show examples and features of the shader. Below are the contents of the Demo folder.
Content/GlitterShader/Demo
GlitterDemo: This level provides an overview of Glitter Shader features and usage. It is divided into the sections shown below.
Content/GlitterShader/Demo/Blueprints
-
BP_AnimateLetters: Blueprint for animating letters.
-
BP_CubeSpinner: Blueprint for spinning a cube and switching it to random glitter colors.
-
BP_DiscoBall: Blueprint that spins the disco ball in the level.
-
BP_PostProcessButton: Button in the level that toggles between Bloom settings (Standard and Convolution).
-
BP_ShadowVolume: Blueprint that triggers Quinn’s blueprint to dim the glitter effect when in shadow and brighten it when not in shadow.
-
BP_ThirdPersonCharacterDemo: Modified blueprint for the Quinn player character for this level.
-
BP_WallText: Blueprint for displaying a title and paragraph of text.
Content/GlitterShader/Demo/Characters
These are the Unreal default mannequin characters with modifications made to their materials.
Content/GlitterShader/Demo/Environment
These are the Unreal default environment meshes and materials, such as the cube and cylinder, with modifications made to their materials.
Content/GlitterShader/Demo/GLITTER_EXAMPLES
The Master Materials at the top level of this folder shown here are the ones used in this demo level. Each one will have Comments explaining its implementation of Glitter Shader.
Within each subfolder are the Material Instances that are used in each section of the demo level. These can be referenced to see how material parameters can be set to achieve different visuals.
Content/GlitterShader/Demo/Input
Input Actions and Input Mappings for the control of Quinn in this level.
Content/GlitterShader/Demo/Props
The letters, dress, skirt, and drapery models, textures, and materials used in this demo level.
Nanite
Nanite objects are supported, including with displacement if that is enabled. However, please note the following.
-
Landscape, including Nanite Landscape, are NOT supported. See the FAQ section for more information.
-
Nanite objects in general DO NOT support Overlay Materials.
-
Nanite tessellation is only available in UE5.3 and above. It does NOT appear to be officially released and can only be enabled through console commands or by editing the project’s DefaultEngine.ini.
-
To add Glitter Shader to a Nanite material, use the merge method, as shown below.
Below is an basic example of how Glitter Shader has been added to a material for a Nanite mesh. The material has been simplified to focus on the usage of Glitter Shader. This example uses Quixel’s Decorative Statuettes Pack (not included, but a link is provided below).
Quixel’s Decorative Statuettes Pack (not included)
https://www.fab.com/listings/e581059c-6146-4d34-83b2-e963d41dc6f0
Below is the material instance that was created from the material above. Circled are the Glitter Shader parameters that where changed from their defaults.
Below are the results. Notice that glitter is calculated before displacement, so it will get stretched along with the displacement when rendering.
FAQ
Q: The following error occurs: "[SM6] Function MF_Glitter_MergeGlitter: (Node TransformPosition) This transformation is only supported in the 'Surface' material domain."
A: This occurs when the Material Domain is set to Deferred Decal and the material function MF_Glitter_MakeGlitter or MF_Glitter_MergeGlitter is used. Decal materials DO NOT support generating noise in local space, so it has to be done in world space. Create a Static Bool node, set it to True, and plug it into the MF_Glitter_MakeGlitter or MF_Glitter_MergeGlitter input "Is Decal?"
Q: Are mobile devices supported?
A: No. This shader requires generating procedural noise which is NOT supported on mobile devices.
Q: Why is use with Deferred Decal experimental?
A: Decals materials are NOT currently supported. Due to decals being a texture and not having normal information, the shader cannot scatter the underlying geometry’s normals. Rather the light reflection is scattered into 4 bright spots, and reflections may not show up at all at some angles.
Q: Are landscape materials supported?
A: No. This is for several reasons.
-
Landscapes do NOT support Overlay Materials.
-
Similar to Deferred Decals, the normals cannot be scattered as expected. Scattering causes 4 reflections of the light source. Simulated reflections are sometimes not present at all.
-
When a glitter material is applied as its own Landscape Layer, glitter cannot be masked out ask dots.
Q: Why does an Overlay Material not cover all materials on some objects?
A: It is unclear why this happens. We noticed that this occurs on characters with more than 16 materials, so perhaps there is a max limit.
Q: Sometimes a build will not have bright convolution bloom.
A: This seems new to UE5.5. Convolution does not always update when in a new window. Try pressing Alt+Enter to toggle between full screen and windowed mode to see if that fixes it.
Q: How expensive is this shader to render?
A: This shader is moderately expensive. The shader alone with default settings is 519 instructions. Shader Complexity will differ based on usage. Below is a screenshot of the Shader Complexity view of the demo.
-
Glitter Shader as an Overlay Material on top of a simple material is not complex.
-
Glitter Shader as an Overlay Material on top of Quinn’s Clear Coat material is very complex.
-
Glitter Shader merged or layered with a material is moderately complex.
-
Glitter Shader merged or layered with a material PLUS another Glitter Shader material on top of that as an Overlay Material on top of a Clear Coat material is extremetly complex, as shown with the Quinn model to the far right.