- Home /
Rendering only outside the fog
I am trying to implement a simple 2d fog of war; main idea is to keep a black but somewhat transparent rectangle sprite in front of camera but circularly reveal around units. (I am thinking of finding the point by ray-casting but a better idea is very welcome)
Naturally when an enemy shows up, you will see them outside the fog. I knew it could be done by disabling/enabling render component by some visibility check, though what I am curious about is whether we can do this through shading: some kind of fragment check maybe. This way exactly what part of the incoming object is visible would be seen outside the fog. If it was half visible then the other side would still look as grayed out background.
Answer by arlinon · Dec 28, 2013 at 07:22 PM
I used Zbuffers to achieve exactly what I desire, hope this doesn't create some zfighting problems on different platforms. Each unit has a circular texture to create an aperture through fog, so no need for checking locations.
Your answer
Follow this Question
Related Questions
Unwanted eye adaptation effect/Overexposure after switching to HDRP 1 Answer
Shader Question about Alpha 0 Answers
Use a sprite to render another sprite transparent 0 Answers
shader pass controll 0 Answers
Shadow Support in Custom Shader 0 Answers