diff options
author | Yuri Rubinsky <chaosus89@gmail.com> | 2023-01-28 09:54:41 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-28 09:54:41 +0300 |
commit | 2afa175195d0fc885badb60441bef1b31e5e6d05 (patch) | |
tree | 6b797d7d15e06ac36f910c0c765365672c261a44 /scene/resources/shader_include.cpp | |
parent | a43db5afa4bbec4772be2f296931a6d44bb4cbb3 (diff) | |
parent | 0acaccebaf3b1dc6445f8a100a1011b89faa4216 (diff) | |
download | redot-engine-2afa175195d0fc885badb60441bef1b31e5e6d05.tar.gz |
Merge pull request #72174 from bitsawer/shader_include_fixes
Close undefined
Fix undefined
Diffstat (limited to 'scene/resources/shader_include.cpp')
-rw-r--r-- | scene/resources/shader_include.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/scene/resources/shader_include.cpp b/scene/resources/shader_include.cpp index cd5e9861f7..68137cbec0 100644 --- a/scene/resources/shader_include.cpp +++ b/scene/resources/shader_include.cpp @@ -45,9 +45,14 @@ void ShaderInclude::set_code(const String &p_code) { } { + String path = get_path(); + if (path.is_empty()) { + path = include_path; + } + String pp_code; ShaderPreprocessor preprocessor; - preprocessor.preprocess(p_code, "", pp_code, nullptr, nullptr, nullptr, &new_dependencies); + preprocessor.preprocess(p_code, path, pp_code, nullptr, nullptr, nullptr, &new_dependencies); } // This ensures previous include resources are not freed and then re-loaded during parse (which would make compiling slower) @@ -64,6 +69,10 @@ String ShaderInclude::get_code() const { return code; } +void ShaderInclude::set_include_path(const String &p_path) { + include_path = p_path; +} + void ShaderInclude::_bind_methods() { ClassDB::bind_method(D_METHOD("set_code", "code"), &ShaderInclude::set_code); ClassDB::bind_method(D_METHOD("get_code"), &ShaderInclude::get_code); @@ -86,6 +95,7 @@ Ref<Resource> ResourceFormatLoaderShaderInclude::load(const String &p_path, cons String str; str.parse_utf8((const char *)buffer.ptr(), buffer.size()); + shader_inc->set_include_path(p_path); shader_inc->set_code(str); if (r_error) { |