GelamiSalami Profile picture
Shaders and nodes | Graphics enthusiast | Resident salami dog | #blender #nodegolf

Apr 16, 2021, 7 tweets

Here's how you can do physically-based dispersion in Cycles!

I wanted to give more info about this, so here's a little thread
(1/6)
#b3d #blender #cycles

Here's the setup, and I'll explain how it works

First off, we want to generate random wavelengths in the range of the visible spectrum (we choose 380-720 nm)
(2/6)

We then plug that into the Wavelength node to get our color
And divide it by the average color in our range of colors from the spectrum
We do this to make the average white, since division by itself is 1 (sort of like a white balance)
(3/6)

This color is (0.193742, 0.132831, 0.124142) for this particular range (380-720)
I got it from rendering the random wavelengths on a plane, color picking, and comparing the divided color to pure white
(4/6)

Next up, we give our material varying IOR based on wavelength using Cauchy's equation
(en.wikipedia.org/wiki/Cauchy%27…)
This simple formula gives us our IOR per wavelength, with a value to change the strength of the dispersion
(5/6)

And finally a little tip, you can use the Object Info color to give objects with the same material different colors!

The rest is just a glass shader setup, refraction + glossy (reflection), mixed with fresnel

That concludes my ted talk, thank you for coming lol
(6/6)

Here's the scene file, go check it out, play with it :)
Also I included a wavelength node group that works in both EEVEE and Cycles (exactly the same as Cycles Wavelength node)
gum.co/CXXin

Share this Scrolly Tale with your friends.

A Scrolly Tale is a new way to read Twitter threads with a more visually immersive experience.
Discover more beautiful Scrolly Tales like this.

Keep scrolling