diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2022-07-25 14:56:06 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-25 14:56:06 +0200 |
commit | 49b0aa93e3b21bef5974b41ee336d495d615abea (patch) | |
tree | 421c7e16675cbddc37a012118f04c67d2a930a04 /editor | |
parent | 679633f50538f615dab70c070402970fef298a6c (diff) | |
parent | be3fb7a2161535fd84f199e406e3b41a8bc85064 (diff) |
Merge pull request #63424 from Chaosus/shader_preprocessor_inc_fix
Diffstat (limited to 'editor')
-rw-r--r-- | editor/plugins/shader_editor_plugin.cpp | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/editor/plugins/shader_editor_plugin.cpp b/editor/plugins/shader_editor_plugin.cpp index 303b52c495..bdf566e991 100644 --- a/editor/plugins/shader_editor_plugin.cpp +++ b/editor/plugins/shader_editor_plugin.cpp @@ -208,7 +208,30 @@ void ShaderTextEditor::_load_theme_settings() { // to distinguish from keywords at a quick glance. List<String> built_ins; - if (shader.is_valid()) { + + if (shader_inc.is_valid()) { + for (int i = 0; i < RenderingServer::SHADER_MAX; i++) { + for (const KeyValue<StringName, ShaderLanguage::FunctionInfo> &E : ShaderTypes::get_singleton()->get_functions(RenderingServer::ShaderMode(i))) { + for (const KeyValue<StringName, ShaderLanguage::BuiltInInfo> &F : E.value.built_ins) { + built_ins.push_back(F.key); + } + } + + const Vector<ShaderLanguage::ModeInfo> &modes = ShaderTypes::get_singleton()->get_modes(RenderingServer::ShaderMode(i)); + + for (int j = 0; j < modes.size(); j++) { + const ShaderLanguage::ModeInfo &info = modes[j]; + + if (!info.options.is_empty()) { + for (int k = 0; k < info.options.size(); k++) { + built_ins.push_back(String(info.name) + "_" + String(info.options[k])); + } + } else { + built_ins.push_back(String(info.name)); + } + } + } + } else if (shader.is_valid()) { for (const KeyValue<StringName, ShaderLanguage::FunctionInfo> &E : ShaderTypes::get_singleton()->get_functions(RenderingServer::ShaderMode(shader->get_mode()))) { for (const KeyValue<StringName, ShaderLanguage::BuiltInInfo> &F : E.value.built_ins) { built_ins.push_back(F.key); @@ -337,11 +360,10 @@ void ShaderTextEditor::_code_complete_script(const String &p_code, List<ScriptLa ShaderLanguage::ShaderCompileInfo info; info.global_variable_type_func = _get_global_variable_type; - Ref<ShaderInclude> inc = shader_inc; if (shader.is_null()) { info.is_include = true; - sl.complete(p_code, info, r_options, calltip); + sl.complete(code, info, r_options, calltip); get_text_editor()->set_code_hint(calltip); return; } @@ -350,7 +372,7 @@ void ShaderTextEditor::_code_complete_script(const String &p_code, List<ScriptLa info.render_modes = ShaderTypes::get_singleton()->get_modes(RenderingServer::ShaderMode(shader->get_mode())); info.shader_types = ShaderTypes::get_singleton()->get_types(); - sl.complete(p_code, info, r_options, calltip); + sl.complete(code, info, r_options, calltip); get_text_editor()->set_code_hint(calltip); } |