Skip to content

urp: Ship the shader variants the material resolver needs - #30

Merged
freezy merged 1 commit into
masterfrom
fix/urp-material
Oct 17, 2026
Merged

freezy merged 1 commit into
masterfrom
fix/urp-material

Conversation

@freezy

@freezy freezy commented Oct 17, 2026

Copy link
Copy Markdown
Member

Plastics and metals rendered white in URP player builds (Windows and Linux) while the editor looked right.

Cause. The material resolver builds URP/Lit and triplanar materials at runtime and enables shader_feature keywords (surface type, mask map, normal map, emission, planar mapping). A build only compiles the shader_feature variants used by materials in the build, and none uses most of these, so they were stripped; the triplanar shader's forward pass kept 16 variants. Exposed by d1f5843: plastics use the new triplanar shader, and mask-mapped metals now carry all of their metallic in the mask (_Metallic is 0), so a missing _METALLICSPECGLOSSMAP variant turned them into white dielectrics. Before, _Metallic held the profile's metallic and hid the stripped variant.

Fix. VpeUrpResolverVariants.shadervariants in the package's Resources lists every keyword set the resolver produces (148 variants for URP/Lit and the triplanar shader, forward and shadow caster), generated by VPE > Shaders > Generate URP Resolver Variants. A build preprocessor fails URP player builds when the collection is missing or no longer covers what the generator produces.

Verified with Windows URP builds of T2: master shows the white plastics and metals; master with the collection renders them as in the editor and as a control build from before d1f5843. The first build compiles the new variants (about 5 minutes instead of 30 seconds), later builds use the cache.

The resolver builds URP/Lit and triplanar materials at runtime and switches
shader_feature keywords that no material in a build uses, so builds stripped
those variants. Since mask maps carry all of the metallic and plastics use
the triplanar shader, metals and plastics rendered white in player builds,
while the editor compiled the variants on demand.

A shader variant collection in Resources now lists every keyword set the
resolver produces (VPE > Shaders > Generate URP Resolver Variants), and URP
player builds fail when it's missing or out of date.
@freezy
freezy merged commit 1b27cc1 into master Oct 17, 2026
4 checks passed
@freezy
freezy deleted the fix/urp-material branch October 17, 2026 14:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant