2012/12/16

OSL Dispersion Refractive Shader

This Shader does a per wavelength Dispersion in a refractive material.

It is brut force dispersion shader and need a lot render samples to have a correct look. There is near no optimization, so it's not made for animation.

It was made for educational purpose and should be optimized and rethink for an effective production use. Indeed, results are really good for still pictures.

Small documentation :
Transp Color = Color of the transparent material.
Beware that if saturation is too high, you'll not see any dispersion.

IoR = Main Index of Refraction of material.

disp = Dispersion , in IoR Delta.
correct value are between 0.05 and 0.2.
A higher number give more rainbow in transparency, and slower rendering time.
A too high value ( > 0.3 ) can lead to rendering errors or inconsistency.

Roughness = surface roughness.
A good value is 0.0. Higher values blur refraction and could hide dispersion effect.

Full render = optimization.
1.0 = no optimization, slower render but accurate.
0.0 = no dispersion except for eye rays. You'll see no dispersion on a reflect of the object, and backface is ignored.
It is about 30% to 60% faster, and the difference between realistic and optimized material isn't noticeable for rendering that doen't need pure accuracy.


You can download the OSL Shader here : GDispersive.osl

This shader is made for educationnal purpose only. Use it in production at your own risk.
Closures are for Blender/Cycles. They could need adaptation for your renderer.

If you use this material, please credit it and me. Thank you.

Enjoy !

OSL Dispersion Shader from François Gastaldo on Vimeo.








2 commentaires:

Blender Sushi a dit…

Do you use Blender to render this? I am getting a lot of hot speckles, wonder how you set this up? Maybe example scene would help?

Thanks!

Youpi a dit…

Yes, I used Blender to render those animations. I used 300 samples.
I unspeckle renders with compositing.

I exactely use the way described by Zelen 3d, on blender artist :
http://blenderartists.org/forum/showthread.php?234018-Cycles-noise-removal-with-nodes

You can also try to put the Cycles Clamp value to 1.2 or 2.0. It greatly depend on your lighting.

It helps a lot. Thanks for your comment !