Cycles Diamond Dispersion


Kirado shares a technique to simulate dispersion with Cycles.

Kirado writes:

Diamonds rendered in Blender Cycles, using a faked dispersion shader.

I made a diamond shader a few months back; after seeing some diamond renders appearing here on Blendernation I thought I should share the node tree, so people can see what’s possible with cycles, and get the most out of their jewellery renders.

I did a mental ray diamond tutorial ages ago on Zaps Mental Ray Blog and wanted to see if I could get similar dispersion shader working in Cycles. The Diamonds were modelled in 3ds Max and imported into Blender.

I only used RGB Shaders with slighty different IOR mixed with ADD.

Here’s the link to the dispersion node setup on my deviant art page.

Would be fantastic if someone could hard-code a dispersion setting into the glass node ;-)

It looks like you're using an ad blocker. I really need the income to keep this site running, so please enable advertisements on BlenderNation, or leave me a small donation. Everything helps!

  • Obladiobama

    Very cool, thanks for sharing!!!

  • Zander Nicolic

    Thanks, I remember it well, and found it useful. Allow a question: are the slight differences in IOR (growing from R to B) meant or casual?

    • Kirado

      Yes, you have to use 3 different IOR settings. I used the diamond IOR (you can find actual IOR for diff materials on-line) as a mid point, then I increased the IOR higher and lower for the other two glass shaders, It’s important that you combine them using Add, otherwise your glass will not be transparent.

      I also had to add a tiny amount of blur/roughness to each shader, to remove firefly artefacts.

    • Lawrence D’Oliveiro

       Basic physics. It’s how a prism works.

      • Zecc

         Double rainbow! All the way!

  • Alain

    Wow, very simple Nodesetup :-)

  • Nuno Felix

    I created a setup like this some time ago, but for Blender internal, and I got some great results too. I set the differences in IOR for R, G and B as follow: The IOR reference value for the G, a smaller value for R, and a bigger for B. The difference in the values determines the amount of diffraction

    • Kirado

      Wow, that’s cool to know you can do it on the internal as well. Like I said it would be great to have it as a hard coded option in a glass shader, maybe a dev would like to pick it up, at some stage, when they’re not too busy.

      • Nuno Felix

        Yes, i tried for the first time in 2.49, but i had to make some changes for it to work correctly in 2.6.
        I agree, it would be nice to have it in a glass shader, or in the transparency settings, for the B.I.
        Here is an example done with Blender Internal…

  • Sasa

    hey dude
    great work, could you upload blender scene here or somewhere else?
    thx anyway

  • Brian Lockett

    Yet another reason why I’ve gotta learn more about how to use them shaders in Cycles, man!

  • Lucky3d1

    Smart! Thanks for sharing.

  • Gbroadfoot

    Very nice render! It’s a very interesting method. I played around with this technique. You can actually speed up the render considerably by making use of the light path node or using a plain reflective material, when the light doesn’t pass through the surface. I posted my .blend file on blendswap doing this here I hope they build spectral rendering into blender one day but until then it would be great if they could include something like this (even if it’s just a preset node group).

    • Kirado

      Some cool examples. I’m still not sure how the light path node actually works, because I find the terminology for it confusing, eg. you have a glossy node (by glossy do they mean roughness or blurring of the reflection??), and a reflection node..  but reflections are glossy.. and transmission rays? Aren’t all rays transmissive ie. they move through a medium, some of them get absorbed along the way to your eye/camera.. ie. the air.. 

      The documentation kinda hops around from real light characteristics and 3d terminology when it comes to defining what they are talking about. I think the light path node could do with some clearer documentation, and some examples of how to use the different light path nodes. I’m not really sure were you can ask these questions about cycles.

      • Gbroadfoot

        Yes, it’s not well documented at the moment. I had to look at the code to see what was happening. Basically cycles applies a basic path tracing rendering scheme. This casts rays from the camera and bounces them around the scene. Each ray has a state that changes each time it hits a surface. This state includes flags for the type of ray. For example, when it’s first cast from the camera these include one for ‘camera ray’. if that ray hits a glass surface it randomly chooses to either reflect it or let it refract through. If it reflects it adds a ‘glossy’ and ‘reflective’ flag but if it chooses to let the light through it adds a ‘transmissive’ flag. Either way it removes the ‘camera ray’ flag. The ‘light path’ node gives each flag, with a value of 1 for the ones associated with the ray before it hits the material. So, if a mix shader is connected to the camera ray link then one shader will only be used for the first bounce and the other shader will be used for all other bounces. How each shader interacts with the flags isn’t well documented and the fact the rays go in the opposite direction to actual light is confusing. I hope that’s useful. I may make a tutorial if I get time.

        • Kirado

          Hey thanks, does make it a bit clearer! An in-depth tut would be awesome. ;-)

  • Peter Drakuli?

    Simple yet effective technique,awesome result!Excellent and thank you for sharing,Peter    

  • Dewald

    Nice. I posted a similar setup in this post’s comments:

    • Dewald

    • Dewald

       I added an add shader to brighten it up a bit. As the glass seem a bit dark sometime in Cycles.

  • George_Kim

    Thanks for sharing, Kirado. I’ve just tried the node and noticed that it’s mimicking the dispersion beautifully. :)

  • onjoFilms

    Not sure if you’ll see a dispersion code in the glass set-up.  As Lukas states that advantage of Node Groups
    in the Blender Development log:”The advantage of generating such complex effects from simple components instead of adding them as a new node type is customization: You can take an existing shader/particle effect/object, make a copy of it and then tweak any internal part to make a new one. All this can be done by artists or TDs, without having to write C code and either use their own Blender builds or get a patch accepted into trunk.”

    • Kirado

      to do proper dispersion it would have to hard coded in, it’s not something you can make efficiently with nodes. It’s not a hugely important feature, but would be useful to have.

  • Everton

    This thread is also worthy to follow:

  • Mehmet PINARCI

    diamonds are forever . That makes me want to model one .

  • kram1032

    With a more complex setup you could increase the number of color samples and thus the accuracy. But what you got there already is great :) (nion did such a thing in BI but it should be possible to transfer that to cycles )

    • kram1032

       Oh and as he and I discussed in the comments below his video, you could renormalize colors by doing an average calculation instead of doing “max” :)

    • Gbroadfoot

      I had a go at increasing the samples like Nion did but for cycles. I included an attempt at this in the blendswap file I mentioned above, with five coloured glass shaders. Unfortunately, I couldn’t get this to work. There seemed to be a bug in cycles that prevented too many glass shaders from being combined. I reported this bug awhile ago. Not sure if it has been fixed yet. Three colours does seem to be perfectly reasonable though. The spectrum can still be smoothed more with non-zero roughness or by adding a little noise to the IOR.

  • LiquidForgeStudios

    can somebody post a alternate link cause my parental control software blocks deviant art.

  • Kiril Viktorov

     Diamond ring with fake dispersion

  • Ryan Hirst

    Brilliant! I just finished testing Cycles with Fresnel’s experiment, and just hit the end of the physics with Newton’s prism. I was stuck for a solution, but this is brilliant. Still have some ideas brewing, involving mesh precomputation. I’ll let y’all know what I come up with.