Search Issue Tracker

By Design

Votes

0

Found in

2018.3.0f1

2018.3.12f1

2019.1.0a1

2019.2.0a1

Issue ID

1146255

Regression

No

Custom diffuse shader breaks when duplicating Sprites with said shader

Shaders

-

Reproduction steps:
1. Open the attached project named "Case_1146255"
2. Open the Scene "A-Single(OK) and observe a shadow on the bottom left side of the sprite
3. Duplicate the sprite

Expected result: Sprites behave the same way after duplicating
Actual result: The shadow starts spinning with the sprite

Reproducible with: 2018.3.13f1, 2019.1.0f2, 2019.2.0a12
Could not test with: 2018.3.0b12 and below due to the project crashing or throwing errors

Notes:
If "Enable GPU Instancing" in Shader settings is enabled before duplicating the sprite, the issue does not appear

  1. Resolution Note:

    When you have multiple instances of the same sprite in a scene, the built-in dynamic batching for Sprite Render will automatically take effect. When that happens, all geometry will be transformed into world space, and “object space” will be lost. This behavior is incompatible with how you sample object space normal from the lookup texture.

    As for why opening the two sample scenes together makes everything work again, it's because you have one directional light in each of the scenes, and having multiple lights breaks the automatic dynamic batching.

    All the behaviors described here are intentional design decisions of Unity's built-in render pipeline, so we won't make any changes to fix your shader. However, as a workaround, you can explicitly disable dynamic batching for your shader by adding "DisableBatching"="True" to the list of SubShader tags. For more information on this topic, see "DisableBatching tag" section of https://docs.unity3d.com/Manual/SL-SubShaderTags.html.

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.