Hi everyone,
I ported Blender Guru’s “Balanced” diffraction grating shader (the holographic foil look) to Unreal Engine 5.9 with Substrate, checked it against Blender Cycles pixel by pixel, and released it for free under the MIT license.
What’s in the repo
M_DiffractionHybrid(recommended), plus a 4-slab-only version and an unlit reference version- A demo level: pouch, card and sphere, a probe Sky Light and a point light
- The HLSL and the editor Python scripts that build the assets, and the Blender scripts I used for validation
How it works
The grating is modelled as 30 tilted anisotropic specular lobes: 6 diffraction orders × 5 wavelengths. Substrate shades at most 4 closures per pixel, so the hybrid material splits the work:
- Environment: all 30 lobes are evaluated inside the material against the Sky Light cubemap (5 taps per lobe) and output as emissive.
- Direct lights: 4 Substrate slabs (orders ±1 × 2 colour groups) take point / spot / directional lights, with shadows.
- No double counting: material AO = 0 and a Lumen Max Roughness To Trace of 0.2 (below the slab roughness of 0.21) keep the engine from adding its own sky reflections on top of the slabs.
- Path tracer: a separate branch. On every sample, each of the 4 slabs picks one of the 30 lobes (stratified, weighted by lobe energy), so it converges to the full model.
The groove direction can come from UVs, an object-axis projection or triplanar, so it also works on meshes without clean UVs. The fine ribbed bump of the foil is filtered analytically to reduce shimmer when the camera moves.
Results vs Cycles (lit only by the same HDR probe, the 3 Blender cameras): per-pixel relative error 0.15–0.20, brightness 96–100%, colourfulness 97–100%, frame-to-frame noise 0.03% with Lumen on.
Requirements
- UE 5.9 (the assets were saved with 5.9), Windows, DX12, SM6
- Substrate with the Adaptive GBuffer and 4 closures per pixel (already set in the project config)
- A Sky Light in the level. If Lumen reflections are on, a Post Process Volume with Max Roughness To Trace = 0.2 (the demo level has one).
- Hardware ray tracing, only for the path tracer branch
Known issues
MI_Hybrid_Pouch_UVandMI_Hybrid_Pouch_Triplanarrender without theirColorFiltertexture;MI_Hybrid_Pouch_Axisshows it. I haven’t found the cause yet.- The path tracer output has not been compared with Cycles numerically yet.
- I haven’t profiled it. The environment part takes about 150 cubemap samples per pixel (30 lobes × 5), so it is not cheap.
Feedback welcome, especially on:
- A cleaner way to stop sky / Lumen reflections from double counting on Substrate slabs than AO = 0 plus the roughness cut-off.
- Why a texture parameter might not apply in two instances of the same parent material.
- Performance numbers on your hardware.
Credits: the shading model, pouch scene and reference renders are by Blender Guru (Andrew Price); the original OSL diffraction shader is by Secrops. Details are in NOTICE.md in the repo.


