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.
Adds CREST_ prefix to keywords to align with downstream. Also adds a material upgrader (the bulk of the work) to upgrade materials for users similar to SRP packages.
Let me know what you think.
Examples
There are a couple of approaches here which we can use all or only some.
Custom Shader GUI to upgrade one material:
InitializeOnLoadMethod and MenuItem("Edit/Crest/Upgrade Materials"):
How It Works
Checks the data stored in the asset to see whether any of the old m_Float properties exist. Then it inserts the new property if needed, copies the value over, does the same for the m_ShaderKeywords property, and deletes the old property. Finally, it saves the asset.
Trying to get data from the m_Floats was tough since it is an array of pairs. Would have been nice if it could have been deserialised as a dictionary.
Possible Issues
If the user decides to bypass the upgrade, they could try to fix the material themselves by using the inspector like normal. And then if they were to run the upgrade later it would overwrite what they have since the old properties would still be there.
There is also the issue of whether we want to continue using the old names at some point for something else (if we decide to keep this code around).
I believe both issues could be solved with the following:
It could simplify the checking too since we would just check for the serialised version.
Testing
I have committed any upgraded materials so you can try it for yourself. I have only add the prefix to four keywords: caustics, shadows, foam and flow.