Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question UIVertex (normals) and ShaderGraph

Discussion in 'General Graphics' started by FissicsPeep, Dec 19, 2021.

  1. FissicsPeep

    FissicsPeep

    Joined:
    Jan 14, 2014
    Posts:
    65
    Hi,

    I'm pulling my hair out on this one. I've created a custom mesh for UI, by deriving from the Graphic class and overriding OnPopulateMesh(vh) in the usual manner. This works and I see my triangles. However, what I'm trying to do is modify the vertex positions in URP ShaderGraph, by setting the UIVertex normals when I generate my custom mesh: (these are UIVertex's)



    However, what I'm seeing in the shader is that these normals are being reset somehow and are effectively pointing to the centre of the canvas...



    I visualized this by converting the normals to colour...



    I should be seeing random colours as per my code. Does anybody know what is going on here? Does the ShaderGraph have to be a very specific type for UI (currently it is a sprite unlit)? Is it not possible to get the normals I set via ShaderGraph? Is this UIVertex specific perhaps?

    Secondary question - Is Sprite Unlit the right type? I'd rather not use that as it always blends - whereas I just want a solid, non-blended mesh.

    Thanks in advance!
     
  2. FissicsPeep

    FissicsPeep

    Joined:
    Jan 14, 2014
    Posts:
    65
    Update: I tried putting the values into uv0 instead, and it works - I get my random values coming through and can modify the vertex positions in the shader...

    My guess is the VertexHelper, Graphic or UI code is somehow recalculating the normals and that there's no way to suppress that behaviour from script? Seems like an oversight?
     
  3. FissicsPeep

    FissicsPeep

    Joined:
    Jan 14, 2014
    Posts:
    65
    I'm also noticing uv1 values on the UIVertex are not coming through to a Sprite Unlit ShaderGraph. Is this a URP issue? Wrong graph type?