Repository navigation
urp: Ship the shader variants the material resolver needs - #30
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_featurekeywords (surface type, mask map, normal map, emission, planar mapping). A build only compiles theshader_featurevariants 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 (_Metallicis 0), so a missing_METALLICSPECGLOSSMAPvariant turned them into white dielectrics. Before,_Metallicheld the profile's metallic and hid the stripped variant.Fix.
VpeUrpResolverVariants.shadervariantsin 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.