[2D] Fog of War effect

Hello

First of all, I’m a big noob with a bare minimum of knowledge about unity.

I’m trying to create a fog of war effect and found this post on the unity forum.

I understand what Tidyui means, but how can I actually combine Main Camera and the RenderedTexture in Unity itself?

I have no understanding of how shaders work (or what they even are actually).

Thanks in advance

(I know it’s kind of a douche thing to ask help about another post but I’m not into necrophilia)

One way would be to use the Stencil buffer in a shader, which requires a bit of shader knowledge.

Luckily for you, Unity introduced the new SpriteMask component, which does Stencil masking for you.

You can use the SpriteMask component to create areas where certain sprite layers wont render.

So create a big sprite that is transparent black, set it to a specific layer, set it to be “visible outside mask”. Then create your visible area shapes as gameobjects with SpriteMask components, set to mask on the black sprite’s layer.

2 Likes