Dispersive Gem Shader Compound updated and FASTER!
I’ve worked on optimization of the Gem Compound Shader.
In the previous version, each ray were rendered 3 times, for R,G and B. It is needed for real accurate dispersion, but it is slow. And even slower when real reflections are added. But we don’t need such accuracy every time. Often, just a good visual effect is needed. So, here is a new version of Gem Shader Compound.
You now have the choice between 3 level of accuracy (and speed) of dispersion. The rendering time is dramatically speeded up!
You can even add reflections and still have a faster rendering time than previous version.
I also added a ‘no dispersion’ option, so you can go even faster if you don’t need dispersion at a time.
This Compound shader is still released for Educational Purpose and is fully commented. You can watch and read how I optimized it to try to get your own compounds faster. If you just want to use it for production, email me first, please.
Transp Color: The color of the Gem. It should stay not saturated. If you use too much saturated color, you would not see any dispersion effect.
IOR: Base Index of refraction of the Gem. Gems usually have strong IoR, between 1.8 to 2.42.
Dispersion: the variation of IoR between Red and Blue. The stronger this number, the stronger is the effect. I recommend to stay below 0.15.
Metal Gem: when On, the reflection is colored by the Transp Color, giving a metallic look. This effect is not physical, and there is no metal gem in real world. Indeed, the effect is interesting.
External Reflection Only: when On, the output returns an alpha ready reflection on external surface of the gem. No transparence is rendering neither ‘total inside reflection’. If you want to composite reflection, you have to make a pass with ‘External Reflection Only’ ON and another OFF.
Accuracy / Speed:
Accuracy: You have 4 ways to render dispersion, from slower to faster:
Full dispersion: it’s the one in the first version of the compound, the slowest one.
Minus back: faster, but secondary dispersion on total reflection is not rendered. I recommend ‘Minus Back’, which is fast and good enough for most usages.
Front only: just the dispersion of the front surface is rendered. It is really faster, and on very complex objects, the difference is not so visible.
No dispersion: No dispersion is rendered! So the Shader is doing usual glass, as other Mental Ray Shaders. It is faster than any dispersion and can be useful if dispersion isn’t needed for a scene…
External reflection Added: Add the External Reflection, but do not render Total Reflection. It is fast enough to be used with any Accuracy.
Full reflection added: Do complete rendering, with Transparency, External, internal and Total reflection. It is the slowest and the most accurate rendering of dispersion. Indeed, it is fast enough to be used with ‘Minus back’ and ‘Front Only’. Using it with Full dispersion can be very very slow and is ok just with very powerful rendering machine.
Usually, on simple objects, you should use the shader compound (few polygons gems) with Full dispersion and External Reflection.
For very complex object, Front only and External Reflection is fast and nice. I strongly recommend to try different accuracies to see what is the best rendering time / accuracy for your need.
You can download the compound here: GemShaderCompound1.4