1
\$\begingroup\$

I'm building an FPS with fog and I want to include a dynamic minimap, showing the locations of player and enemies in real time.
This is utilized by a second camera which is orthographic and looks at the scene from above.

In the minimap, I don't want to see the fog of course. I've hidden other things from the minimap by using layers and culling masks, however the fog does not belong into any specific layer.

So, how do I disable the fog on just one (or some) camera?

\$\endgroup\$

1 Answer 1

5
\$\begingroup\$

The way to solve this is by disabling the global fog just before the rendering process of the camera and re-enable it immediately afterwards.

TL;DR - attach the following script to the camera you wish to exclude from the fog

using UnityEngine; public class NoFog : MonoBehaviour { bool doWeHaveFogInScene; private void Start() { doWeHaveFogInScene = RenderSettings.fog; } private void OnPreRender() { RenderSettings.fog = false; } private void OnPostRender() { RenderSettings.fog = doWeHaveFogInScene; } } 
\$\endgroup\$

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.