Chaos Corona Forum

Chaos Corona for 3ds Max => [Max] I need help! => Topic started by: dj_buckley on 2023-08-06, 19:29:56

Title: Best way to make something visible in reflections but not refractions
Post by: dj_buckley on 2023-08-06, 19:29:56
I'm rendering a scene that looks directly at a glass window.  The environment beyond the window will be replaced with photography.  I've modelled some dummy geometry to replicate the environment so that I get accurate shadows and reflections, but I don't want these dummy objects visible through the glass so that I can get a clean alpha for comping the backplate in later.

It's worth noting that I don't really want to use the Direct Override because there are other glass objects in the scene.  So is there a way to override just the refractions of the main window glass?

What's the best setup to achieve this?
Title: Re: Best way to make something visible in reflections but not refractions
Post by: Tom on 2023-08-07, 05:44:32
Hi,

What I usually do is create the backplate directly in 3ds Max using a plane with a CoronaLightMtl rather than doing it later in post production. This way you don't have to worry about such issues.

Is there a particular reason why you don't want to create the backplate in 3ds Max?
Title: Re: Best way to make something visible in reflections but not refractions
Post by: dj_buckley on 2023-08-07, 07:39:30
Purely because I don't have the photography yet. And because you don't get correct shadows from a flat backplate.

The photography will be a very last minute job.  Typical British weather has meant we're only able to shoot 2 days before the deadline, so trying to have the renders ready to go in advance so all we have to do is drop the backplates in and submit the work to the client.

Out of interest, why do you use Light Materials?  I normally shoot 360's and then just drop that into the direct overrides.
Title: Re: Best way to make something visible in reflections but not refractions
Post by: Tom on 2023-08-07, 09:06:39
I use a LightMtl as a way to adjust the exposure of the backplate.
Title: Re: Best way to make something visible in reflections but not refractions
Post by: dj_buckley on 2023-08-07, 09:18:34
Ah ok, yeh i just use exposure in a CC node for that, or adjust it before dropping it in
Title: Re: Best way to make something visible in reflections but not refractions
Post by: Tom on 2023-08-07, 09:28:00
Did you try to set Alpha mode to "Always black"?
Title: Re: Best way to make something visible in reflections but not refractions
Post by: dj_buckley on 2023-08-07, 09:29:10
On what? The materials of the dummy geometry?
Title: Re: Best way to make something visible in reflections but not refractions
Post by: Tom on 2023-08-07, 09:31:12
Yes
Title: Re: Best way to make something visible in reflections but not refractions
Post by: dj_buckley on 2023-08-07, 10:54:19
Did you try to set Alpha mode to "Always black"?

That does the job, perfect, thanks
Title: Re: Best way to make something visible in reflections but not refractions
Post by: Tom on 2023-08-07, 11:38:56
You're welcome!
Title: Re: Best way to make something visible in reflections but not refractions
Post by: dj_buckley on 2023-08-11, 23:09:39
Hmm, this doesn't quite fix the problem after all.  it gives you the correct alpha, but you still get the reflections/refractions of the dummy objects in the glass.

I've attached a screenshot of the scene, the glass is currently hidden, but essentially the red blocks are behind the glass.  They're intended purely to cast the correct shadows into the scene and to affect the reflections of the objects infront of the glass.  So their current properties are - Visible to Camera Unchecked, Receive Shadows Unchecked, Cast Shadows Checked, Visible to Reflection/Refraction Checked.  If I make them invisible to reflection/refractions then the reflections of the objects infront of the glass will be far too bright reflecting just the sky.  This would look strange once the backplate is dropped in as the reflections won't match the backplate at all.

I'm attached some images.

"RENDER" - this is how it looks in the VFB

"ALPHA" - looks good using the 'Always Black' option on the background materials

"RENDER WITH ALPHA" - looks good so far

"RENDER WITH ALPHA BLACK BACKGROUND" - now you see the problem

"RENDER WITH ALPHA WITH BACKPLATE" - I've just dropped a random photo in to prove the point, it doesn't look as obvious but you can still see the brickwork from the dummy objects over the blue shutters

How do we solve this scenario?  Is it a case of rendering twice?  Once with the glass hidden and the dummy objects visible, then again with the glass visible but the dummy objects hidden?  Then comp the two together by masking the glass back in?  Although technically this still isn't right because now the objects infront of the glass wouldn't have the correct brightness/reflections when viewed in the glass reflections but that wouldn't be obvious at all.

Any ideas anyone?
Title: Re: Best way to make something visible in reflections but not refractions
Post by: dj_buckley on 2023-08-12, 00:37:30
Solved it.  Use the Legacy material.  Turns out this is an old issue I highlighted when the Physical Material was first released.  I thought it had been fixed.

Physical Material - Diffuse 0 - Glossiness 1 - Refraction 1 - Thin Shell Unchecked = Problem

Physical Material - Diffuse 0 - Glossiness 1 - Refraction 1 - Thin Shell Checked = Problem

Legacy Material - Diffuse 0 - Reflection 1 - Refraction 1 - Thin (no refraction) Unchecked = Problem

Legacy Material - Diffuse 0 - Reflection 1 - Refraction 1 - Thin (no refraction) Checked - Problem Solved

So it seems that checking Thin Shell on the Physical Material isn't fully disabling refraction like the Legacy Material Thin (no refraction) does.


Edit:  This is the original thread where I highlighted the weird behaviour of PhysicalMaterial Thin option back in 2021 https://forum.corona-renderer.com/index.php?topic=34168.msg189151#msg189151

It seems the explanation was that "Thin Shell in the Physical Material now takes Refraction Overrides into account".  The way I see it, as the tooltip states, Thin Shell should disable refraction.  Any refraction overrides should also be ignored if refraction is effectively disabled.

And that's exactly the problem I'm having.  The dummy geometry is visible to reflection/refraction because I need it visible to reflections.  I don't want it visible to refractions though because I want to render on black.  So I tick "Thin Shell" aka disable refractions.  And theoretically that should solve the problem.  The dummy objects would be visible to reflections still, but because the glass has refractions disabled (Thin Shell ticked), then the dummy geometry wouldn't be visible through the glass despite 'Visible to Reflections/Refractions being checked.
Title: Re: Best way to make something visible in reflections but not refractions
Post by: Tom on 2023-08-12, 03:57:28
Very intersting scenario, thanks for sharing.
Glad you found a workaround and I hope the Corona team will fix the behaviour of 'Thin shell' in PhysicalMtl in the future.

I'm not too sure, but maybe you could have fixed your problem by playing around with the 'Reflect BG override' in the 'Maps options' settings of the PhysicalMtl?
Title: Re: Best way to make something visible in reflections but not refractions
Post by: dj_buckley on 2023-08-13, 09:32:46
Very intersting scenario, thanks for sharing.
Glad you found a workaround and I hope the Corona team will fix the behaviour of 'Thin shell' in PhysicalMtl in the future.

I'm not too sure, but maybe you could have fixed your problem by playing around with the 'Reflect BG override' in the 'Maps options' settings of the PhysicalMtl?

I have a feeling that would also stop it reflecting the interior, maybe a flat plane would work ...
Title: Re: Best way to make something visible in reflections but not refractions
Post by: dj_buckley on 2023-08-13, 22:18:09
Found a downside to the Legacy Material - you can't get a proper RawComponent Reflection or CESSENTIAL Reflection pass when Thin is checked, it always seems to have transparency when Thin is checked.

So my choices are Physical Material - just doesn't work but can get a decent Reflection element out of it.

Legacy - works as I want but can't get a decent element out of it.

So whichever I use I have to render twice if I want the element as well.

Can't have it all I guess.
Title: Re: Best way to make something visible in reflections but not refractions
Post by: Tom on 2023-08-14, 03:39:46
Thx for letting us know @dj_buckley
Title: Re: Best way to make something visible in reflections but not refractions
Post by: Aram Avetisyan on 2023-09-04, 10:20:16
Hi,

Sorry for being late to the party, but I think what you want to do is quite achievable with RaySwitch and/or alpha mode override.
First, I think you should use thin mode for glass for optimal render times.

Then, you can use a RaySwitch material (without reflections, simple gray material) for the Global Illumination of the outside objects, to get the shadows from them.
This way they are still transparent (black) to the alpha, and you can easily composite what is outside, through the glass, later on.

Of course you can get different render elements and try complex compositing, but I am always for keeping things simple.
You can as well render everything seen through the glass as real (with correct, physical material), and then set the glass alpha mode to always black to completely change what is directly seen in the glass (or overlay with different opacity).

This really depends on the objects outside of the glass and the type of compositing to be done too, of course. But I don't think complex solutions bring improvements in this case.

Please see the attached image for more details.