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 a project setting for the Shader editor to warn/error as if using the gl_compatibility renderer #6177

Open
clayjohn opened this issue Jan 26, 2023 · 2 comments
Milestone

Comments

@clayjohn
Copy link
Member

Describe the project you are working on

The Godot Engine

Describe the problem or limitation you are having in your project

We flag shader functions as high-end (only usable from RD backends) or low end (can be used in any backend). If a user writes a shader and includes a high-end function while using the gl_compatibility renderer, the shader editor will provide an error and explain that the function is not supported.

The issue arises for users who develop using an RD-based backend (Forward+ or Mobile) and then export using gl_compatibility (for example if the export to web). The error in that case will arise in the exported project but not in the editor.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

I suggest that we add a project setting like emulate_low_end that make the shader compiler provide errors as if it were using a low end renderer. That way users can author their shaders in a way that will be supported on all devices regardless of what renderer they have selected while authoring.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

We could implement it by changing this line:
https://github.com/godotengine/godot/blob/44c0bfc94d81e758b39a8ee43df5915d64200ed6/servers/rendering/shader_language.cpp#L3093
to:

if (RenderingServer::get_singleton()->is_low_end() || emulate_low_end ) {

emulate_low_end would be a variable that is set based on the project setting.

If this enhancement will not be used often, can it be worked around with a few lines of script?

No

Is there a reason why this should be core and not an add-on in the asset library?

It requires core changes

@clayjohn clayjohn added this to the 4.x milestone Jan 26, 2023
@lostminds
Copy link

I think this could be helpful for cases like those discussed in godotengine/godot#72016 . However, emulate_low_end sounds to me like it would not just show warnings about unsupported features. Perhaps it could be called something more descriptive like shader_editor_show_low_end_compatibility_warnings if that's what it will actually do?

Even better would be if these warnings could also include hints on how to make fallbacks (like making an instance uniform a constant) if possible for the shader in gl_compatibility mode to make it compile there while still keeping the advanced feature in use when supported.

@Zireael07
Copy link

show_low_end_warnings would imho be the compromise name that would not be too wordy (unlike what @lostminds proposed) and better reflect what happens in editor.

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

No branches or pull requests

3 participants