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
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
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- Articulation Body with 'Revolute' Joint Type has erratic behavior when Upper Limit is set to above 360
- WebGL Player fails to render Scene when Terrain with Detail Mesh is added and WebGPU Graphics API is used
- Inconsistent errors are logged when different types are passed into the Query "Q<>" method in UIToolkit and the ancestor VisualElement is null
- Crash on GetMaterialPropertyByIndex when opening a specific Scene
- Discrepancies in the styling are present when using a TSS file instead of a USS file in custom EditorWindow
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.