32
$\begingroup$

I'm trying to achieve the effect where a beam of light sent through a prism or other refractive object, separates out into the light spectrum. (See image below)

enter image description here

This effect is especially useful to have when modeling gemstones, since the 'sparkle' of colors produced by this effect adds a lot of realism to the model.

It does not seem possible to get Cycles to produce this effect, since Cycles handles each ray of light as only a single, one-colored ray. Is there any way to coax Cycles (or any other render engine) into treating light as a full spectrum? Is this kind of treatment of light even possible in Blender?

$\endgroup$
2
  • $\begingroup$ I was about to ask this question myself, after looking all over for good techniques to get this effect.. :D $\endgroup$
    – gandalf3
    Jul 2 '13 at 19:45
  • $\begingroup$ There's a new Add-on "Prism" which should help you achieve exactly this effect. $\endgroup$
    – Samoth
    Mar 21 '16 at 19:58
16
$\begingroup$

It is fake-able to some extent in cycles, see some of these results:

http://www.blendernation.com/2012/04/05/cycles-diamond-dispersion/

http://www.blendernation.com/2012/09/04/cycles-dispersion-glass-shader/

One technique I know of is to use multiple Glass shaders with different IOR values

A quick setup:

enter image description here

Low sample result:
enter image description here
(Not that great, but the closest method I know of..)

Luxrender is an open source unbiased bi-directional rendering engine with blender integration (and GPU rendering support via OpenCL) and is capable of this.

Some examples:

http://mitsuma.deviantart.com/art/LuxRender-Prism-198927185

https://www.youtube.com/watch?feature=player_detailpage&v=kIX5WL07Uss#t=15s

Luxrender (technically SmallLuxGPU, an early version of luxrender with GPU support) https://www.youtube.com/watch?feature=player_detailpage&v=jk-N4f9ze4k#t=82s

Yafaray is another open source render engine with blender integration that supports both biased and unbiased techniques, and also seems to handle this well.
http://www.youtube.com/watch?v=RVHYMq8NEEs

$\endgroup$
3
  • 1
    $\begingroup$ Just a note, since Cycles' caustics are still not very good, if you use that Cycles material setup in a low-light setting you end up needing about 10,000 samples to see anything reasonable. I ended up going with Luxrender for that reason, and I've gotten great results, thank you! $\endgroup$
    – Gwen
    Jul 9 '13 at 1:46
  • $\begingroup$ LuxRender and its associated website has since moved to luxcorerender.org and the old links in this post now lead to a random shop. $\endgroup$
    – ch4rl1e97
    Feb 10 at 16:46
  • 1
    $\begingroup$ @ch4rl1e97 thanks for the heads up! $\endgroup$
    – gandalf3
    Feb 11 at 7:40
2
$\begingroup$

Cycles only shoots rays from the camera:

diagram of the ray path
(source: blender.org)

For dispersion, support for bidirectional path tracing needs to be added. This is currently considered a low priority. There has been a community effort to get an additional developer to implement it.

$\endgroup$
1
  • 7
    $\begingroup$ Having myself written a unidirectional forward pathtracer supporting dispersion, I can say that requiring BDPT is incorrect. $\endgroup$
    – imallett
    Nov 16 '14 at 23:25
0
$\begingroup$

I know this is old, but there's now a White Noise Texture added with 2.81. It generates a random value based on the input. So if you put something like Geometry > Position or a texture coordinate (as long as it's different depending on where the ray lands on it) it will be noisy at first (some pixels white/some black/some in between) because each iteration it actually samples ramdom trajectory within each pixel's cell.

All this is to say, you can actually use the white noise to randomize the IOR and the color. And because it's fully deterministic PRNG (same input = same output), if it generates 0.68274, it will use that number for the IOR & the hue of the color, effectively mimicking the property of certain wavelength refracted at certain degrees. Just make sure it's the same white noise node to randomize both.

All that bidirectional path tracing does is seemingly just randomize the wavelength and use that to determine the refraction IOR. It wasn't possible to randomize something per ray before, but now it actually is and you can, in fact, approximate dispersion very well in RGB. Bidirectional would just be slightly more accurate-looking.

$\endgroup$
4
  • 1
    $\begingroup$ I'm curious about your method, and I'd like to see this answer developed some more if you have the time. :) $\endgroup$ Jun 25 at 4:34
  • $\begingroup$ This sounds interesting, but from what I'm reading in the answer I have no idea how to setup a material for this method... $\endgroup$ Jun 25 at 8:46
  • $\begingroup$ I know this is a bit late, but I've finally elaborated on this here: $\endgroup$ Jul 22 at 19:40
  • $\begingroup$ youtube.com/watch?v=lZuvwmqWjkk $\endgroup$ Jul 26 at 5:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.