Added shader variant (multi-compile) system#466
Merged
adriengivry merged 12 commits intomainfrom Apr 30, 2025
Merged
Conversation
litelawliet
approved these changes
Apr 30, 2025
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.
Description
#feature FEATURE_NAMEin a shader code.Each possible variant gets compiled (2^n, with n being the feature count: how many times #feature is used in a single shader).
#includedirective parsing by preventing commented includes (i.e. `// #include "...") from being evaluated. Instead of checking if a line "contains" a directive, we now trim the line, and checks if it starts with the directive (safer)AssetBrowserto enable logging temporarily (when a manual compilation is requested by the user).Limitations
ShaderandShaderLoaderto enable the multi-compile feature. Some additional work needs to be done at the material level to expose these features in the editor, and use them when a material is bound.#include) cannot be added/excluded from a variant using#ifdef)Additional notes
The current system is similar to what unity describes as
shader_feature:https://docs.unity3d.com/Manual/SL-MultipleProgramVariants-declare.html