# Free (MIT): real-time diffraction grating / holographic foil material for UE 5.9 Substrate, validated against Cycles 

**URL:** <https://forums.unrealengine.com/t/free-mit-real-time-diffraction-grating-holographic-foil-material-for-ue-5-9-substrate-validated-against-cycles/2860944>\
**Category:** Rendering\
**Tags:** unreal-engine, Substrate, Lumen\
**Created:** [November 23, 2026, 3:23pm UTC](https://forums.unrealengine.com/t/free-mit-real-time-diffraction-grating-holographic-foil-material-for-ue-5-9-substrate-validated-against-cycles/2860944 "2026-11-23T15:23:54Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![zyyyyyc](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@zyyyyyc](https://forums.unrealengine.com/u/zyyyyyc)\
**Post date:** [November 23, 2026, 3:23pm UTC](https://forums.unrealengine.com/t/free-mit-real-time-diffraction-grating-holographic-foil-material-for-ue-5-9-substrate-validated-against-cycles/2860944/1 "2026-11-23T15:23:54Z")

</div>

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.

 ![Blender Cycles reference vs the Unreal versions](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/8/d/78dc841581346f60a9f8b8582d7dfc34404e62cf.png)

> **[GitHub - yichenzhu56/DiffractionGrating-UE: Real-time diffraction grating (holographic foil)...](https://github.com/yichenzhu56/DiffractionGrating-UE)**
>
> Real-time diffraction grating (holographic foil) material for Unreal Engine 5 Substrate

**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.

 ![How the 30 lobes fit into 4 Substrate slabs](https://d3kjluh73b9h9o.cloudfront.net/original/4X/1/a/a/1aae3ab9ce9bd939bd5df8baac723f5d39e0aa94.png)

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.

 ![Validation against Cycles](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/a/e/7ae1a85e8045fdeeb28dcd2316d07f2e9e06737b.png)

**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_UV` and `MI_Hybrid_Pouch_Triplanar` render without their `ColorFilter` texture; `MI_Hybrid_Pouch_Axis` shows 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.
