Search Unity

Resolved Boolean Property supported in Material Override? (Use float property in shader instead of boolean)

Discussion in 'Graphics for ECS' started by CodeWiesel, Jan 3, 2023.

  1. CodeWiesel

    CodeWiesel

    Joined:
    Jun 1, 2022
    Posts:
    4
    Hey guys
    I have a question/problem regarding Material Overrides and I am not sure if this is supposed to be working or not:

    Edit: URP, Entities Graphics 1.0.0-pre.15, Unity Version 2022.2.1f1.112.6257

    I am looking into shaders and tried to create a simple "Selected"-Shader:
    upload_2023-1-3_13-23-14.png

    I created a material override for the 3 parameters. upload_2023-1-3_13-27-27.png
    If I change the towercolor, it works in scene and game view
    If I change the towerselected flag, it only works in scene view...

    Are boolean Properties not supported or am I doing something wrong?
    If I set Towerselected to 1 and run it, it is applied correctly in the Entities Hierarchy window and updates the scene window, but not in the game...
    But the overriden towercolor property is applied correctly to the game...
    upload_2023-1-3_13-25-58.png

    Left side is the game running, right side is the scene view (both with towerselected = 1):
    upload_2023-1-3_13-31-12.png

    Thanks for your time :)
     
  2. charleshendry

    charleshendry

    Joined:
    Jan 7, 2018
    Posts:
    98
    Boolean properties are treated as floats, so you'll have to pass a float and then do a true/false check for say <0.5f.
     
  3. CodeWiesel

    CodeWiesel

    Joined:
    Jun 1, 2022
    Posts:
    4
    Thanks for your reply Charles, the override value is set to 1 in the Entities Hierarchy window.
    upload_2023-1-5_11-52-39.png
     
  4. CodeWiesel

    CodeWiesel

    Joined:
    Jun 1, 2022
    Posts:
    4
    You led me on the right track, it works if I use a float instead of a boolean property in the shader.
    upload_2023-1-5_12-36-28.png
     
    JussiKnuuttila and charleshendry like this.