Achieving physically accurate iridescence, seen on soap bubbles or oil slicks, requires specialized material setups. This guide explores using Unreal Engine’s Substrate system for quick results and, crucially, how to build a highly controllable custom thin film shader using HLSL code for superior performance and control.
Creating compelling visual effects often hinges on mastering subtle details, and few effects are more mesmerizing than iridescence, also known as the thin film effect. This phenomenon, where color changes based on the viewing angle due to light interference, is crucial for simulating everything from car paint and heat damage to soap bubbles and insect shells.
Expert material designer renderBucket has published a comprehensive tutorial detailing two distinct methods for generating these realistic effects in Unreal Engine 5.6. Whether artists prioritize speed or ultimate control, renderBucket provides a clear path forward.
The Fast Track: Using Unreal Engine Substrate
For those looking for a rapid, efficient solution, Unreal Engine’s experimental Substrate material system offers a streamlined approach. Once enabled in Project Settings, Substrate provides a dedicated thin film node.
This method requires connecting specular color inputs to facing and grazing angles, then setting the crucial parameters: the film’s thickness (measured in micrometers) and the Indices of Refraction (IOR) for both the film and the surrounding medium (like air). To introduce dynamic realism, the presenter demonstrates how to drive thickness variation using a simple noise texture, resulting in natural, shifting color patterns as the camera moves.
Why Go Custom? Unleashing Control with HLSL
While Substrate offers convenience, artists requiring maximum control, performance, or cross-engine portability often turn to custom shader implementation. The heart of this custom thin film material lies in the High-Level Shading Language (HLSL), integrated via a Custom node within a standard Unreal material.
Using HLSL allows the artist to directly manage the complex physics that govern iridescence. A fully physically correct shader needs to calculate constructive and destructive interference based on the optical path length, and it must separately handle S-polarized and P-polarized reflections. This separation results in the highest level of accuracy, though it increases computational complexity.
Building the Performance-Friendly Thin Film Shader
To balance realism and performance, renderBucket outlines a simplified, yet highly effective, HLSL implementation. This custom node requires several key inputs to work, all convertible to parameters for real-time adjustment in Material Instances:
- N Medium & N Film: The IOR of the surrounding medium (e.g., 1.0 for air) and the IOR of the thin film itself (e.g., 1.5).
- Thickness Map: A texture defining the initial thickness variation.
- Thick Min/Max: Defines the minimum and maximum thickness limits for the blend.
- Camera Vector and Normals: Essential directional inputs.
The core of the HLSL code first calculates the Fresnel reflection using the IORs, determining reflection strength based on the view angle. Crucially, the shader approximates the visible wavelengths of light for Red (650 nm), Green (510 nm), and Blue (475 nm) in a float3 vector, often called `lambda`.
The final reflection color is calculated by combining the Fresnel value with a cosine term involving `lambda`, `N film`, the sampled thickness, and the view angle. This expression models the constructive/destructive interference that produces the characteristic rainbow effect, allowing the artist to fine-tune the resulting colors by adjusting the film’s IOR (`N film`) and the thickness range.
Expert Insight: The use of defined RGB wavelengths in the shader, rather than complex spectral rendering, is a common optimization trick in real-time graphics. While slightly less accurate than separating S and P polarization, this simplified approach still delivers stunning, controllable photorealistic results at a fraction of the cost, making it ideal for large-scale production assets like Automotive paint or ArchViz details.
Conclusion
By understanding both the convenient path offered by Substrate and the powerful control granted by custom HLSL, artists can elevate the realism of their materials significantly. The custom shader approach, in particular, grants the flexibility to achieve specific material looks, whether replicating a precise oil slick or creating an otherworldly alien texture. If you are interested in diving deeper into the technical aspects of writing custom shaders, be sure to check out renderBucket’s excellent HLSL Tutorial Series on YouTube.
For more advanced techniques and tutorials focusing on visual quality, explore our category dedicated to Unreal Engine Lighting & Rendering, or learn about similar Materials & Shaders methods.
Source:
How to Make a Realistic Iridescent / Thin Film Material in Unreal Engine 5.6



