Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

how do I set HDRP "Fog Attentuation Distance" by script?

Discussion in 'High Definition Render Pipeline' started by Nowak_ITK, Nov 13, 2020.

  1. Nowak_ITK

    Nowak_ITK

    Joined:
    Oct 2, 2020
    Posts:
    2
    Hi,

    in our Project we are using HDRP 7.1.8 and want to set the Fog Attenuation Distance dynamically by script. See also: https://docs.unity3d.com/Packages/c....high-definition@7.1/manual/Override-Fog.html

    Until now we got the following working:

    Code (CSharp):
    1. public Volume volume;
    2. ...
    3. Fog fog;
    4. volume.profile.TryGet(out fog);
    5. fog.enabled.value = interface.fogVolumetricOn;
    6. fog.baseHeight.value = interface.fogBaseHeight;
    7. fog.maximumHeight.value = interface.fogMaximumHeight;
    How can I set the "Fog Attentuation Distance" in a similar way? The Fog class doesn't seem to provide a variable with that name.
     
  2. DrSeltsam

    DrSeltsam

    Joined:
    Jul 24, 2019
    Posts:
    100
    The "Fog Attenuation Distance" is called "meanFreePath" in code (at least in HDRP 8), so you could change it like this:
    Code (CSharp):
    1. fog.meanFreePath.value = ...
     
  3. Nowak_ITK

    Nowak_ITK

    Joined:
    Oct 2, 2020
    Posts:
    2
    Thanks :) I wasn't aware of that alias. It works on HDRP 7.1.8, too.
     
  4. cecarlsen

    cecarlsen

    Joined:
    Jun 30, 2006
    Posts:
    858
    Just wasted time trying to find an answer on this as well. Inconsistencies in UI and API like this ruin the user experience. I hope the HDRP team will fix it.
     
    koirat and chap-unity like this.
  5. LumaPxxx

    LumaPxxx

    Joined:
    Oct 3, 2010
    Posts:
    340
    Agreed with cecarlsen.
    HDRP api is a mess.
    the way to use a volume system in coding is not even a traditional component thing.
    why????
     
    KhoolWasHereIsPog likes this.
  6. cecarlsen

    cecarlsen

    Joined:
    Jun 30, 2006
    Posts:
    858
    I just wasted time on this once again. Please fix.
     
    Marou1 likes this.
  7. Marou1

    Marou1

    Joined:
    Dec 13, 2021
    Posts:
    161
    Same waste of time here...