Chromatic Abberation in Glass, An Emulation Test

I don’t normally go so heavily into building a node setup, but since the work is done I thought I might share it.

It all starts with a simple observation

https://dl.dropboxusercontent.com/u/25867270/projects/glass/realglass.jpg
A render of colored squares viewed through a magnifying glass (and a camera lens) shows apparent chromatic aberration as the angle of the glass increases towards the sides.

Using the default glass shader in cycles and as close to exact IOR and size of lens results in this look

https://dl.dropboxusercontent.com/u/25867270/projects/glass/standardglass.png

Not quite as distorted, but its plain to see that the internal math of the shader assumes a unified IOR for all wavelengths of light. This gives you a very efficient render, as this assumption saves you time, but when going the extra mile for photo realism, you concern yourself with the result and not so much the render time.

This is where I do a bunch of research, seeing what people have done previously and fuse many concepts into this spaghetti mess of nodes and math

https://dl.dropboxusercontent.com/u/25867270/projects/glass/node.jpg

On the right you can see the final grouping and the options, lets go line by line.

Refraction ColorThis controls what colors of light ‘make it through’ the object we are rendering. The color goes through a RGB separator to the three master colors. As I couldn’t think of a neat or non-ridiculous way of having a different index of refraction for each individual wavelength of light, I settled on having the three most important be represented. As will be seen below in example renders, you will rarely see a perfect spectrum, but in many cases it can give you just the little bit you need. Upon reflection I might be able to create a function which uses the IOR input, picks a range with that IOR as the midpoint, then uses a color ramp as a spectrum to show the aberration at the specific point.

Refraction Roughness
Behavior is the same as the original refraction shader

Index of Refraction
Relatively simple, same use as original, number gets sent through the math operators and added/subtracted by the…

Dispersion of Refraction
This number will control the divergence of the Red and Blue colors of light from the Green midpoint, which just uses the Index with no math added, this effectively controls the prevalence of the chromatic aberration effect. I’m not quite smart enough to make this based on the information here, so its just how much you add/sub to the IOR.

Reflection Color, Reflection Roughness, and Dispersion of Reflection
This is something extra I added from my own sensibilities, by default, the glass shader assumes that the surface and the subsurface are the same, so in terms of real life, it assumes that if the stuff inside is rough, or colored red or something, that the surface is the same. The entire node setup above allows you more control in this regard, you can have smooth fully reflective exterior, even if the interior is rough and colored

https://dl.dropboxusercontent.com/u/25867270/projects/glass/two%20color.png

Extreme Angle Correction

This number mixes between all of the math and extra stuff I have done and the default glass shader, the purpose is to fix the over-darkening caused by the refraction shader, in most of the following renders its value is set to .300, and even at this level you can get very apparent chromatic aberration effects. It uses the input value to change the Layer Weight blending, which is adds the facing and fresnel to affect the mix node.

The Experiment Results

https://dl.dropboxusercontent.com/u/25867270/projects/glass/newglass.png

The method Ive devised can give you cool effects, but requires you to clamp direct and indirect values unless you are going for super renders. Most of what follows is using 24 samples, with full global lightpathing, and direct and indirect clamped to 1

Here is a render lineup comparing the regular glass (top) with my glass (bottom) with equivalent IOR and color.

https://dl.dropboxusercontent.com/u/25867270/projects/glass/comp_glass_1.png

https://dl.dropboxusercontent.com/u/25867270/projects/glass/comp_glass_2.png

https://dl.dropboxusercontent.com/u/25867270/projects/glass/comp_glass_3.png

And here are the rest of my renders with varying IOR levels and different styles.

https://dl.dropboxusercontent.com/u/25867270/projects/glass/Ior_1100.png

https://dl.dropboxusercontent.com/u/25867270/projects/glass/Ior_1200.png

https://dl.dropboxusercontent.com/u/25867270/projects/glass/Ior_1300.png

https://dl.dropboxusercontent.com/u/25867270/projects/glass/Ior_1400.png

https://dl.dropboxusercontent.com/u/25867270/projects/glass/Ior_1500.png

https://dl.dropboxusercontent.com/u/25867270/projects/glass/Ior_2400.png

https://dl.dropboxusercontent.com/u/25867270/projects/glass/Ior_1500_red.png

https://dl.dropboxusercontent.com/u/25867270/projects/glass/Ior_1700_roughed.png

https://dl.dropboxusercontent.com/u/25867270/projects/glass/glass_dispersion_bottle.png

https://dl.dropboxusercontent.com/u/25867270/projects/glass/glass_dispersion_port.png

https://dl.dropboxusercontent.com/u/25867270/projects/glass/water.png

https://dl.dropboxusercontent.com/u/25867270/projects/glass/untitled.png

If you would like to see the node setup in person, check the attachments for the file that has all of the models used above and give it a look. The skybox and scratch displacements are of my own creation, and are free to be used by anyone who may find them useful.

DispersiveGlass_Example_BA.blend (14.9 MB)