Search Issue Tracker
By Design
Votes
8
Found in [Package]
10.0.0-preview.27
Issue ID
1307861
Regression
Yes
Material is rendered black when switching from Shader Graph to HDRP or URP Shader during runtime in the Build
How to reproduce:
1. Open the user's attached "ShaderChangeBug" project
2. Open the Build Settings (File->Build Settings...)
3. Make sure that the "Scene" is in the Scenes In Build list
4. Build And Run
5. Press space twice
Expected results: The bushes are the same color they were before pressing space
Actual results: The bushes are solid black in color
Reproducible with: 10.0.0-preview.27 (2020.2.0b5), 10.2.2 (2020.2.2f1), 11.0.0 (2021.1.0b3, 2021.2.0a3)
Not reproducible with: 4.10.0-preview (2018.4.31f1), 7.5.2 (2019.4.19f1), 8.3.1 (2020.1.17f1), 9.0.0-preview.71 (2020.2.0b5)
Notes:
- The issue has been tested and reproduced on Windows 10
- Reproducible with URP and HDRP, sometimes the material might turn pink instead of black
-
mkrmediauk
Jan 21, 2021 13:24
please fix this, it is so annoying!
-
IrishJohnGaming
Jan 21, 2021 13:21
Yes Please!
-
aylinibryamov1
Jan 21, 2021 11:51
Can you please fix this bug asap thanks :)
-
ianch8w
Jan 21, 2021 11:48
Please fix this issue asap. thx
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
- Recent search window can't be closed
- Tab on empty search doesn't pop up the recent search window any more
- Image effect shaders with RenderGraphUtils.FullScreenGeometryType.Mesh render incorrectly when using the RenderGraph
- Search window Shortcuts are not functioning when certain areas of the window are focused
- Interface property is not shown in the Inspector when the null value is chosen while using the CustomPropertyDrawer attribute with the generic Object class
Resolution Note:
Think I figured out the issue.
It's because you are using Shader.Find(...) to find the shader, which isn't guaranteed to work in a player. I think in practice it only works if the Shader happends to be loaded.
I think what is happening is as soon as you replace all of the HDRP/lit shaders in the scene with ShaderGraph shaders, then the HDRP/lit shader is not referenced by anything and is free to be unloaded, or at least unload some important bits of the shader.
If you simply keep around a reference to HDRP/lit in one of your scripts, it will keep it from being unloaded. And probably better to skip using Shader.Find outside of editor scripts. For this use case you could have each script store off the original shader and restore it, which keeps the reference alive.
Let us know if this doesn't work for you.