Search Unity

Question Gradient Parameter

Discussion in 'Shader Graph' started by Horus_Sungod42, Jun 2, 2020.

  1. Horus_Sungod42

    Horus_Sungod42

    Joined:
    Oct 30, 2014
    Posts:
    99
    Hello, simple question:

    when creating a gradient parameter in the shadergraph, the Exposed checkmark remains grayed out and the gradient does not appear in the material.

    Are gradient parameters simply not functional?

    Thank you.
     
  2. alexanderameye

    alexanderameye

    Joined:
    Nov 27, 2013
    Posts:
    1,383
    You can't have exposed gradients and it's not coming anytime soon afaik
     
  3. Horus_Sungod42

    Horus_Sungod42

    Joined:
    Oct 30, 2014
    Posts:
    99
    Thanks for the reply. Too bad, it could be useful.
     
  4. namynnac

    namynnac

    Joined:
    Jun 4, 2020
    Posts:
    9
    HI. How make a gradient without gradient. Im trying lerp but lerp take only two colors
     
  5. Qriva

    Qriva

    Joined:
    Jun 30, 2019
    Posts:
    1,314
    I think the easy way is to sample gradient texture. Create image in gimp/photoshop or other program - it can be even 1 pixel wide and just sample it from 0-1.
     
  6. Horus_Sungod42

    Horus_Sungod42

    Joined:
    Oct 30, 2014
    Posts:
    99
    This is how I made it: the bottom saturate is the 0-1 value that I would use to sample my gradient, then I have a bunch of comparisons and branches. Meaning the output will be one of the 5 colors depending on where between 0 and 1 that initial value is.

    This is done to make random tree colors, depending on their position.
    grad.jpg

    I didn't want to sample a gradient texture, simply because I want to be able to change the colors precisely in Unity.
     
    namynnac likes this.
  7. Horus_Sungod42

    Horus_Sungod42

    Joined:
    Oct 30, 2014
    Posts:
    99
    I changed the "branches" for "lerps" in the final version of the shader. Instead of logic gates comparisons, I simply remap the value to create a sharp black and white mask.