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
- Crash on mono_get_hazardous_pointer when running Play Mode tests in a specific project
- [iOS] ‘확인’(Done) and '취소'(Cancel) text is displayed as '...' in the on-screen keyboard when the System preferred language is set to Korean
- [Usability] No warnings when creating the selector with the duplicate name
- [sw-unity-6-1] Shadergraph panning area size is constant regardless of the size or the zoom level
- [Android] Arabic characters are not displayed when the font falls back to the OS font
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.