26
$\begingroup$

Here's a sample scene:

A room with a window, a point light to project light into the room, an HDR environment outside the room and a nice Image by Rembrandt that should be somewhat reflected on the glass:

enter image description here

Using a standard glass shader on the window, the direct light from the lamp does not shine into the room, regardless of how bright that light is. So I can't recreate the impression of hard day light, with clearly defined areas of light and shadow.

enter image description here

Adding a transparent shader to the glass shader I get a very pleasing result. The light from the lamp illuminates into the room creating defined shadows, transparency seems unaffected, to see the HDR in the background, the refection seem correct to me (I also like how I get double reflections from the thick glass).

enter image description here

Even though I am quite happy with this solution, I've gotten a few comments on making a setup with light path nodes controlling the mix of transparent and glass. The biggest issue is that the reflections on the glass are brighter than what they should be.

So the question is: By using this approach am I messing up any of the qualities of glass? And if so, what would make a proper glass shader that is realistic, in terms of letting direct light through, while keeping reflections, refraction and transparency?

A file to play with:

The HDR image used was created by GiantCowFilms

$\endgroup$
11
  • $\begingroup$ Why not use Is camera ray to mix the transparent and glass? $\endgroup$ Commented Feb 28, 2016 at 0:27
  • $\begingroup$ @GiantCowFilms because it changes the transparency: i.sstatic.net/efCNj.jpg or it doesn't let the lamp's light through again: i.sstatic.net/oTo21.png $\endgroup$
    – user1853
    Commented Feb 28, 2016 at 0:28
  • $\begingroup$ Why does it change the transparency? smells second followup question $\endgroup$ Commented Feb 28, 2016 at 0:28
  • $\begingroup$ @GiantCowFilms see how the trees in the background change. It looks like all we get is refraction $\endgroup$
    – user1853
    Commented Feb 28, 2016 at 0:29
  • 1
    $\begingroup$ Have you tried putting a portal over the window? That helps with light calculation and distribution in an enclosed scene. $\endgroup$
    – Italic_
    Commented Feb 28, 2016 at 3:00

1 Answer 1

27
$\begingroup$

This has been answered before with a very clear explanation here.

Using the Shadow Ray and Reflection Ray trough a Math/Maximum node to combine the glass and transparent shaders.

I'll just post the node setup here, maybe someone will find it useful.

enter image description here

$\endgroup$
1
  • $\begingroup$ An equivalent to this using the Principled BSDF shader only seems to be as simple as plugging the math node to an Invert Color then that to the Principled's Alpha socket. $\endgroup$
    – Lauloque
    Commented Oct 25, 2023 at 18:53