Search Issue Tracker

Won't Fix

Votes

0

Found in [Package]

14.0.8

15.0.6

16.0.2

Issue ID

SGB-609

Regression

No

[Shader Graph] Custom shader's vertices does not fit Sprite when scaling up SpriteRenderer

Package: Shader Graph

-

Reproduction steps:
1. Open the attached project "ReproProj"
2. Open the “/Assets/SampleScene.unity” Scene
3. In Hierarchy select “Broken scale 4“ GameObject
4. Zoom in and out in the Scene View window

Expected result: Vertices of the Sprite always fits Sprite when zoomed in and out
Actual result: Vertices of the Sprite do not fit Sprite when zoomed out as seen in Repro.gif

Reproducible with: 13.0.0 (2022.1.0a11), 14.0.8 (2022.3.4f1), 15.0.6 (2023.1.3f1), 16.0.2 (2023.2.0a21)
Could not test with: 12.1.12 (2021.3.27f1, 2022.1.0a10) (Could not test due to vertices not being rendered)

Reproduces on: Windows 10 Enterprise 21H2

Notes:
- The SpriteRenderer uses a material with a custom shader (made with a shader graph). The shader modifies the vertices of the sprite
- Issue reproduces when the Sprite is scaled up
- Implemented a quick fix by multiplying/dividing the result of the vertex modification by the object's bounds size. With this quick fix, the issue seems to be "resolved" in the Game view. However, a new issue appears where sometimes the sprites do not appear in the Scene view

  1. Resolution Note:

    The reporter's error project wasn't attached to the issue correctly, so I can't reproduce or inspect the user's project (please feel free to reopen the issue if you feel it's appropriate). However, I think I know what's going on here.

    The sprite renderer takes much more liberties with geometry, so you probably shouldn't do vertex manipulation in the shader as there is no way for the sprite renderer to accommodate those modifications (since they don't actually result in any changes to the geometry, just how they are rendered on screen).

    While you can accommodate for the math, if you wanted it to work in scene and game view, you'd need to incorporate special handling for each case.

    Whatever effect you're trying to achieve, I highly recommend not using scale and vertex manipulation together, particularly non-uniform and particularly with sprites.

    It's likely there is a fragment-only solution to the effect you want to achieve, provided your mesh/sprite is large enough (has the appropriate padding) to accommodate the space you need.

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.