Skip to content

Commit

Permalink
shader override handling workaround
Browse files Browse the repository at this point in the history
  • Loading branch information
Xtarsia committed Sep 27, 2024
1 parent ac4b2e2 commit 489a96e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/shaders/editor_functions.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ R"(


//INSERT: EDITOR_COMPATIBILITY_DEFINES
// Compatibility overrides
// COMPATIBILITY_DEFINES
// This is added automatically when in compatibility mode. It is not required for Mobile or Forward+
#define fma(a, b, c) (a) * (b) + (c)
#define dFdxCoarse(a) dFdx(a)
#define dFdyCoarse(a) dFdy(a)
Expand Down
6 changes: 5 additions & 1 deletion src/terrain_3d_material.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ String Terrain3DMaterial::_inject_editor_code(const String &p_shader) const {
// Insert at the very begining
idx = 0;
insert_names.clear();
if (_compatibility) {
if (_compatibility && !shader.contains("COMPATIBILITY_DEFINES")) {
insert_names.push_back("EDITOR_COMPATIBILITY_DEFINES");
}
for (int i = 0; i < insert_names.size(); i++) {
Expand Down Expand Up @@ -253,6 +253,10 @@ void Terrain3DMaterial::_update_shader() {
if (_shader_override->get_code().is_empty()) {
_shader_override->set_code(_generate_shader_code());
}
//
if (_compatibility && !_shader_override->get_code().contains("COMPATIBILITY_DEFINES")) {
_shader_override->set_code(_shader_override->get_code().insert(0, _shader_code["EDITOR_COMPATIBILITY_DEFINES"]));
}
code = _shader_override->get_code();
if (!_shader_override->is_connected("changed", callable_mp(this, &Terrain3DMaterial::_update_shader))) {
LOG(DEBUG, "Connecting changed signal to _update_shader()");
Expand Down

0 comments on commit 489a96e

Please sign in to comment.