diff options
author | Yuri Roubinsky <chaosus89@gmail.com> | 2020-01-27 12:17:06 +0300 |
---|---|---|
committer | Yuri Roubinsky <chaosus89@gmail.com> | 2020-01-27 12:17:06 +0300 |
commit | 4445f892d2f87c234568d960370b186bb89ca200 (patch) | |
tree | 05adf1421b3418eb695d951b7f2b007c07e5fafc | |
parent | f76009bbcf4140495a37a7350a953799b2f70094 (diff) |
Fix VisualShaderNodeCubeMap generation
-rw-r--r-- | scene/resources/visual_shader_nodes.cpp | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/scene/resources/visual_shader_nodes.cpp b/scene/resources/visual_shader_nodes.cpp index 225274a5fe..ba58c02e3b 100644 --- a/scene/resources/visual_shader_nodes.cpp +++ b/scene/resources/visual_shader_nodes.cpp @@ -792,7 +792,7 @@ String VisualShaderNodeCubeMap::generate_global(Shader::Mode p_mode, VisualShade case TYPE_COLOR: u += " : hint_albedo"; break; case TYPE_NORMALMAP: u += " : hint_normal"; break; } - return u + ";"; + return u + ";\n"; } return String(); } @@ -809,29 +809,32 @@ String VisualShaderNodeCubeMap::generate_code(Shader::Mode p_mode, VisualShader: return String(); } + code += "\t{\n"; + if (id == String()) { - code += "\tvec4 " + id + "_read = vec4(0.0);\n"; - code += "\t" + p_output_vars[0] + " = " + id + "_read.rgb;\n"; - code += "\t" + p_output_vars[1] + " = " + id + "_read.a;\n"; + code += "\t\tvec4 " + id + "_read = vec4(0.0);\n"; + code += "\t\t" + p_output_vars[0] + " = " + id + "_read.rgb;\n"; + code += "\t\t" + p_output_vars[1] + " = " + id + "_read.a;\n"; return code; } if (p_input_vars[0] == String()) { // Use UV by default. if (p_input_vars[1] == String()) { - code += "\tvec4 " + id + "_read = texture( " + id + " , vec3( UV, 0.0 ) );\n"; + code += "\t\tvec4 " + id + "_read = texture( " + id + " , vec3( UV, 0.0 ) );\n"; } else { - code += "\tvec4 " + id + "_read = textureLod( " + id + " , vec3( UV, 0.0 )" + " , " + p_input_vars[1] + " );\n"; + code += "\t\tvec4 " + id + "_read = textureLod( " + id + " , vec3( UV, 0.0 )" + " , " + p_input_vars[1] + " );\n"; } } else if (p_input_vars[1] == String()) { //no lod - code += "\tvec4 " + id + "_read = texture( " + id + " , " + p_input_vars[0] + " );\n"; + code += "\t\tvec4 " + id + "_read = texture( " + id + " , " + p_input_vars[0] + " );\n"; } else { - code += "\tvec4 " + id + "_read = textureLod( " + id + " , " + p_input_vars[0] + " , " + p_input_vars[1] + " );\n"; + code += "\t\tvec4 " + id + "_read = textureLod( " + id + " , " + p_input_vars[0] + " , " + p_input_vars[1] + " );\n"; } - code += "\t" + p_output_vars[0] + " = " + id + "_read.rgb;\n"; - code += "\t" + p_output_vars[1] + " = " + id + "_read.a;\n"; + code += "\t\t" + p_output_vars[0] + " = " + id + "_read.rgb;\n"; + code += "\t\t" + p_output_vars[1] + " = " + id + "_read.a;\n"; + code += "\t}\n"; return code; } |