diff --git a/addons/material_maker/engine/multi_renderer.gd b/addons/material_maker/engine/multi_renderer.gd index 2dd38f902..c6f688274 100644 --- a/addons/material_maker/engine/multi_renderer.gd +++ b/addons/material_maker/engine/multi_renderer.gd @@ -27,12 +27,7 @@ signal free_rendering_device func _ready() -> void: shader_error_handler = load("res://addons/material_maker/engine/shader_error_handler.gd").new() - common_shader = "varying float elapsed_time; - -void vertex() { - elapsed_time = TIME; -} -" + common_shader = "varying float elapsed_time;\nvoid vertex() {\n\telapsed_time = TIME;\n}\n" common_shader += preload("res://addons/material_maker/shader_functions.tres").text for i in total_renderers: var renderer = preload("res://addons/material_maker/engine/renderer.tscn").instantiate() diff --git a/material_maker/nodes/debug/debug_popup.gd b/material_maker/nodes/debug/debug_popup.gd index 879199244..097b16c3d 100644 --- a/material_maker/nodes/debug/debug_popup.gd +++ b/material_maker/nodes/debug/debug_popup.gd @@ -30,7 +30,7 @@ func generate_shadertoy() -> String: code += mm_renderer.common_shader code += "\n" code = code.replace("varying float elapsed_time;", "") - code = code.replace("void vertex() {\n\telapsed_time = TIME;\n}\n", "") + code = code.replace("void vertex() {\n\telapsed_time = TIME;\n}", "") code += src_code.uniforms_as_strings("const", true) code += "\n" code += src_code.get_globals_string(src_code.defs+src_code.code) @@ -43,7 +43,7 @@ func generate_shadertoy() -> String: code += "vec2 UV = vec2(0.0, 1.0) + vec2(1.0, -1.0) * (fragCoord-0.5*(iResolution.xy-vec2(minSize)))/minSize;\n" code += src_code.code if src_code.output_values.has("rgba"): - code += "fragColor = "+src_code.output_values.rgba+";\n" + code += "fragColor = vec4(mix(vec3(0.5), "+src_code.output_values.rgba+".rgb, "+src_code.output_values.rgba+".a), 1.0);\n" else: code += "fragColor = vec4(1.0, 0.0, 0.0, 1.0);\n" code += "}\n" @@ -56,7 +56,7 @@ func generate_godot_canvasitem() -> String: var code = "shader_type canvas_item;\n" code += "const float seed_variation = 0.0;\n" code += mm_renderer.common_shader - code += src_code.uniforms_as_strings() + code += src_code.uniforms_as_strings("uniform", true) code += "\n" code += src_code.get_globals_string(src_code.defs+src_code.code) code += src_code.defs @@ -78,7 +78,7 @@ func generate_godot_spatial() -> String: code += "\nconst float seed_variation = 0.0;\n" code += mm_renderer.common_shader code += "\n" - code += src_code.uniforms_as_strings() + code += src_code.uniforms_as_strings("uniform", true) code += "\n" code += src_code.get_globals_string(src_code.defs+src_code.code) code += src_code.defs