How to control opacity through a post process material?

I’ve got a post process material and I would like to make all meshes outside of a sphere mask completely invisible, as if their opacity was set to 0. I’ve seen it done, but can’t figure out how to do it inside the PP material. For performance reasons, I don’t want to have to use a parameter collection and put an opacity lerp into every material in the map.

Any suggestions?

Thanks!

what do you mean all meshes? what about landscape, characters, skysphere?
if you hide everything outside sphere, there will be complete darkness.
so you can Lerp (0, scenecolor, spheremask)

Hi Redbox, good question - I’m trying to hide everything (landscape, characters, meshes, etc) except for the skysphere, so just using a 0 input won’t work. The material screenshot above is an extremely simplified version of what I’m actually using. In my real material, I have an IF function that checks the distance between player position and absolute world position and if it’s > 250k units, then a different material is applied to the skysphere.

Here’s an idea of the effect in action, so I know it’s possible: Skip to 44:42

Only one way I see to do that is to render sky sphere with specific stencil value and work with it. Like compare it with everything else (with 0 stencil value).
But its only as assumption, I never tried something like that before.

Render skysphere using tranluency and disable depth test. Then add opacity logic there.

@ I’m coming back around to this nearly 2 years later and still wondering about your BulletTrain de-rez effect… how were you able to control the opacity of the scene through the PP material? The scene meshes’ opacity appears(?) to fade leaving the virtual plane function underneath… were you simply setting the emissive for the meshes to (0,0,0) and faking an opacity effect with the virtual plane function?

I got an idea on how to do this. Its very simple if you use a “HDRI” or a 360 picture on your skysphere. So for this to work I used a HDRI picture (360 sky texture) and reused the same picture inside the postprocess material. So what happens is that when there is the “Transparency” part it get replaced with the HDRI picture of my sphere. Just make sure that the post-process i setup to be “Before Tonemapping” because if its on “After Tonemapping” it will be darker than the skysphere.

The second picture is the skysphere material and the last one is the postprocess one. Good luck!

Very interesting solution! I will play around with this and see if I can make it work for my needs. Thank you!

Let me know if you want some further help on this.