Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

what does "saturate" mean???

Discussion in 'Shaders' started by JohnSonLi, Sep 5, 2012.

  1. JohnSonLi

    JohnSonLi

    Joined:
    Apr 15, 2012
    Posts:
    586
    void surf (Input IN, inout SurfaceOutput o) {
    o.Albedo = tex2D (_MainTex, IN.uv_MainTex).rgb;
    o.Normal = UnpackNormal (tex2D (_BumpMap, IN.uv_BumpMap));
    half rim = 1.0 - saturate(dot (normalize(IN.viewDir), o.Normal));
    o.Emission = _RimColor.rgb * pow (rim, _RimPower);
    }

    what does it mean?????...where can I find its and other built-in mathmatic operation in Unity mannul??
     
  2. tomvds

    tomvds

    Joined:
    Oct 10, 2008
    Posts:
    1,028
    AxPetre and trul like this.
  3. Farfarer

    Farfarer

    Joined:
    Aug 17, 2010
    Posts:
    2,249
    It clamps the value so that it is never larger than 1.0 and never smaller than 0.0.

    It's not a function Unity created, it's part of the CG shader language.
     
    AxPetre and laurentlavigne like this.
  4. JohnSonLi

    JohnSonLi

    Joined:
    Apr 15, 2012
    Posts:
    586
    thanks a lot....
     
  5. Yanger_xy

    Yanger_xy

    Joined:
    Dec 4, 2010
    Posts:
    7
    That's what i need.
    Thank you!
     
  6. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    anyone know how to average two values? i can't find a function that does this!
     
  7. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    (col1 + col2) * 0.5 ?

    Or lerp with 0.5