microsoft / microsoft/MixedReality-GraphicsTools-Unity
Add programmatic iridescence support
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 209
- Forks
- 49
- PR merge metrics
- No merged PRs in 30d
Description
Describe the problem
Banding is present in our texture based iridescence feature:

Switching to programmatic iridescence gradient look ups would alleviate this issue.
Describe the solution you'd like
Add a new gradient mode to this list which is maybe called "Iridescence Procedural"?

Implemented like so from @maluoi -
The sharp edges on the gradient were kinda bothering me, and I finally realized smoothstep was the answer! 😄
Anyhow, I thought I'd share the HLSL shader code I use for the iridescence gradient in StereoKit, in case it's helpful.
Another note here, using an array of float3s for the gradient color is how I'm avoiding banding, that's the ir_gradient variable here.
static const int ir_gradient_count = 5; static const float3 ir_gradient[] = { float3(0,0,0), float3(0,0,0), float3(0.065,0.018,0.429), float3(0,0,0), float3(0.013, 0.117, 0.597), float3(0,0,0) }; float3 GetIridescence(uint view_id, float3 world_pos, float3 surface_normal) { float3 dir = normalize(sk_camera_pos[view_id].xyz - world_pos); float ir = saturate(dot(dir, surface_normal)); float pct = ir * ir_gradient_count; int g = pct; pct = smoothstep(0, 1, frac(pct)); float3 curr = ir_gradient[g]; float3 next = ir_gradient[g+1]; return lerp(curr, next, pct); }
Describe alternatives you've considered
Live with the banding or use HDR textures for iridescence.
Additional context
Related to: https://github.com/microsoft/MixedReality-GraphicsTools-Unity/issues/22
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the existing texture-based iridescence implementation and the gradient-mode list in the Unity graphics tools. Compare the supplied HLSL approach with the current shader path, then verify that a procedural iridescence mode reduces banding without requiring an HDR texture.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, unity
- Domain
- computer-graphics, game-dev
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100
