-
-
Notifications
You must be signed in to change notification settings - Fork 18.7k
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
[WIP] Move visual shaders to a module #64596
base: master
Are you sure you want to change the base?
Conversation
df252c5
to
8968c39
Compare
8968c39
to
a4ddcda
Compare
Thank you @aaronfranke ! |
@QbieShay It will not crash, the class will simply be unavailable. In the console it will print |
a4ddcda
to
6b86c95
Compare
#ifdef MODULE_VISUAL_SHADER_ENABLED | ||
Ref<VisualShader> vs = es.shader; | ||
if (vs.is_valid()) { | ||
es.visual_shader_editor = memnew(VisualShaderEditor); | ||
shader_tabs->add_child(es.visual_shader_editor); | ||
es.visual_shader_editor->edit(vs.ptr()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should likely be refactored further so that such hacks are not needed. A module should be modular and thus self-contained (sometimes it's not possible and we do allow hacks like this occasionally, but this needs to be assessed).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Basically, if we want VisualShader to be a module, it should have the same relationship to the ShaderEditor and (script) Shader as VisualScript has to the ScriptEditor and GDScript.
There are no uses of MODULE_VISUAL_SCRIPT_ENABLED
anywhere in the editor code, everything is self-contained. There are a few references by String though which are allowed:
$ rg '"VisualScript"'
editor_node.cpp
2306: if (main_plugin->get_name() == "Script" && !current_obj->is_class("VisualScript") && current_res && !current_res->is_built_in() && (bool(EditorSettings::get_singleton()->get("text_editor/external/use_external_editor")) || overrides_external_editor(current_obj))) {
editor_asset_installer.cpp
122: extension_guess["vs"] = tree->get_theme_icon(SNAME("VisualScript"), SNAME("EditorIcons"));
translations/de.po
17338:msgstr "VisualScript"
plugins/script_editor_plugin.cpp
2270: !p_resource->is_class("VisualScript")) {
2369: if (!p_resource->is_class("VisualScript")) {
#ifdef MODULE_VISUAL_SHADER_ENABLED | ||
SHADER_TYPE_VISUAL, | ||
#endif // MODULE_VISUAL_SHADER_ENABLED |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is problematic as it may break compatibility. Does this ShaderType
get saved to some scene/resource files?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, it's only used in the shader create dialog.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But doesn't it remember the selected value for future runs? If so, the selected value might change (similarly to what happens when using C# in the script create dialog and then switching to a non-Mono build). It may not be a big deal though, unless you have SHADER_TYPE_INC
selected in a build with VisualShader, and then when you open in a build without VisualShader this becomes SHADER_TYPE_MAX
and throws an error.
6b86c95
to
1025348
Compare
1025348
to
da125ea
Compare
da125ea
to
9052cde
Compare
Do not merge yet! I will make other PRs that better abstract this code, so that it doesn't have to be as hacky. This one needs to be merged first: #65276
This PR moves visual shaders to a module. I have three reasons for doing this: