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

Add renderer state defines to shader preprocessor #98549

Merged
merged 1 commit into from
Nov 10, 2024

Conversation

Chaosus
Copy link
Member

@Chaosus Chaosus commented Oct 26, 2024

Closes godotengine/godot-proposals#10764

implements 4 built-in defines to shader preprocessor:

  • CURRENT_RENDERER is either 0, 1, 2 (depends on current renderer)
  • RENDERER_COMPATIBILITY is 0
  • RENDERER_MOBILE is 1
  • RENDERER_FORWARD_PLUS is 2

Using it is simple:

изображение

@Chaosus Chaosus requested a review from a team as a code owner October 26, 2024 09:35
@Chaosus Chaosus added this to the 4.4 milestone Oct 26, 2024
@Chaosus Chaosus force-pushed the shader_renderer_states branch 2 times, most recently from 2a697ec to c061093 Compare October 26, 2024 09:51
@Chaosus Chaosus force-pushed the shader_renderer_states branch from c061093 to e021076 Compare October 26, 2024 10:50
@lostminds
Copy link

Could this perhaps be extended to include a couple of renderer feature support flags based on current renderer (see godotengine/godot-proposals#6207) and not just current renderer? For me instance uniform support FEATURE_INSTANCE_UNIFORMS would be the only example I'm interested in. But maybe there are other features that are only available in some renderers that could benefit from such feature flags as well?

The use case would be similar to the idea behind this PR as I understand it, as well as the logic and place to add it I think. But such feature flags would allow shaders to adapt and start using features as support is added in the engine without the developer needing to keep track of what is supported in each renderer/shader type and change their shader code.

@clayjohn
Copy link
Member

clayjohn commented Nov 2, 2024

Could this perhaps be extended to include a couple of renderer feature support flags based on current renderer (see godotengine/godot-proposals#6207) and not just current renderer? For me instance uniform support FEATURE_INSTANCE_UNIFORMS would be the only example I'm interested in. But maybe there are other features that are only available in some renderers that could benefit from such feature flags as well?

The use case would be similar to the idea behind this PR as I understand it, as well as the logic and place to add it I think. But such feature flags would allow shaders to adapt and start using features as support is added in the engine without the developer needing to keep track of what is supported in each renderer/shader type and change their shader code.

I think that's an interesting idea, but is way out of scope for this PR.

As for instance uniforms, they are fully supported in all rendering backends now. So there should be no need for a flag

@clayjohn
Copy link
Member

clayjohn commented Nov 5, 2024

Looks good, we should make a corresponding docs PR before merging.

@tetrapod00
Copy link
Contributor

I created the docs PR: godotengine/godot-docs#10231.

@clayjohn clayjohn self-requested a review November 8, 2024 20:45
@Repiteo Repiteo merged commit 9dfb36c into godotengine:master Nov 10, 2024
20 checks passed
@Repiteo
Copy link
Contributor

Repiteo commented Nov 10, 2024

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a shader preprocessor #define for the renderer (Compatibility, Forward+, or Mobile)
5 participants