Fire ‘shader:generate’ when a shader code gets generated #5524
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.
The event
shader:generate
is fired on the GraphicsDevice when the shader definition is generated, just before the shader is compiled, to allow the user to inspect / modify the generated shader. Note that there is a further processing happening after this step, where defines are process (unused code is removed), a shader is converted to uniform format on some platforms (currently on WebGPU) and similar.Typical use case:
This is the expected output, in this case the shader is compiled for a shadow pass and a forward pass. You can find relevant info in the `info.shaderPassInfo'. Note that there could be multiple shader compilations based on material settings / vertex format it's used on and similar.