Fog / no minimap icons

Nothing appeared on my minimap. This was due to fog being on:
Window->Rendering->Lighting
Environment Tab->Other Settings
Fog checkbox

Another way is to reduce the minimap camera height from 50 to 10.

However, I quite like the fog. When we start zooming out it will add some ambience. It doesn’t belong on the minimap though. The only way I could find was to turn off RenderSettings.fog during rendering. Something like:

using UnityEngine;
using UnityEngine.Rendering;

public class NoFog : MonoBehaviour
{
    bool fog;

    private void Start()
    {
        fog = RenderSettings.fog;
        RenderPipelineManager.beginCameraRendering += RenderPipelineManager_beginCameraRendering;
        RenderPipelineManager.endCameraRendering += RenderPipelineManager_endCameraRendering;
    }

    private void OnDestroy()
    {
        RenderPipelineManager.beginCameraRendering -= RenderPipelineManager_beginCameraRendering;
        RenderPipelineManager.endCameraRendering -= RenderPipelineManager_endCameraRendering;
    }

    private void RenderPipelineManager_beginCameraRendering(ScriptableRenderContext arg1, Camera arg2)
    {
        if(arg2.gameObject == gameObject)
        {
            RenderSettings.fog = false;
        }
    }

    private void RenderPipelineManager_endCameraRendering(ScriptableRenderContext arg1, Camera arg2)
    {
        if (arg2.gameObject == gameObject)
        {
            RenderSettings.fog = fog;
        }
    }

}

And then put this on the minimap camera gameobject. You might have OnPreRender and OnPostRender, but in my version, 2021.2.1f1, these didn’t seem to be called.

4 Likes

Privacy & Terms