Search Unity

Dynamically setting a boolean property on a material using a Shader Graph generated shader

Discussion in 'Shaders' started by D43DB33F, Nov 23, 2019.

  1. D43DB33F

    D43DB33F

    Joined:
    Apr 6, 2017
    Posts:
    43
    Hi !

    I have created a shader using the shader graph that is based on the standard shader and extends it to make an object look selected and / or hovered based on two properties of type boolean.

    The manual says that boolean properties are treated as floats. Thus, when I want to set one of these boolean properties, I naturally use Material.setFloat(). However, this does not seem to work.

    My boolean properties are nammed "Hovered" and "Selected". I tried with and without prefixing them with an underscore, but got the same result.

    So my question is : am I using the right way to set those boolean properties ?

    Also another tiny question : is there a way to combine the use of the shader graph and GPU instancing ?

    Thanks !!

    EDIT : I tried with an integer property and Material.setInt(), but still no change.
     
    Last edited: Nov 23, 2019
  2. D43DB33F

    D43DB33F

    Joined:
    Apr 6, 2017
    Posts:
    43
  3. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,352
    You have to use the reference name, which the Blackboard auto generates when you create a property, but which you can override if you want it called something else.
     
    D43DB33F likes this.
  4. D43DB33F

    D43DB33F

    Joined:
    Apr 6, 2017
    Posts:
    43
    Thanks for your help, as usual. :)