Search Unity

(Solved) expentional normalization for expentional fog

Discussion in 'Scripting' started by Utopien, Jul 11, 2019.

  1. Utopien

    Utopien

    Joined:
    Feb 15, 2016
    Posts:
    46
    hello community i try to set fog value on expentional by distance to ground i have normalize 0 to 1 with my max distance and min distance to get lerp value of the fog density


    float _normalizedFloat = (_curValue - _min) / (_max -_min);



    but it is linear

    any idée on how i can change my to be normalize expentionally ?


    thanks for any help....
     
  2. jvo3dc

    jvo3dc

    Joined:
    Oct 11, 2013
    Posts:
    1,520
    Because you mention exponential, it sounds like you want to calculate the correct physical fog transparency. But that doesn't match up with the mentioning of "distance to ground". The way to calculate fog transparency based on distance through fog of a given density is:

    Code (csharp):
    1.  
    2. float transparency = Mathf.Exp(-density * distance);
    3.  
    The fog opacity/density would then be 1 - transparency.

    Offtopic: I'm guessing you are French.
     
    Utopien likes this.
  3. Utopien

    Utopien

    Joined:
    Feb 15, 2016
    Posts:
    46

    you guessed wisely ^^ thanks for your reply i will try this right a away et merci ....
     
  4. Utopien

    Utopien

    Joined:
    Feb 15, 2016
    Posts:
    46
    fog transparensy dont do the trick what i need is to be able to
    normalize expentionally or lerp expentionally
     
  5. jvo3dc

    jvo3dc

    Joined:
    Oct 11, 2013
    Posts:
    1,520
    Well, you lerp based on the transparancy, which is exponential based on the distance. What do you have now and how does it look?
     
    Utopien likes this.
  6. Utopien

    Utopien

    Joined:
    Feb 15, 2016
    Posts:
    46

    found a solution i put the fog in linear mode and liked the endfordistance to my player distance to ground