How to catch refractions in Cycles?

I would like to blur a lamp (emission shader) visible through a window (glass shader), but cannot figure out how to select the refracted image of this lamp. If I select the Render Layer containing the lamp without the layer containing the window, the image of the lamp is slightly offset, because it is not refracted. I had hoped to be able to select the refracted lamp as a render pass, but this doesn’t work either. Any clues?

I’m pretty sure this is done with passes. Though my understanding of working with those is very limited.

You’ll probably have to have a separate layer with the window on it and try out the different AOV layers until you get the data you’re looking to manipulate.

That was my first guess, but although I can catch the reflection in a mirror, I cannot catch refractions…

Perhaps something like this is what you’re looking for.


Basic shaders. Floor is diffuse, box is glass, and plane is the light source with the shown material.
Refracted light goes to 3 different passes: diffuse indirect (light through glass and on the floor), glossy indirect (reflected from glass), and transmission indirect (refracted light from glass).

refracted_light.blend (602 KB)

Cycles have no limitations and can render anything with background or emission mesh as light source. No need for passes or any tricks. Just doublecheck you have enough min bounces to shoot all objects, usually 4+. Other light sources have limitations, as some class of light cannot pass glass or reflect in perfect mirror.

You’re showing both the refracted light source and the glass.
I would like to select the refracted light source, i.e. the green patch, only.

Right. You could separate the glass from the rest with render layers. (I excluded the glass entirely from the bg render layer for this example)


That is exactly what I had tried before, but this way, you also lose the white refraction of the lamp, visible through the top of the cube?
Maybe I am overlooking something, I would appreciate if you could include the blend file.

That is not refracted light, it’s a reflection that goes to the glossy pass if I remember correctly. It’s white instead of green because it doesn’t come from the transmission channel, which was set in the material.
The only .blend file I’ve saved was the one I posted earlier.

I stand corrected. Let me rephrase my question as follows: is there any way to catch an object as we see it through the glass, without the glass itself?

This works with a plane background, but not so much with a gradient.

Plane background:
http://i1206.photobucket.com/albums/bb458/onjo/refractions.png

Gradient background:
http://i1206.photobucket.com/albums/bb458/onjo/refractions2.png

Attachments



I heard that moonbeams can be caught in a jar. Did you try a jar yet?

Probably not the best way to do it, but you could create a copy of the scene and tweak all materials to use Holdout for camera rays, except for the refraction material.

I attached a sample file, of a cube embedded in glass.
Is it possible to tweak it so that the rendered output looks as follows?


Attachments

refraction.blend (528 KB)

in render settings>light paths> select the direct light preset (this will lower bounces and turn off caustics) and turn up the glossy bounces to 3 and diffuse to maybe 2…
select the glass cube and under object properties>ray visibility> un-check shadow… now you can turn down the strength of the emission plane to 5 or 10… good luck

I am probably overlooking something trivial, but this leaves the glass cube clearly visible for me.
Could you post a .blend file?