Added shader variant (multi-compile) system #466
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_NAME
in 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).
#include
directive 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)AssetBrowser
to enable logging temporarily (when a manual compilation is requested by the user).Limitations
Shader
andShaderLoader
to 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