Search Unity

URP/Shader bug: multiple objects use same sprite would result in wrong vertex position

Discussion in 'General Graphics' started by filod, Nov 20, 2020.

  1. filod

    filod

    Joined:
    Oct 3, 2015
    Posts:
    152
    my sprite shader is very simple, just change scale of object position.x:
    upload_2020-11-20_12-8-55.png

    when i use mutiple objects in the scene, vertext position seems use a world position rather that object:
    upload_2020-11-20_12-14-29.png
    when i deactive test sprite 1, test sprite 2 find its place:
    upload_2020-11-20_12-16-59.png

    ----------- update ------------
    i found a solution is that change SpriteRenderer's Rendering Layer Mask to make sure it's different among objects, here is how i deal with it:
    Code (CSharp):
    1. GetComponent<SpriteRenderer>().renderingLayerMask = (uint)GetHashCode();
     

    Attached Files:

    Last edited: Nov 20, 2020
unityunity