diff options
author | Yuri Roubinski <chaosus89@gmail.com> | 2019-08-20 19:34:09 +0300 |
---|---|---|
committer | Yuri Roubinski <chaosus89@gmail.com> | 2019-08-20 19:34:09 +0300 |
commit | 1e3fb6d760b0b209ddbde189eab9698015212720 (patch) | |
tree | 0312d49b41655842ec9b91f82bb3f9f8e6649e20 /scene/resources | |
parent | cce148b0242836b5c32a7fa6c39013a2fc1c9eff (diff) |
Fix preview for global expressions in visual shaders
Diffstat (limited to 'scene/resources')
-rw-r--r-- | scene/resources/visual_shader.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/scene/resources/visual_shader.cpp b/scene/resources/visual_shader.cpp index f7d7c2d1bc..08ce47692c 100644 --- a/scene/resources/visual_shader.cpp +++ b/scene/resources/visual_shader.cpp @@ -612,6 +612,25 @@ String VisualShader::generate_preview_shader(Type p_type, int p_node, int p_port global_code += String() + "shader_type canvas_item;\n"; + String global_expressions; + for (int i = 0, index = 0; i < TYPE_MAX; i++) { + for (Map<int, Node>::Element *E = graph[i].nodes.front(); E; E = E->next()) { + Ref<VisualShaderNodeGlobalExpression> global_expression = Object::cast_to<VisualShaderNodeGlobalExpression>(E->get().node.ptr()); + if (global_expression.is_valid()) { + + String expr = ""; + expr += "// " + global_expression->get_caption() + ":" + itos(index++) + "\n"; + expr += global_expression->generate_global(get_mode(), Type(i), -1); + expr = expr.replace("\n", "\n\t"); + expr += "\n"; + global_expressions += expr; + } + } + } + + global_code += "\n"; + global_code += global_expressions; + //make it faster to go around through shader VMap<ConnectionKey, const List<Connection>::Element *> input_connections; VMap<ConnectionKey, const List<Connection>::Element *> output_connections; |