Search Unity

Question Having trouble with ShaderGraph properties in Android build

Discussion in 'Shader Graph' started by kwchang, Feb 18, 2021.

  1. kwchang

    kwchang

    Joined:
    Apr 27, 2016
    Posts:
    2
    Can someone please help me with this? Something weird happens while using properties in ShaderGraph

    As you can see in the screenshot below, there are two exposed Vector3 properties in this shaderGraph
    Second property (reference name '_bbbb') is connected to Albedo of PBR Master



    A material of this shader is set to a sphere in the scene, and there is a script attached to this sphere
    below is the script; just setting (0, 1, 0) to the property of reference name '_bbbb'

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.UI;
    5.  
    6. public class PropertyTest : MonoBehaviour
    7. {
    8.     public Text log;
    9.  
    10.     private void Start()
    11.     {
    12.         Material mat = GetComponent<MeshRenderer>().material;
    13.  
    14.         mat.SetVector("_bbbb", new Vector3(0, 1, 0));
    15.  
    16.         log.text += "\n_bbbb : " + mat.GetVector("_bbbb");
    17.     }
    18. }
    19.  

    I was expecting the sphere color turn into green, and it works nice in the editor



    However, when I build this scene in Android, I get the result below

    it seems like (0, 0, 1) is injected to '_bbbb' property instead of (0, 1, 0),
    but log says result of mat.GetVector("_bbbb") is (0, 1, 0)

    When '_aaaa' property is connected to Albedo, it works fine.
    Also, if I turn off 'Exposed' value of one property, it works fine.
    Only when two properties are both exposed, second property shows wrong values

    I just want to know what the reason is
    am I doing something wrong or missing something? or is this a bug?
    I use OpenGLES3 for Graphics API


    P.S.
    Is there a tool that I can use for ShaderGraph debugging?
    At first this was a critical bug of my project while changing from built-in RP to URP,
    and it was so difficult and took a long time in finding actual root of the bug.
    I wish that I could have some tools which show me node values while runtime, especially in Android build.