Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor of private ShaderPass class to be dynamic instead of hardcoded #5256

Merged
merged 2 commits into from
Apr 20, 2023

Conversation

mvaligursky
Copy link
Contributor

@mvaligursky mvaligursky commented Apr 20, 2023

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:

  • SHADOW_PASS (existing), but also
  • CUSTOM_PASS (based on 'custom' shader pass name)

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:

        add('depth', SHADER_DEPTH);
        add('pick', SHADER_PICK);
        add('shadow', SHADER_SHADOW);

Example logging of shader pass creation logging when rendering shadows for few different light types.

Screenshot 2023-04-18 at 12 26 18

@mvaligursky mvaligursky self-assigned this Apr 20, 2023
@mvaligursky mvaligursky added the area: graphics Graphics related issue label Apr 20, 2023
@mvaligursky mvaligursky merged commit 664d24a into main Apr 20, 2023
@mvaligursky mvaligursky deleted the mv-shader-pass-refactor branch April 20, 2023 15:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: graphics Graphics related issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants