Custom Opal Shader - Part 1

Background

As someone who has been a longtime rock collector, I enjoy any type of interesting rocks and minerals, but there is something almost mystical about opals to me. I find them absolutely fascinating.

Gem grade (precious) opals display a phenomenon known as “play-of-color,” which basically means that their color changes depending on the angle that they are viewed from when exposed to light.  An example of this can be seen in the video below.

This opal is one from a personal collection that I was able to get a video of. It is “dark base” opal from Mintabie, Australia. While it isn’t as vibrant as other very expensive, high quality opals, this does exhibit some play-of-color and provides a simple example of the effect. For a better idea of what top quality opal looks like, consider checking out this video or this one or just check out the Black Opal Direct YouTube channel since they have some of the best close-up videos of opals and they also have some interesting content about the mining and cutting of opals.

Research

Another thing that is interesting about opals is that it isn’t particularly easy to replicate the look of them convincingly using standard rendering workflows. With all of that in mind, I decided that it would be a fun challenge to try to replicate their appearance with a shader.

I started by gathering resources on how opals get their appearance in the real world. I learned that opals are formed over millions of years as water soaks up silica in the earth, then pools and evaporates, which gradually builds layers of microscopic silica spheres. These spheres can eventually coalesce into a matrix formation that creates crystals. When conditions are just right, and the arrangement of spheres has the perfect mix of regularity and irregularity, light bounces through the tiny substructure of the material creating an array of colors. If the silica spheres are smaller, it produces blues and greens, and if the spheres are larger, yellows, oranges, and reds appear. The way that the light interacts with the medium is called diffraction in physics. Diffraction can also be seen in a variety of other materials as well. For example, certain prisms and optical glass also produce diffraction effects. For example, it is also what gives the surface of CDs and DVDs their characteristic appearance.

Existing Solutions

After conducting some initial research, I found that various other people have tried to create opal materials in the past, but I think that there is still room to improve on them. Most seem to try to simulate the effect within the confines of the PBR pipeline and therefore only vaguely match patterns and shifting colors found in real opal. Some seemed like they might be trying to use iridescent effects that were admittedly closer to the real effect, but still didn’t look quite right since iridescence is not actually the same physical phenomenon (although it is closely related).

I did find one example of a quite realistic opal rendering that was created using Cycles in Blender. However, despite some interest from the community, no node set-up or shader details seem to have been shared and the original author doesn’t seem to have posted any further updates. For reference, the Blender example can be found here. This example does a nice job of replicating a crystal opal, but the color shift and angle variation is all very uniform. It has a nice translucency, but the play-of-color still appears to be a surface effect.

A different example of an opal shader was created by Wesley Eldrige in Unreal Engine 4 and the demo video can be seen here. This one mimics the play-of-color quite well by using the light angle to drive the color changes in the flecks, but the maps are somewhat blocky. Although it seems like it does try to provide a little bit of the illusion of inner depth, it still looks a little bit flat. That being said, I would be hard-pressed to mimic depth any better in a non-volumetric material. Overall, this is one of the best that I found.

Please check out Part 2 for more information on my version of the opal shader.

Previous
Previous

Custom Opal Shader - Part 2

Next
Next

Introduction