Cycles: how to create background invisible to camera behind glass

Hi! I have a problem with the environment that I can’t solve. I hope you can help me to solve it.

I can’t understand how to set up an environment that isn’t visible to camera and that is behind a glass of a window. Becouse if I use that environment to light my scene, I have to make it visible to transmission, but if it is visible to transmission, it becames also visible to camera, even if I set that background invisible to camera with the light path node.

So how do I achieve a mix of backgrounds where the one that lights the scene isn’t visible behind a glass to my camera?


Can you supply an example scene

You can just make the background transparent in the render / film settings. The environment texture will light the scene but not be visible

Sorry, it doesn’t work, because it is transparent only if seen directly from the camera, not through a glass. The problem is the glass.

Do you need the environment just to light up your scene? Maybe making the enviroment only visible to diffuse and glossy rays?!

Unfortunately the scene sees the environment by the transmission rays when there is a glass, so it doesn’t work.

Refractive shaders render opaque in Cycles. Use transparent/glossy shaders for your glass

I tryed this. It should work (even if there isn’t refraction), but doesn’t work completely. Still remain some reflections on the glass of the HDR, I don’t know why. Probably a matter of normals or of the thikness of the glas panel. It still remains a workaround, not a correct solution. It seems cycles can’t achieve this result.

It’s strange becouse it should reflect the interior of the scene, not the exterior. Anyway, I found a solution, but it is still not ideal. I made the glass panel object visible only to the camera. The bad thing is that it force me to separate the glass panel from the window frame, so I can’t edit them together no more. So I thinks this still remains a limit of Cycles it should be considered.

Why don’t you use the Light Path node to make the window material transparent for all non-camera rays? That way you could solve this on a per material basis and not on a per object basis.

Still not sure what you expect Cycles to do in this case. Did you try experimenting with different environments for the different ray types? I get that Cycles doesn’t seem to work as you expect it to, but that doesn’t necessarily mean that Cycles can’t do what you want to achieve. Perhaps it’s you that has to reconsider your workflow to match Cycles’ inner workings?

Could you post a screenshot of what your current result looks like and perhaps an example of the result you want to achieve? It’s all a bit acedemic right now…

Good point! You found it! This works! Here the settings needed to have a background behind a glass that is idfferent than the one that lights the scene.
If look at the scene image (really minimal) you see that the red background lights the box trough the glass, but behind the glass you see the HDR.

Thanks IkariShinji!