2010/06/23

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.

Quick documentation:
Gem:
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.

Pass:
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



8 commentaires:

RoN43 a dit…

Hi! Thanks for work! SI 2012 x64.
' ERROR : PHEN 0.6 error: Internal error: misss_call_shader: Unexpected state->type case.

Youpi a dit…

I'm going to have a look and try to find the error...
Which version of Softimage do you use ?

Anonyme a dit…

He said "SI 2012 x64."

I have got ERROR : PHEN 0.5 error: Internal error: misss_call_shader: Unexpected state->type case.
In SI 2012 x64 SP1.

Youpi a dit…

I'm going to have a look...
I'm trying to have the same error. Do you have a scene to send to me , please ?

Youpi a dit…

It is working here... do you have version 1.4.1 ?

Youpi a dit…

Ok, I've got the error, in red, but the compound is woring anyway... I4m trying to fix this !

Thanks a lot !

Youpi a dit…

So, here is the FIX :

http://vadrouillegraphique.blogspot.com/2011/10/dispersive-gem-shader-compound-updated.html

Enjoy and thank you for your help !

Anonyme a dit…

Hi Youpi, This shader looks great and I can't wait to try it out but I have SI 2010 SP1 and the gem shader compound versions 1.41 & 1.42 don't seem to work. I can import them but the compound is just empty except for the note boxes -- no nodes at all. I wanted to try the original version to see if that worked but the link to that file isn't working for some reason.

- Erik W