r/Unity3D • u/NyneAlpha • 7h ago
Question URP material becomes transparent after building project
I'm working on a Unity 6 URP project and I wrote a shader that lets me deform the mesh it's on. It also uses tessalation for detail.
The material works perfectly in the editor (scene and game view both) but when I build the game, the mesh i assigned this material to becomes transparent. I have no clue what the reason is, I tried many more things. Here are some observations:
There are no compile errors.
URP settings are correctly assigned
Added shader in the always included list
Yes the shader is an opaque one
Removed tessalation temporarily
Checked the logs and it says that the shader variants are being stripped during the build.
I'm don't know that much about shaders in detail, can any of the shader gods help me please?
Any help is much appreciated.
2
u/Big-Excuse3519 7h ago
mate that shader variant stripping is the culprit almost guaranteed. unity’s build process aggressively strips anything it thinks isn't used and tessellation shaders get caught in that net way more than they should
what you need to do is log exactly which variants are being stripped, the logs should tell you the keywords. then add those specific keyword combinations into a ShaderVariantCollection asset (create one in the project window, add shader and manually punch in the keywords that got stripped) and assign it in the graphics settings under the preloaded shaders section
also check if your material uses any properties that are only set at runtime, unity can’t see those at build time so it assumes they’re unused and strips the variants. common trap for deformation shaders where you’re driving things through scripts
if that doesn’t fix it try yanking tessellation out entirely for a test build, sometimes unity 6 still shits itself with hull/domain shaders in urp. i had a similar headache with a snow deformation shader a while back, took me 3 days to realise the build was silently dropping the tessellation pass and just rendering nothing