Search Unity

Fog on multiple cameras

Discussion in 'Image Effects' started by vmp1r3, Jun 20, 2019.

  1. vmp1r3

    vmp1r3

    Joined:
    Jun 15, 2015
    Posts:
    6
    Hello, I'm using LWRP to use Shader Graph.
    I have 2 cameras in my scene, rendering at the same time.
    And I have Fog enabled in my scene.

    The question is: Is it possible to disable fog for one camera but keep it in another?

    I've found this script on internet, but it's not working for me now.


    Code (CSharp):
    1. using UnityEngine;
    2.  
    3. public sealed class CameraFogController : MonoBehaviour
    4. {
    5.     private bool _globalFogEnabled;
    6.  
    7.     private void Start()
    8.     {
    9.         _globalFogEnabled = RenderSettings.fog;
    10.     }
    11.  
    12.     private void OnPreRender()
    13.     {
    14.         RenderSettings.fog = false;
    15.     }
    16.  
    17.     private void OnPostRender()
    18.     {
    19.         RenderSettings.fog = _globalFogEnabled;
    20.     }
    21. }
    22.  
    Should I move to HDRP and use Shader Graph there, or there are options to fix this?