Search Unity

Question Implicit truncation of vector type (that wont go away)

Discussion in 'Shader Graph' started by undertow, Feb 18, 2020.

  1. undertow

    undertow

    Joined:
    Nov 25, 2013
    Posts:
    5
    I get that "implicit truncation of vector type" with some shader graph HDRP shaders made in 2019.1, except that warning only shows up in other versions of unity (LWRP and 2019.3 any) not the one theyre made in.

    I try edited the graph in one of the unity versions that will actually give me that warning, but nothing i do changes the error list on the shader. I tried disabling various inputs, splitting and combing vectors that are auto dropped down in the graph...
    even after emptying out a graph it would give me those same errors/warnings. How does that work?!

    Is the shader graph just bugged? Do i not need to worry about that warning? My materials all seemed to work fine.
     
  2. garett_recroom

    garett_recroom

    Joined:
    Apr 8, 2020
    Posts:
    6
    It looks like a bug in shader graph generated code here:

    Code (CSharp):
    1.  
    2. VertexDescriptionInputs BuildVertexDescriptionInputs(Attributes input)
    3. {
    4.     VertexDescriptionInputs output;
    5.     ZERO_INITIALIZE(VertexDescriptionInputs, output);
    6.                
    7.     output.ObjectSpaceNormal =           input.normalOS;
    8.     output.ObjectSpaceTangent =          input.tangentOS; // truncation: float3 = float4
    9.     output.ObjectSpacePosition =         input.positionOS;
    10.                
    11.     return output;
    12. }
    13.  
     
  3. garett_recroom

    garett_recroom

    Joined:
    Apr 8, 2020
    Posts:
    6
    I suggest the Unity team make the following change. I can't figure out where in the packages this code is generated, or I would fix it myself locally. IIRC, these "implicit truncation" warnings can be errors on some platforms, e.g. GLES3 backends.

    Code (CSharp):
    1. VertexDescriptionInputs BuildVertexDescriptionInputs(Attributes input)
    2. {
    3.     VertexDescriptionInputs output;
    4.     ZERO_INITIALIZE(VertexDescriptionInputs, output);
    5.              
    6.     output.ObjectSpaceNormal =           input.normalOS;
    7.     output.ObjectSpaceTangent =          input.tangentOS.xyz; // float3 = float4.xyz
    8.     output.ObjectSpacePosition =         input.positionOS;
    9.              
    10.     return output;
    11. }
     
  4. garett_recroom

    garett_recroom

    Joined:
    Apr 8, 2020
    Posts:
    6
    Also, I'm very curious how they recover the correct bitangent without tangentOS.w
     
  5. garettbass

    garettbass

    Joined:
    Nov 24, 2017
    Posts:
    1