Unity ShaderGraph: Creating Opacity Hole for Objects Inside Cloud - URP

87 views Asked by At

"Hello, I'm currently working with Unity version 2022.3.11f1 and utilizing Shader Graph. In my project, I have implemented a cloud, as visible in the attached photo. My goal is to enhance the visual effect by incorporating an offset opacity when the cloud interacts with walls and other objects. Specifically, I aim to achieve a fog-of-war effect where the opacity adjusts dynamically based on the presence of objects within the fog. I've attempted to implement this, as illustrated in another photo, but encountered challenges, and the desired effect hasn't been realized. Can you provide assistance or guidance on how to achieve this? Your help is greatly appreciated." enter image description here

enter image description here

enter image description here

1

There are 1 answers

2
Nikolai On

The thing, on the top of my head, is to bake your level into a texture. For example mark walls with white and no-walls with black color with a little gradient between. And sample a color from this texture with world position(not actually world position, but a value calculated based on it to map world position to the texture coords) instead of regular UV. So, when you sample a color you can add opacity depends on what color you've sampled.

You also can have a fog-of-war texture, that will work just like the texture, I've described above. But it will being modified in runtime, based on properties of objects, which can give a vision inside a fog-of-war.