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
- Frame Debugger is not disabled when switching Scenes if the Frame Debugger window is not open during the transition
- Standalone Profiler Targets another Project if a Standalone Profiler was launched in it before when switching between Edit or Play Mode Targets
- Crash on ForwardRenderLoopJob when opening a specific project
- [Android] Memory leak and eventual crash on Snapdragon 8 Gen 1+ devices when a Clear Pass is executed after Framebuffer Fetch
- PhysicsRaycaster ray length is incorrect when casting from rotated Camera
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.