diff --git a/drivers/gles2/shader_compiler_gles2.cpp b/drivers/gles2/shader_compiler_gles2.cpp index 6c07a8918d5..6ab5d7129a7 100644 --- a/drivers/gles2/shader_compiler_gles2.cpp +++ b/drivers/gles2/shader_compiler_gles2.cpp @@ -368,14 +368,14 @@ String ShaderCompilerGLES2::_dump_node_code(SL::Node *p_node, int p_level, Gener // constants - for (Map::Element *E = snode->constants.front(); E; E = E->next()) { + for (int i = 0; i < snode->vconstants.size(); i++) { String gcode; gcode += "const "; - gcode += _prestr(E->get().precision); - gcode += _typestr(E->get().type); - gcode += " " + _mkid(E->key()); + gcode += _prestr(snode->vconstants[i].precision); + gcode += _typestr(snode->vconstants[i].type); + gcode += " " + _mkid(String(snode->vconstants[i].name)); gcode += "="; - gcode += _dump_node_code(E->get().initializer, p_level, r_gen_code, p_actions, p_default_actions, p_assigning); + gcode += _dump_node_code(snode->vconstants[i].initializer, p_level, r_gen_code, p_actions, p_default_actions, p_assigning); gcode += ";\n"; vertex_global += gcode; fragment_global += gcode; diff --git a/drivers/gles3/shader_compiler_gles3.cpp b/drivers/gles3/shader_compiler_gles3.cpp index 1bf0d3ddcee..5ae4d4bcff3 100644 --- a/drivers/gles3/shader_compiler_gles3.cpp +++ b/drivers/gles3/shader_compiler_gles3.cpp @@ -440,14 +440,14 @@ String ShaderCompilerGLES3::_dump_node_code(SL::Node *p_node, int p_level, Gener r_gen_code.fragment_global += interp_mode + "in " + vcode; } - for (Map::Element *E = pnode->constants.front(); E; E = E->next()) { + for (int i = 0; i < pnode->vconstants.size(); i++) { String gcode; gcode += "const "; - gcode += _prestr(E->get().precision); - gcode += _typestr(E->get().type); - gcode += " " + _mkid(E->key()); + gcode += _prestr(pnode->vconstants[i].precision); + gcode += _typestr(pnode->vconstants[i].type); + gcode += " " + _mkid(String(pnode->vconstants[i].name)); gcode += "="; - gcode += _dump_node_code(E->get().initializer, p_level, r_gen_code, p_actions, p_default_actions, p_assigning); + gcode += _dump_node_code(pnode->vconstants[i].initializer, p_level, r_gen_code, p_actions, p_default_actions, p_assigning); gcode += ";\n"; r_gen_code.vertex_global += gcode; r_gen_code.fragment_global += gcode; diff --git a/servers/visual/shader_language.cpp b/servers/visual/shader_language.cpp index 809901d9924..f02d886bf8a 100644 --- a/servers/visual/shader_language.cpp +++ b/servers/visual/shader_language.cpp @@ -5156,6 +5156,7 @@ Error ShaderLanguage::_parse_shader(const Map &p_funct while (true) { ShaderNode::Constant constant; + constant.name = name; constant.type = type; constant.precision = precision; constant.initializer = NULL; @@ -5190,6 +5191,8 @@ Error ShaderLanguage::_parse_shader(const Map &p_funct } shader->constants[name] = constant; + shader->vconstants.push_back(constant); + if (tk.type == TK_COMMA) { tk = _get_token(); if (tk.type != TK_IDENTIFIER) { diff --git a/servers/visual/shader_language.h b/servers/visual/shader_language.h index 852101f435b..35f4a8b1b0f 100644 --- a/servers/visual/shader_language.h +++ b/servers/visual/shader_language.h @@ -512,6 +512,7 @@ public: struct ShaderNode : public Node { struct Constant { + StringName name; DataType type; DataPrecision precision; ConstantNode *initializer; @@ -577,6 +578,7 @@ public: Vector render_modes; Vector functions; + Vector vconstants; ShaderNode() : Node(TYPE_SHADER) {}