Skip to content

Add renderer state defines to shader preprocessor#98549

Merged
Repiteo merged 1 commit into
godotengine:masterfrom
Chaosus:shader_renderer_states
Nov 10, 2024
Merged

Add renderer state defines to shader preprocessor#98549
Repiteo merged 1 commit into
godotengine:masterfrom
Chaosus:shader_renderer_states

Conversation

@Chaosus

@Chaosus Chaosus commented Oct 26, 2024

Copy link
Copy Markdown
Member

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
Copy Markdown

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

clayjohn commented Nov 2, 2024

Copy link
Copy Markdown
Member

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

clayjohn commented Nov 5, 2024

Copy link
Copy Markdown
Member

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

@tetrapod00

Copy link
Copy Markdown
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
@Repiteo

Repiteo commented Nov 10, 2024

Copy link
Copy Markdown
Contributor

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