Dielectric materials and IOR
I always take questions on the significant differences between using the mental ray sample compositing mib_refraction shader versus regular shaders (such as the Maya Blinn). As always the question is similar to this question:
In my final render, why does the Maya Blinn refraction result differ from the MR Blinn with MR refraction with ramp nodes? Essentially I have double checked settings and it could only be the way I have constructed my shader tree. All refraction settings are the same, same ramps; the only difference is the setup and Maya additions to the standard Blinn shader."
The answer is in how these shaders handle refraction. The law of refraction states that the speed of light changes as light travels through different densities that are typically referred to as dielectric materials. The term index of refraction (IOR) represents a ratio that describes the change in the speed of light inside and outside the current dielectric. So as it slows down the ratio (number) increases (one and higher) and as it accelerates the number decreases to one below one when traveling from inside a dielectric to vacuum. Generally speaking, the speed of light is never faster than in vacuum – it is the “speed of light”, so the ratio refers to the change in speed between two dielectrics. If we consider the speed of light in vacuum (as an assumption referring to the atmosphere –air – as vacuum for all CG purposes) as a “max speed” then as it enters a dielectric it slows down, thus the IOR for water is noted as something like 1.333 indicating the ratio has shifted. Mathematically if we consider the max speed as a value of 1, then as light enters water it slows down by 25% because 1/0.75 = 1.333. Hence my comment above on increasing ratios as the speed slows down.
As discussed in my book, another characteristic of light is that it bends when it enters a dielectric, however, as it exists (assuming it exists back into the same atmosphere, i.e. air –water – air) it will continue in the same direction as seen in the image below, but at an offset location.
Thus light actually bends twice; once as it enters and once as it exists as seen in the image.
The math then becomes the index of refraction going into the dielectric, air to glass (1 / 0.666 = 1.5 as IOR), then a refraction on the other side which would be glass-to-air which can be written as the IOR of air divided by the current IOR (1/1.5 = 0.666). this represents the change of the speed of light in glass to air.
In 3D
Now to 3D, I cant’ speak to the actual math used in Mayas’ Blinn shader. However, I can show you another way of seeing the correct result and by doing so identifying what the Blinn shader is actually doing. I’m putting this here with a grain of salt because it contradicts other wise contributors to the field; this is a topic that has made us all grow a few gray hairs…
The Setup
In my scene I have three spheres as seen in the rendered figure assigned with the shaders seen in the shaders figure. In the render version, note that B and C look very similar (the angle of the camera creates the slight differences), whereas A and C are the common differences that results with the “question” cited above.
The Shader trees
Under the shaders figure, for all the shaders you can see the typical setup for a reflective / refractive glass sphere with Fresnel reflections and refractions. A ramp is being used with the sampler info node to drive the refraction intensity (mib_refraction > refraction attribute) and the inverted ramp is used to drive the mib_reflection > reflection intensity. Thus the ramp acts as a black and white mask driving the Fresnel reflections. The same ramp was duplicated each time and is being used by the Maya Blinn shader in the same way (once connected to transparency and the reverse node connects to a luminance node *vector to scalar* which connects to the reflectivity attribute.


The Results
The main thing to notice in the rendered figure is that B has been divided into two separate pieces of geometry to control the IOR going in and out of the sphere. Thus:
1. The sphere seen as A (one piece) is assigned with the mental ray shader seen in the shaders figure as “mental ray front surfaces –(on the top left).
2. The same shader is assigned to the front surface of B, handling the IOR going in (1.5), whereas a similar tree is duplicated and assigned to the back surface with an IOR of 0.666 (as described above).
3. Note that the back surface would not show reflections hence the reflection shader is omitted as seen under the shader tree (top right) “mental ray back surface”.
4. The Blinn acts as a more complete solution since the IOR in and out is considered twice (going into the surface and coming out).
You may conclude:
1. By comparing B and C, while knowing that B actually uses two separate shaders that have the correct IOR settings, the similarities indicate the Blinn is considering both interfaces.
2. Keep in mind, the angle at which we are looking at makes the checker pattern shear towards the viewer with the Blinn. Same thing happens if you place the mental ray shader in the sample place relative to the camera.
3. It also shows that the mental ray shader mib_refraction shader (a simple component shader) does one thing only. When assigned to an entire surface, it only considers the IOR going in, without considering a second IOR coming out.
4. As an additional comparison I used the dielectric shader – the most physically correct shader in the physics library- and it too looked the same when set with an IOR of 1.5 going in and an IOR of 1 describing the outer environment). Not illustrated but you can run your comparisons and see the results.
5. When you exit a surface, like water, to a different surface (other than air – like glass), you need this two shader setup or use the dielectric material. Thus the Blinn, as many other shaders calculate the IOR correctly making the assumption of air – to a given IOR – back to air.
Thus, in conclusion, most illumination models that have an IOR attribute only cope with a transition into that IOR and back out. This makes for a single dielectric-to-dielectric interface. Thus you would need to use two Blinns two model something going into glass (let’s call it A) and then going from glass into water and back to glass (B) and of course A again going from the glass back to air. The only shader that allows you to consider a change in dielectrics, meaning two interfaces is the Dielectric shader. Essentially you can specify an in going IOR and out going IOR so that can simplify some of the process. You will need to scratch your head a bit while setting it up but if you get it, you’re already making good progress!
If you want to really experiment with it, you can take pictures, for example through a glass with water, and place a few pins behind the glass in a straight line. This will show the offset seen through the glass and you can then try simulating a similar render in 3D, matching the IOR behavior. I’d be happy to see some posts with images showing these sort of comparisons.
Cheers,
Boaz


