Search Issue Tracker
Won't Fix
Votes
0
Found in
2021.3.40f1
2022.3.37f1
6000.0.10f1
6000.0.15f1
Issue ID
UUM-75751
Regression
No
GameObject Alpha Clipping does not work when a ShaderGraph Material is assigned during runtime
How to reproduce:
1. Open the “Material.zip“ project
2. Open the “SampleScene“
3. Observe the Plane GameObject in the Game view
4. Enter Play Mode
5. Press the Enter key
6. Observe the Plane GameObject in the Game view
Expected result: The Plane GameObject is still Alpha Clipped
Actual result: The Plane GameObject is not Alpha Clipped anymore
Reproducible in: 2021.3.40f1, 2022.3.37f1, 6000.0.10f1
Reproduced on: Windows 11 Pro (23H2)
Not reproduced on: No other environment tested
Note: Reproducible in the Player
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
- Opening Terrain Prefab in Prefab Editing Mode throws "NullReferenceException" error
- [Search] Dragging query pills put them behind the search text field
- A CustomPropertyDrawer that returns a PropertyField for a property named the same as a child field will not render all child fields
- Graphics Settings shows default values instead of the real values in the Rendering Debugger when Volume.profile is assigned via script
- Deleting multiple Tags throws “NullReferenceException”, and "Retrieving array element that was out of bounds" errors when holding the Enter key
Resolution Note:
I was able to reproduce the issue locally. It's a known limitation of the Material system :
- When you change a Material’s properties in the Inspector, the Render Pipeline sets up properties, keywords, and passes on the Material directly so that it can be rendered correctly.
- When you instantiate a Material in C# (e.g new Material(mShader)), the Keywords are not updated automatically or set. So in this bug report, the Alpha Clipping is not enabled automatically after instantiating the Material.
- To fix it, you need to change a property of the Material from the inspector directly (like the Alpha Clipping one) so the Keywords are updated.
This is not a new limitation, but a pretty old one. We don't have a system, like a callback system, to automatically update the Keywords, since instantiating a Material (with the new keyword) is at the barebone of our system and not something we can overload.
Since this is not a very common case, the workaround for the users would be to manually change the Keywords on the Material after instantiating it, by using EnableKeyword.
HDRP has this custom solution, which is to call the HDRP function ValidateMaterial after instantiating it: https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@15.0/manual/Material-API.html
URP doesn't have an equivalent.