Search Unity

Disable Fog for one camera

Discussion in 'Universal Render Pipeline' started by BlakeSchreurs, Mar 4, 2021.

  1. BlakeSchreurs

    BlakeSchreurs

    Joined:
    Aug 10, 2016
    Posts:
    51
    I would like to turn off fog for a single camera in my URP scene (rendering to a RenderTexture).

    I've found ways to do this in Builtin pipeline... I think I have a good idea of how to do it on HDRP... But URP is a bit different:.. The fog's under Lighting-> Environment instead of being part of the RenderSettings or in a post process volume. I've tried a bunch of searches, but I feel like I don't know what terms to use.

    Any help is greatly apprecaited!
     
  2. revolute

    revolute

    Joined:
    Jul 28, 2014
    Posts:
    50
    You can use
    UnityEngine.Rendering.RenderPipelineManager.beginCameraRendering
    event to get camera render events.
    Swap fog settings in
    beginCameraRendering
    , revert it in
    endCameraRendering
    .

    If you want specific camera, I would attach such script on a camera and compare it to the current camera for equality.

    Like this:
    void BeginCameraRendering( ScriptableRenderContext src, Camera cam )

    if( myCam == cam ) ...
     
    CosmicMenace likes this.
  3. BlakeSchreurs

    BlakeSchreurs

    Joined:
    Aug 10, 2016
    Posts:
    51
    Thank you for your help! How does one change the fog setting in beginCameraRendering or endCameraRendering? I don't see anything labeled as fog, lighting, or environment settings, and I can't find an environment settings asset similar to the lighting settings.
     
  4. revolute

    revolute

    Joined:
    Jul 28, 2014
    Posts:
    50
    RenderSettings.fog
    to toggle fog on/off. Practically everything that are in "Lighting" settings can be found in
    RenderSettings
    .