Refactor of private ShaderPass class to be dynamic instead of hardcoded #5256
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.
In the past, a shader pass ids were hardcoded, for example forward, depth, pick, and a whole list of them for combinations of light type and shadow type. The Editor also uses hardcoded number, which was limiting what can be done in the engine (separate PR to address). The shader pass dictates a shader needed for the pass - each pass generates a new shader for its specific requirements.
In order to make the engine more flexible, this has been now changed to a dynamic solution, where renderers can request shader creation for any number of passes. This will allow is to easily add debug rendering ('render albedo, render normal' ..).
For each shader pass, a new define is added to a shader, allowing per pass customization, i.e:
Each shader pass created can have additional options to be attached, to be used by the generator.
There will be a separate follow up PR taking advantage of this to implement some debug rendering.
Note that few shader passes related to public constants commonly used are pre-created to guarantee their order matches the constants:
Example logging of shader pass creation logging when rendering shadows for few different light types.