Hey there,
I have set up two ways of rendering a fog of war for my game. Both work (mostly), but with none of whom i am currently able to achieve everything i want.
Both use a PostProcessMaterial, which takes the absolute world position as UVs for a texture containing the information which areas to reveal.
The first one uses a RenderTarget that units draw a circle on, like in this tutorial video i found: https://www.youtube.com/watch?v=It_HmGaTTPU (Fig. 1 + Fig. 5)
The seccond one uses a Texture2D which pixels i write manually from c++ (Fig. 2 + Fig. 4)
The problem i am facing with the RenderTarget aproach is that previously visited areas get these sharp edges, the longer a unit stands at the same location. Since the draw method is additive even the outer most corners become a value of 1.f eventually, resulting in no smooth transition anymore. (Fig. 3)
This could be solved if i could apply the max value of previous and current pixel color instead of adding the values with the additive material that draws the circle to my RenderTarget. But i can not find a setting to make this happen.
In my Texture2D i could easily do this, but for some reason the Texture2D always gets rendered with sharp edges, even tho the resolution of the RenderTargen and the Texture2D are the same (which you can see in Fig. 3 as well).
Can anyone explain to me why this is?
Thanks in advance for any inputs, that brings me closer to solving this issue.
If you have any question or need further information, feel free to ask me.
Side note:
I prefer the RenderTarget solution a bit, since the computation of the areas to reveal is done on the GPU, but in the end i take what works.




