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

Implement a feature/variant system for materials #341

Open
adriengivry opened this issue Nov 29, 2024 · 0 comments
Open

Implement a feature/variant system for materials #341

adriengivry opened this issue Nov 29, 2024 · 0 comments
Labels
Feature New feature to the engine Graphics Graphical feature Optimization Optimization related stuff

Comments

@adriengivry
Copy link
Owner

adriengivry commented Nov 29, 2024

Problem this feature should address
Our current material/shader system is quite limited. In many cases, we rely on booleans (int 0/1) to control branching in the shader code. While some of these booleans could be resolved at compilation time (e.g., toggling features through the material editor), the current implementation always resolves them at runtime by sending a uniform value.

Expected solution
We should implement a system to create shader variants, where a single instance of the Shader class can manage multiple underlying programs. Variants would represent a predefined set of feature toggles.

Feature Count Variants
0 2^0 = 1
1 2^1 = 2
2 2^2 = 4
3 2^3 = 8

Pre-compiled shader programs would significantly improve runtime performance by eliminating the need for branching.

@adriengivry adriengivry added Feature New feature to the engine Optimization Optimization related stuff Graphics Graphical feature labels Nov 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature New feature to the engine Graphics Graphical feature Optimization Optimization related stuff
Projects
None yet
Development

No branches or pull requests

1 participant