diff --git a/addons/material_maker/engine/multi_renderer.gd b/addons/material_maker/engine/multi_renderer.gd index ca4c33ac6..1a49067d8 100644 --- a/addons/material_maker/engine/multi_renderer.gd +++ b/addons/material_maker/engine/multi_renderer.gd @@ -72,6 +72,7 @@ func generate_shader(src_code : MMGenBase.ShaderCode) -> String: shader_code += "\nuniform float variation = 0.0;\n" shader_code += "\nvoid fragment() {\n" shader_code += "float _seed_variation_ = variation;\n" + shader_code += "vec4 _controlled_variation_ = vec4(0.0);\n" shader_code += "vec2 uv = mm_chunk_offset+mm_chunk_size*UV;\n" if src_code.code != "": shader_code += src_code.code diff --git a/addons/material_maker/engine/nodes/buffer_compute.tres b/addons/material_maker/engine/nodes/buffer_compute.tres index d2e46ca20..ffeae39c6 100644 --- a/addons/material_maker/engine/nodes/buffer_compute.tres +++ b/addons/material_maker/engine/nodes/buffer_compute.tres @@ -27,6 +27,7 @@ const float seed_variation = 0.0; void main() { float _seed_variation_ = seed_variation; + vec4 _controlled_variation_ = vec4(0.0); vec2 pixel = gl_GlobalInvocationID.xy+vec2(0.5, 0.5+mm_chunk_y); vec2 image_size = imageSize(OUTPUT_TEXTURE); vec2 uv = pixel/image_size; diff --git a/addons/material_maker/engine/nodes/gen_base.gd b/addons/material_maker/engine/nodes/gen_base.gd index 69c7354a9..1b64cc64f 100644 --- a/addons/material_maker/engine/nodes/gen_base.gd +++ b/addons/material_maker/engine/nodes/gen_base.gd @@ -635,6 +635,22 @@ static func find_matching_parenthesis(string : String, i : int, op : String = '( i = max_p if min_p < 0 else min_p return i +static func split_parameters(string : String) -> Array[String]: + if string[0] != "(" or find_matching_parenthesis(string, 0) != string.length()-1: + print("bad") + return [] + string = string.substr(1, string.length()-2) + var parameters : Array[String] = [] + var p : String = "" + for s in string.split(","): + if p != "": + p += "," + p += s + if p.count("(") == p.count(")") and p.count("[") == p.count("]"): + parameters.append(p.strip_edges()) + p = "" + return parameters + static var re_line_comment : RegEx = RegEx.create_from_string("//.*") static func remove_comments(s : String) -> String: diff --git a/addons/material_maker/engine/nodes/gen_shader.gd b/addons/material_maker/engine/nodes/gen_shader.gd index 31c82b7d2..a5d1ffa75 100644 --- a/addons/material_maker/engine/nodes/gen_shader.gd +++ b/addons/material_maker/engine/nodes/gen_shader.gd @@ -105,11 +105,11 @@ func find_instance_functions(code : String): for r in result: if not r.strings[1] in [ "return" ]: functions.push_back(r.strings[2]); - code = code.replace(r.strings[0], "%s %s(%s, float _seed_variation_) {" % [ r.strings[1], r.strings[2], r.strings[3] ]) + code = code.replace(r.strings[0], "%s %s(%s, float _seed_variation_, vec4 _controlled_variation_) {" % [ r.strings[1], r.strings[2], r.strings[3] ]) return { code=code, functions=functions } func fix_instance_functions(code : String, instance_functions : Array): - var variation_parameter = ", _seed_variation_" + var variation_parameter = ", _seed_variation_, _controlled_variation_" var variation_parameter_length = variation_parameter.length() for f in instance_functions: var location : int = 0 @@ -411,7 +411,7 @@ func find_keyword_call(string : String, keyword : String): print(string) return "#error" -func replace_input_with_function_call(string : String, input : String, seed_parameter : String = ", _seed_variation_", input_suffix : String = "") -> String: +func replace_input_with_function_call(string : String, input : String, seed_parameter : String = ", _seed_variation_, _controlled_variation_", input_suffix : String = "") -> String: var genname = "o"+str(get_instance_id()) while true: var uv : String = find_keyword_call(string, input+input_suffix) @@ -424,8 +424,10 @@ func replace_input_with_function_call(string : String, input : String, seed_para string = string.replace("$%s(%s)" % [ input+input_suffix, uv ], "%s_input_%s(%s%s)" % [ genname, input, uv, seed_parameter ]) return string +const WORD_LETTERS : String = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_?" + func is_word_letter(l) -> bool: - return "azertyuiopqsdfghjklmwxcvbnAZERTYUIOPQSDFGHJKLMWXCVBN1234567890_".find(l) != -1 + return WORD_LETTERS.find(l) != -1 func replace_rnd(string : String, offset : int = 0) -> String: while true: @@ -455,8 +457,6 @@ func replace_rndi(string : String, offset : int = 0) -> String: string = string.replace(replace, with) return string -const WORD_LETTERS : String = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_" - func generate_parameter_declarations(rv : ShaderCode) -> void: var genname = "o"+str(get_instance_id()) if has_randomness(): @@ -493,7 +493,7 @@ func generate_input_function(index : int, input: Dictionary, rv : ShaderCode, co rv.add_uniforms(source_rv.uniforms) rv.defs += source_rv.defs rv.add_globals(source_rv.globals) - rv.defs += "%s %s_input_%s(%s, float _seed_variation_) {\n" % [ mm_io_types.types[input.type].type, genname, input.name, mm_io_types.types[input.type].paramdefs ] + rv.defs += "%s %s_input_%s(%s, float _seed_variation_, vec4 _controlled_variation_) {\n" % [ mm_io_types.types[input.type].type, genname, input.name, mm_io_types.types[input.type].paramdefs ] rv.defs += "%s\n" % source_rv.code rv.defs += "return %s;\n}\n" % source_rv.output_values[input.type] @@ -611,9 +611,16 @@ func replace_input(input_name : String, suffix : String, parameters : String, va if input_def.has("function") and input_def.function: var function_name : String = "o%s_input_%s" % [ str(get_instance_id()), input_def.name ] if suffix == "variation": - return function_name+parameters + var parameter_list : Array[String] = split_parameters(parameters) + var parameters_suffix : String = ")" + match parameter_list.size(): + 1: + parameters_suffix = ", _seed_variation_, _controlled_variation_)" + 2: + parameters_suffix = ", _controlled_variation_)" + return function_name+"("+", ".join(split_parameters(parameters))+parameters_suffix else: - return function_name+"("+parameters+", _seed_variation_)" + return function_name+"("+parameters+", _seed_variation_, _controlled_variation_)" var source_rv : ShaderCode = source.generator.get_shader_code(parameters, source.output_index, context) rv.add_uniforms(source_rv.uniforms) rv.defs += source_rv.defs @@ -709,6 +716,10 @@ func get_common_replace_variables(uv : String, rv : ShaderCode) -> Dictionary: variables["seed"] = "seed_"+genname else: variables["seed"] = "(seed_"+genname+"+fract(_seed_variation_))" + variables["?1"] = "_controlled_variation_.x" + variables["?2"] = "_controlled_variation_.y" + variables["?3"] = "_controlled_variation_.z" + variables["?4"] = "_controlled_variation_.w" variables["node_id"] = str(get_instance_id()) return variables diff --git a/addons/material_maker/engine/nodes/iterate_buffer_compute.tres b/addons/material_maker/engine/nodes/iterate_buffer_compute.tres index d09c8a195..f7cb6a6fe 100644 --- a/addons/material_maker/engine/nodes/iterate_buffer_compute.tres +++ b/addons/material_maker/engine/nodes/iterate_buffer_compute.tres @@ -27,6 +27,7 @@ const float seed_variation = 0.0; void main() { float _seed_variation_ = seed_variation; + vec4 _controlled_variation_ = vec4(0.0); vec2 pixel = gl_GlobalInvocationID.xy+vec2(0.5, 0.5+mm_chunk_y); vec2 image_size = imageSize(OUTPUT_TEXTURE); vec2 uv = pixel/image_size; diff --git a/addons/material_maker/nodes/controlled_variations.mmg b/addons/material_maker/nodes/controlled_variations.mmg new file mode 100644 index 000000000..82c03c087 --- /dev/null +++ b/addons/material_maker/nodes/controlled_variations.mmg @@ -0,0 +1,86 @@ +{ + "generic_size": 1, + "name": "controlled_variations", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "v1": 0.5, + "variable": 0.0 + }, + "seed_int": 0, + "shader_model": { + "code": [ + "#for", + "vec4 $(name_uv)_cv_# = _controlled_variation_;", + "$(name_uv)_cv_#.$variable = $v#;", + "#end" + ], + "global": "", + "inputs": [ + { + "default": "1.0", + "function": true, + "label": "", + "longdesc": "The input image", + "name": "in", + "shortdesc": "Input", + "type": "f" + } + ], + "instance": "", + "longdesc": "Generates controlled variations for its input", + "name": "Controlled Variations", + "outputs": [ + { + "f": "$in.variation($uv, _seed_variation_, $(name_uv)_cv_#)", + "longdesc": "Shows a variation of the input", + "shortdesc": "Output1", + "type": "f" + } + ], + "parameters": [ + { + "control": "None", + "default": 0.0, + "label": "", + "longdesc": "Variable value", + "max": 1.0, + "min": 0.0, + "name": "v#", + "shortdesc": "Value", + "step": 0.01, + "type": "float" + }, + { + "default": 0.0, + "label": "Variable", + "longdesc": "Variable name", + "name": "variable", + "shortdesc": "Variable", + "type": "enum", + "values": [ + { + "name": "$?1", + "value": "x" + }, + { + "name": "$?2", + "value": "y" + }, + { + "name": "$?3", + "value": "z" + }, + { + "name": "$?4", + "value": "w" + } + ] + } + ], + "shortdesc": "Controlled Variations" + }, + "type": "shader" +} \ No newline at end of file diff --git a/addons/material_maker/nodes/fbm_variations.mmg b/addons/material_maker/nodes/fbm_variations.mmg new file mode 100644 index 000000000..f43ec8d83 --- /dev/null +++ b/addons/material_maker/nodes/fbm_variations.mmg @@ -0,0 +1,116 @@ +{ + "name": "fbm_variations", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "iterations": 10.0, + "persistance": 0.5, + "randomize": true, + "variable": 0.0 + }, + "seed_int": 0, + "shader_model": { + "code": "", + "global": "", + "inputs": [ + { + "default": "1.0", + "function": true, + "label": "", + "longdesc": "The input image", + "name": "in", + "shortdesc": "Input", + "type": "f" + } + ], + "instance": [ + "float fbm_variations_$(name)(vec2 uv, int iterations, float persistance) {", + "\tfloat v = 0.0;", + "\tfloat keep = 1.0;", + "\tfloat sum = 0.0;", + "\tfloat seedvar = _seed_variation_;", + "\tvec4 var = _controlled_variation_;", + "\tvar.$variable = 1.0;", + "\tfor (int i = 0; i < iterations; i++) {", + "\t\tfloat input_v = $in.variation(uv, seedvar, var);", + "\t\tv += input_v*keep;", + "\t\tif ($randomize) {", + "\t\t\tseedvar = rand(vec2(seedvar,sum));", + "\t\t}", + "\t\tsum += keep;", + "\t\tvar.$variable *= 2.0;", + "\t\tkeep *= persistance;", + "\t}", + "\treturn v/sum;", + "}" + ], + "longdesc": "Combines the octaves of controlled variations for its input", + "name": "FBM Variations", + "outputs": [ + { + "f": "fbm_variations_$(name)($uv, int($iterations), $persistance)", + "longdesc": "Shows a variation of the input", + "shortdesc": "Output1", + "type": "f" + } + ], + "parameters": [ + { + "default": 0.0, + "label": "Variable", + "name": "variable", + "type": "enum", + "values": [ + { + "name": "$?1", + "value": "x" + }, + { + "name": "$?2", + "value": "y" + }, + { + "name": "$?3", + "value": "z" + }, + { + "name": "$?4", + "value": "w" + } + ] + }, + { + "control": "None", + "default": 5.0, + "label": "Iterations", + "longdesc": "Seed modifier for output 1", + "max": 10.0, + "min": 1.0, + "name": "iterations", + "shortdesc": "Seed modifier", + "step": 1.0, + "type": "float" + }, + { + "control": "None", + "default": 0.5, + "label": "Persistance", + "max": 1.0, + "min": 0.0, + "name": "persistance", + "step": 0.01, + "type": "float" + }, + { + "default": true, + "label": "Randomize", + "name": "randomize", + "type": "boolean" + } + ], + "shortdesc": "FBM Variations" + }, + "type": "shader" +} \ No newline at end of file diff --git a/addons/material_maker/nodes/iterate_variations.mmg b/addons/material_maker/nodes/iterate_variations.mmg new file mode 100644 index 000000000..42841f878 --- /dev/null +++ b/addons/material_maker/nodes/iterate_variations.mmg @@ -0,0 +1,163 @@ +{ + "name": "iterate_variations", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "combine": 1.0, + "randomize": false, + "step": 0.1, + "v1": 0.0, + "v2": 1.0, + "variable": 0.0 + }, + "seed_int": 0, + "shader_model": { + "code": "", + "global": "", + "inputs": [ + { + "default": "1.0", + "function": true, + "label": "", + "longdesc": "The input image", + "name": "in", + "shortdesc": "Input", + "type": "f" + } + ], + "instance": [ + "float iterate_variations_$(name)(vec2 uv, float v1, float v2, float step) {", + "\tfloat v = 0.0;", + "\tif (sign(step) == sign(v2-v1)) {", + "\t\tfloat count = 1.0+floor((v2-v1)/step);", + "\t\tfloat seedvar = _seed_variation_;", + "\t\tvec4 var = _controlled_variation_;", + "\t\tvar.$variable = v1;", + "\t\tfloat input_v = $in.variation(uv, _seed_variation_, var);", + "\t\tv = $combine;", + "\t\tfor (float x = v1+step; x < v2; x += step) {", + "\t\t\tvar.$variable = x;", + "\t\t\tinput_v = $in.variation(uv, seedvar, var);", + "\t\t\tv = $combine;", + "\t\t\tif ($randomize) {", + "\t\t\t\tseedvar = rand(vec2(seedvar,x));", + "\t\t\t}", + "\t\t}", + "\t}", + "\treturn v;", + "}" + ], + "longdesc": "Combines controlled variations for its input by iterating on the variable", + "name": "Iterate Variations", + "outputs": [ + { + "f": "iterate_variations_$(name)($uv, $v1, $v2, $step)", + "longdesc": "The output image", + "shortdesc": "Output", + "type": "f" + } + ], + "parameters": [ + { + "default": 0.0, + "label": "Variable", + "longdesc": "Variable name", + "name": "variable", + "shortdesc": "Variable", + "type": "enum", + "values": [ + { + "name": "$?1", + "value": "x" + }, + { + "name": "$?2", + "value": "y" + }, + { + "name": "$?3", + "value": "z" + }, + { + "name": "$?4", + "value": "w" + } + ] + }, + { + "control": "None", + "default": 0.0, + "label": "From", + "longdesc": "Initial value of the variable", + "max": 1.0, + "min": 0.0, + "name": "v1", + "shortdesc": "From", + "step": 0.01, + "type": "float" + }, + { + "control": "None", + "default": 1.0, + "label": "To", + "longdesc": "Maximum value of the variable", + "max": 1.0, + "min": 0.0, + "name": "v2", + "shortdesc": "To", + "step": 0.01, + "type": "float" + }, + { + "control": "None", + "default": 0.1, + "label": "Step", + "longdesc": "Step value when iterating", + "max": 1.0, + "min": 0.0, + "name": "step", + "shortdesc": "Step", + "step": 0.001, + "type": "float" + }, + { + "default": 0.0, + "label": "Combine", + "longdesc": "Operator used to combine iterations (Add, Min, Max or average)", + "name": "combine", + "shortdesc": "Combine", + "type": "enum", + "values": [ + { + "name": "Add", + "value": "v+input_v" + }, + { + "name": "Max", + "value": "max(v, input_v)" + }, + { + "name": "Min", + "value": "min(v, input_v)" + }, + { + "name": "Average", + "value": "v+input_v/count" + } + ] + }, + { + "default": true, + "label": "Randomize", + "longdesc": "Pick different seeds for different variations", + "name": "randomize", + "shortdesc": "Randomize", + "type": "boolean" + } + ], + "shortdesc": "Iterate Variations" + }, + "type": "shader" +} \ No newline at end of file diff --git a/addons/material_maker/nodes/layer_variations.mmg b/addons/material_maker/nodes/layer_variations.mmg new file mode 100644 index 000000000..186e755e4 --- /dev/null +++ b/addons/material_maker/nodes/layer_variations.mmg @@ -0,0 +1,146 @@ +{ + "name": "layer_variations", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "randomize": true, + "step": 0.1, + "v1": 0.0, + "v2": 1.0, + "variable": 0.0 + }, + "seed_int": 0, + "shader_model": { + "code": "", + "global": "", + "inputs": [ + { + "default": "1.0", + "function": true, + "label": "", + "longdesc": "The input image", + "name": "in", + "shortdesc": "Input", + "type": "f" + }, + { + "default": "0.0", + "function": true, + "label": "", + "longdesc": "The input mask", + "name": "mask", + "shortdesc": "Mask", + "type": "f" + } + ], + "instance": [ + "float layer_variations_$(name)(vec2 uv, float v1, float v2, float step) {", + "\tfloat v = 0.0;", + "\tif (sign(step) == sign(v2-v1)) {", + "\t\tfloat count = 1.0+floor((v2-v1)/step);", + "\t\tfloat seedvar = _seed_variation_;", + "\t\tvec4 var = _controlled_variation_;", + "\t\tvar.$variable = v1;", + "\t\tfloat input_v = $in.variation(uv, seedvar, var);", + "\t\tv = input_v;", + "\t\tfor (float x = v1+step; x < v2; x += step) {", + "\t\t\tvar.$variable = x;", + "\t\t\tinput_v = $in.variation(uv, seedvar, var);", + "\t\t\tfloat mask_v = $mask.variation(uv, seedvar, var);", + "\t\t\tv = mix(v, input_v, mask_v);", + "\t\t\tif ($randomize) {", + "\t\t\t\tseedvar = rand(vec2(seedvar,x));", + "\t\t\t}", + "\t\t}", + "\t}", + "\treturn v;", + "}" + ], + "longdesc": "Layers controlled variations for its input using the variations of the mask by iterating on the variable", + "name": "Layer Variations", + "outputs": [ + { + "f": "layer_variations_$(name)($uv, $v1, $v2, $step)", + "longdesc": "Shows a variation of the input", + "shortdesc": "Output1", + "type": "f" + } + ], + "parameters": [ + { + "default": 0.0, + "label": "Variable", + "longdesc": "Variable name", + "name": "variable", + "shortdesc": "Variable", + "type": "enum", + "values": [ + { + "name": "$?1", + "value": "x" + }, + { + "name": "$?2", + "value": "y" + }, + { + "name": "$?3", + "value": "z" + }, + { + "name": "$?4", + "value": "w" + } + ] + }, + { + "control": "None", + "default": 0.0, + "label": "From", + "longdesc": "Initial value of the variable", + "max": 1.0, + "min": 0.0, + "name": "v1", + "shortdesc": "From", + "step": 0.01, + "type": "float" + }, + { + "control": "None", + "default": 1.0, + "label": "To", + "longdesc": "Maximum value of the variable", + "max": 1.0, + "min": 0.0, + "name": "v2", + "shortdesc": "To", + "step": 0.01, + "type": "float" + }, + { + "control": "None", + "default": 0.1, + "label": "Step", + "longdesc": "Step value when iterating", + "max": 1.0, + "min": 0.0, + "name": "step", + "shortdesc": "Step", + "step": 0.001, + "type": "float" + }, + { + "default": true, + "label": "Randomize", + "longdesc": "Pick different seeds for different variations", + "name": "randomize", + "shortdesc": "Randomize", + "type": "boolean" + } + ], + "shortdesc": "Layer Variations" + }, + "type": "shader" +} \ No newline at end of file diff --git a/addons/material_maker/nodes/layer_variations_color.mmg b/addons/material_maker/nodes/layer_variations_color.mmg new file mode 100644 index 000000000..eac47a9e4 --- /dev/null +++ b/addons/material_maker/nodes/layer_variations_color.mmg @@ -0,0 +1,136 @@ +{ + "name": "layer_variations_color", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "randomize": false, + "step": 0.1, + "v1": 0.0, + "v2": 1.0, + "variable": 0.0 + }, + "seed_int": 0, + "shader_model": { + "code": "", + "global": "", + "inputs": [ + { + "default": "1.0", + "function": true, + "label": "", + "longdesc": "The input image", + "name": "in", + "shortdesc": "Input", + "type": "rgba" + } + ], + "instance": [ + "vec4 layer_variations_$(name)(vec2 uv, float v1, float v2, float step) {", + "\tvec4 v = vec4(0.0);", + "\tif (sign(step) == sign(v2-v1)) {", + "\t\tfloat count = 1.0+floor((v2-v1)/step);", + "\t\tfloat seedvar = _seed_variation_;", + "\t\tvec4 var = _controlled_variation_;", + "\t\tvar.$variable = v1;", + "\t\tvec4 input_v = $in.variation(uv, seedvar, var);", + "\t\tv = input_v;", + "\t\tfor (float x = v1+step; x < v2; x += step) {", + "\t\t\tvar.$variable = x;", + "\t\t\tinput_v = $in.variation(uv, seedvar, var);", + "\t\t\tv = vec4(mix(v.rgb, input_v.rgb, input_v.a), min(1.0, input_v.a+v.a));", + "\t\t\tif ($randomize) {", + "\t\t\t\tseedvar = rand(vec2(seedvar,x));", + "\t\t\t}", + "\t\t}", + "\t}", + "\treturn v;", + "}" + ], + "longdesc": "Layers controlled variations for its input using the variations of the mask by iterating on the variable", + "name": "Layer Variations", + "outputs": [ + { + "longdesc": "Shows a variation of the input", + "rgba": "layer_variations_$(name)($uv, $v1, $v2, $step)", + "shortdesc": "Output1", + "type": "rgba" + } + ], + "parameters": [ + { + "default": 0.0, + "label": "Variable", + "longdesc": "Variable name", + "name": "variable", + "shortdesc": "Variable", + "type": "enum", + "values": [ + { + "name": "$?1", + "value": "x" + }, + { + "name": "$?2", + "value": "y" + }, + { + "name": "$?3", + "value": "z" + }, + { + "name": "$?4", + "value": "w" + } + ] + }, + { + "control": "None", + "default": 0.0, + "label": "From", + "longdesc": "Initial value of the variable", + "max": 1.0, + "min": 0.0, + "name": "v1", + "shortdesc": "From", + "step": 0.01, + "type": "float" + }, + { + "control": "None", + "default": 1.0, + "label": "To", + "longdesc": "Maximum value of the variable", + "max": 1.0, + "min": 0.0, + "name": "v2", + "shortdesc": "To", + "step": 0.01, + "type": "float" + }, + { + "control": "None", + "default": 0.1, + "label": "Step", + "longdesc": "Step value when iterating", + "max": 1.0, + "min": 0.0, + "name": "step", + "shortdesc": "Step", + "step": 0.001, + "type": "float" + }, + { + "default": true, + "label": "Randomize", + "longdesc": "Pick different seeds for different variations", + "name": "randomize", + "shortdesc": "Randomize", + "type": "boolean" + } + ], + "shortdesc": "Layer Variations" + }, + "type": "shader" +} \ No newline at end of file diff --git a/addons/material_maker/nodes/material_dynamic.mmg b/addons/material_maker/nodes/material_dynamic.mmg index 4c75d3a1a..e1cde3e47 100644 --- a/addons/material_maker/nodes/material_dynamic.mmg +++ b/addons/material_maker/nodes/material_dynamic.mmg @@ -75,6 +75,7 @@ "$definitions float_uniform_to_const,rename_buffers", "void fragment() {", "\tfloat _seed_variation_ = variation;", + "\tvec4 _controlled_variation_ = vec4(0.0);", "\tvec2 uv = fract(UV);", "$if $(connected:depth_tex)", "\t{", @@ -177,6 +178,7 @@ "$definitions float_uniform_to_const,rename_buffers", "void fragment() {", "\tfloat _seed_variation_ = variation;", + "\tvec4 _controlled_variation_ = vec4(0.0);", "\tvec2 uv = fract(UV);", "$if $(connected:depth_tex)", "\t{", @@ -266,7 +268,8 @@ "$definitions hlsl,rename_buffers,unity", "\t\t", "\t\tvoid surf (Input IN, inout SurfaceOutputStandard o) {", - "\t \t\tfloat _seed_variation_ = 0.0;", + "\t\t\tfloat _seed_variation_ = 0.0;", + "\t\t\tfloat4 _controlled_variation_ = float4(0.0, 0.0, 0.0, 0.0);", "\t\t\tfloat2 uv = IN.uv_MainTex;", "$begin_generate hlsl,rename_buffers,unity", "\t\t\to.Albedo = $albedo_tex(uv).rgb*$albedo_color.rgb;", @@ -468,7 +471,8 @@ "struct Functions {", "$definitions hlsl,rename_buffers,unreal", "\tfixed4 generated_shader(float2 uv, out float metallic, out float roughness, out float3 normal) {", - "\t \tfloat _seed_variation_ = 0.0;", + "\t\tfloat _seed_variation_ = 0.0;", + "\t\tfloat4 _controlled_variation_ = float4(0.0, 0.0, 0.0, 0.0);", "$begin_generate hlsl,rename_buffers,unreal", "\t\t// sample the generated texture", "\t\tfixed4 rv = tofloat4($albedo_tex(uv), 1.0)*$albedo_color;", @@ -558,7 +562,8 @@ "\t\t\t\t\t\t\tTexture2D _texture_$(buffer_index), SamplerState _texture_$(buffer_index)Sampler,", "$end_buffers", "\t\t\t\t\t\t\tout float metallic, out float roughness, out float3 normal, out float3 emission) {", - "\t \tfloat _seed_variation_ = 0.0;", + "\t\tfloat _seed_variation_ = 0.0;", + "\t\tfloat4 _controlled_variation_ = float4(0.0, 0.0, 0.0, 0.0);", "\t\tTime = _time;", "$begin_buffers", "\t\ttexture_$(buffer_index) = _texture_$(buffer_index);", @@ -766,6 +771,7 @@ "", "void fragment() {", "\tfloat _seed_variation_ = variation;", + "\tvec4 _controlled_variation_ = vec4(0.0);", "\tvec2 uv = fract(UV);", "", "$if $(connected:depth_tex)", diff --git a/addons/material_maker/nodes/material_raymarching.mmg b/addons/material_maker/nodes/material_raymarching.mmg index 173dc9a20..3a1027032 100644 --- a/addons/material_maker/nodes/material_raymarching.mmg +++ b/addons/material_maker/nodes/material_raymarching.mmg @@ -52,6 +52,7 @@ "$definitions float_uniform_to_const,rename_buffers", "vec2 GetDist(vec3 p) {", "\tfloat _seed_variation_ = seed_variation;", + "\tvec4 _controlled_variation_ = vec4(0.0);", "$begin_generate", "\tif ($flip_y) {", "\t\tp *= vec3(1.0, -1.0, 1.0);", @@ -98,6 +99,7 @@ "}", "void fragment() {", "\tfloat _seed_variation_ = seed_variation;", + "\tvec4 _controlled_variation_ = vec4(0.0);", "\tvec3 ro = world_camera;", "\tvec3 rd = normalize(world_position - ro);", "\t", @@ -168,6 +170,7 @@ "$definitions float_uniform_to_const,rename_buffers", "vec2 GetDist(vec3 p) {", "\tfloat _seed_variation_ = seed_variation;", + "\tvec4 _controlled_variation_ = vec4(0.0);", "$begin_generate", "\tif ($flip_y) {", "\t\tp *= vec3(1.0, -1.0, 1.0);", @@ -214,6 +217,7 @@ "}", "void fragment() {", "\tfloat _seed_variation_ = seed_variation;", + "\tvec4 _controlled_variation_ = vec4(0.0);", "\tvec3 ro = world_camera;", "\tvec3 rd = normalize(world_position - ro);", "\t", @@ -283,6 +287,7 @@ "$definitions hlsl,rename_buffers,unity", "\t\tfloat2 sceneSDF(float3 p) {", "\t\t\tfloat _seed_variation_ = 0.0;", + "\t\t\tfloat4 _controlled_variation_ = float4(0.0, 0.0, 0.0, 0.0);", "$begin_generate hlsl,rename_buffers,unity", "\t\t\treturn $distance(p);", "$end_generate", @@ -320,6 +325,7 @@ "\t\t}", "\t\tvoid surf (Input IN, inout SurfaceOutputStandard o) {", "\t\t\tfloat _seed_variation_ = 0.0;", + "\t\t\tfloat4 _controlled_variation_ = float4(0.0, 0.0, 0.0, 0.0);", "\t\t\tfloat3 ro = mul(unity_WorldToObject, float4(_WorldSpaceCameraPos, 1.0));", "\t\t\tfloat3 rd = normalize(mul(unity_WorldToObject, float4(IN.worldPos, 1.0))-ro);", "\t\t\tfloat2 dist = RayMarch(ro, rd);", @@ -526,6 +532,7 @@ "$definitions hlsl,rename_buffers,unreal", "\tfloat2 sceneSDF(float3 p) {", "\t\tfloat _seed_variation_ = 0.0;", + "\t\tfloat4 _controlled_variation_ = float4(0.0, 0.0, 0.0, 0.0);", "\t\tp = p.xzy/Scale;", "$begin_generate hlsl,rename_buffers,unreal", "\t\tfloat2 d = $distance(p);", @@ -565,6 +572,7 @@ "\t}", "\tfloat4 generated_shader(float3 CameraPosition, float3 RayDirection, out float metallic, out float roughness, out float3 normal) {", "\t\tfloat _seed_variation_ = 0.0;", + "\t\tfloat4 _controlled_variation_ = float4(0.0, 0.0, 0.0, 0.0);", "\t\tfloat3 ro = CameraPosition;", "\t\tfloat3 rd = RayDirection;", "\t\tfloat2 dist = RayMarch(ro, rd);", @@ -671,6 +679,7 @@ "$definitions hlsl_base,rename_buffers,unreal5", "\tfloat2 sceneSDF(float3 p) {", "\t\tfloat _seed_variation_ = 0.0;", + "\t\tfloat4 _controlled_variation_ = float4(0.0, 0.0, 0.0, 0.0);", "\t\tp = p.xzy/Scale;", "$begin_generate hlsl_base,rename_buffers,unreal5", "\t\tfloat2 d = $distance(p);", @@ -714,6 +723,7 @@ "$end_buffers", "\t\t\t\t\t\t\tout float metallic, out float roughness, out float3 normal) {", "\t\tfloat _seed_variation_ = 0.0;", + "\t\tfloat4 _controlled_variation_ = float4(0.0, 0.0, 0.0, 0.0);", "\t\tTime = _time;", "\t\tScale = _scale;", "$begin_buffers", @@ -823,6 +833,7 @@ "", "vec2 GetDist(vec3 p) {", "\tfloat _seed_variation_ = 0.0;", + "\tvec4 _controlled_variation_ = vec4(0.0);", "\t", "$begin_generate", "\t\tif ($flip_y) {", @@ -876,6 +887,7 @@ "", "void fragment() {", "\tfloat _seed_variation_ = 0.0;", + "\tvec4 _controlled_variation_ = vec4(0.0);", "\tvec3 ro = world_camera;", "\tvec3 rd = normalize(world_position - ro);", "\t", diff --git a/addons/material_maker/nodes/material_unlit.mmg b/addons/material_maker/nodes/material_unlit.mmg index fcc3fe3d5..4e21c74c7 100644 --- a/addons/material_maker/nodes/material_unlit.mmg +++ b/addons/material_maker/nodes/material_unlit.mmg @@ -55,6 +55,7 @@ "$definitions float_uniform_to_const,rename_buffers", "void fragment() {", "\tfloat _seed_variation_ = variation;", + "\tvec4 _controlled_variation_ = vec4(0.0);", "\tvec2 uv = fract(UV);", "$begin_generate rename_buffers", "\tvec4 color_tex = $color_tex(uv);", @@ -110,6 +111,7 @@ "$definitions float_uniform_to_const,rename_buffers", "void fragment() {", "\tfloat _seed_variation_ = variation;", + "\tvec4 _controlled_variation_ = vec4(0.0);", "\tvec2 uv = fract(UV);", "$begin_generate rename_buffers", "\tvec4 color_tex = $color_tex(uv);", @@ -166,6 +168,7 @@ "$definitions float_uniform_to_const,rename_buffers", "void fragment() {", "\tfloat _seed_variation_ = variation;", + "\tvec4 _controlled_variation_ = vec4(0.0);", "\tvec2 uv = fract(UV);", "$begin_generate rename_buffers", "\tvec4 color_tex = $color_tex(uv);", @@ -221,6 +224,7 @@ "$definitions float_uniform_to_const,rename_buffers", "void fragment() {", "\tfloat _seed_variation_ = variation;", + "\tvec4 _controlled_variation_ = vec4(0.0);", "\tvec2 uv = fract(UV);", "$begin_generate rename_buffers", "\tvec4 color_tex = $color_tex(uv);", @@ -285,6 +289,7 @@ "\t\t\t}", "\t\t\tfixed4 frag (v2f i) : SV_Target {", "\t\t\t\tfloat _seed_variation_ = 0.0;", + "\t\t\t\tfloat4 _controlled_variation_ = float4(0.0, 0.0, 0.0, 0.0);", "\t\t\t\tfloat2 uv = i.uv;", "$begin_generate hlsl,rename_buffers,unity", "\t\t\t\t// sample the generated texture", @@ -486,6 +491,7 @@ "$definitions hlsl,rename_buffers,unreal", "\tfixed4 generated_shader(float2 uv) {", "\t\tfloat _seed_variation_ = 0.0;", + "\t\tfloat4 _controlled_variation_ = float4(0.0, 0.0, 0.0, 0.0);", "$begin_generate hlsl,rename_buffers,unreal", "\t\t// sample the generated texture", "\t\treturn $color_tex(uv);", @@ -565,7 +571,8 @@ "\t\t\t\t\t\t , Texture2D _texture_$(buffer_index), SamplerState _texture_$(buffer_index)Sampler", "$end_buffers", "\t\t\t\t\t\t\t) {", - "\t \tfloat _seed_variation_ = 0.0;", + "\t\tfloat _seed_variation_ = 0.0;", + "\t\tfloat4 _controlled_variation_ = float4(0.0, 0.0, 0.0, 0.0);", "\t\tTime = _time;", "$begin_buffers", "\t\ttexture_$(buffer_index) = _texture_$(buffer_index);", @@ -662,6 +669,7 @@ "", "void fragment() {", "\tfloat _seed_variation_ = variation;", + "\tvec4 _controlled_variation_ = vec4(0.0);", "\tvec2 uv = fract(UV);", "$begin_generate", "\tvec4 color_tex = $color_tex(uv);", diff --git a/addons/material_maker/nodes/preview_f.gdshader b/addons/material_maker/nodes/preview_f.gdshader index b12aa2bd4..d92c2e1c8 100644 --- a/addons/material_maker/nodes/preview_f.gdshader +++ b/addons/material_maker/nodes/preview_f.gdshader @@ -2,6 +2,7 @@ uniform float variation = 0.0; vec4 preview_2d(vec2 uv) { float _seed_variation_ = variation; + vec4 _controlled_variation_ = vec4(0.0); $(code) return vec4(vec3($(value)), 1.0); } diff --git a/addons/material_maker/nodes/preview_fill.gdshader b/addons/material_maker/nodes/preview_fill.gdshader index 384bb1eb3..b5a62b9e5 100644 --- a/addons/material_maker/nodes/preview_fill.gdshader +++ b/addons/material_maker/nodes/preview_fill.gdshader @@ -2,6 +2,7 @@ uniform float variation = 0.0; vec4 preview_2d(vec2 uv) { float _seed_variation_ = variation; + vec4 _controlled_variation_ = vec4(0.0); $(code) return vec4(sign(dot($(value),vec4(1.0)))*(vec3(0.1)+0.9*fract(vec3(3456.765, 6523.12, 2373.987)*$(value).rgb+2341.876*$(value).aaa)), 1.0); } diff --git a/addons/material_maker/nodes/preview_rgb.gdshader b/addons/material_maker/nodes/preview_rgb.gdshader index ae1de0194..5b2a0b97c 100644 --- a/addons/material_maker/nodes/preview_rgb.gdshader +++ b/addons/material_maker/nodes/preview_rgb.gdshader @@ -2,6 +2,7 @@ uniform float variation = 0.0; vec4 preview_2d(vec2 uv) { float _seed_variation_ = variation; + vec4 _controlled_variation_ = vec4(0.0); $(code) return vec4($(value), 1.0); } diff --git a/addons/material_maker/nodes/preview_rgba.gdshader b/addons/material_maker/nodes/preview_rgba.gdshader index 85ce62894..566b8d9ce 100644 --- a/addons/material_maker/nodes/preview_rgba.gdshader +++ b/addons/material_maker/nodes/preview_rgba.gdshader @@ -2,6 +2,7 @@ uniform float variation = 0.0; vec4 preview_2d(vec2 uv) { float _seed_variation_ = variation; + vec4 _controlled_variation_ = vec4(0.0); $(code) return $(value); } diff --git a/addons/material_maker/nodes/preview_sdf2d.gdshader b/addons/material_maker/nodes/preview_sdf2d.gdshader index 3b744df79..19d33d354 100644 --- a/addons/material_maker/nodes/preview_sdf2d.gdshader +++ b/addons/material_maker/nodes/preview_sdf2d.gdshader @@ -2,6 +2,7 @@ uniform float variation = 0.0; vec4 preview_2d(vec2 uv) { float _seed_variation_ = variation; + vec4 _controlled_variation_ = vec4(0.0); $(code) float d = $(value); vec3 col = vec3(clamp(6.0*cos(d*min((256), preview_size))-5.0, 0.0, 1.0)); diff --git a/addons/material_maker/nodes/preview_sdf3d.gdshader b/addons/material_maker/nodes/preview_sdf3d.gdshader index c5a381ae5..94518d84c 100644 --- a/addons/material_maker/nodes/preview_sdf3d.gdshader +++ b/addons/material_maker/nodes/preview_sdf3d.gdshader @@ -2,6 +2,7 @@ uniform float variation = 0.0; float calcdist(vec3 uv) { float _seed_variation_ = variation; + vec4 _controlled_variation_ = vec4(0.0); $(code) float v = $(value); v = v == 0.0 ? 1.0 : v; diff --git a/addons/material_maker/nodes/preview_sdf3dc.gdshader b/addons/material_maker/nodes/preview_sdf3dc.gdshader index 6fe0971c3..792c30a91 100644 --- a/addons/material_maker/nodes/preview_sdf3dc.gdshader +++ b/addons/material_maker/nodes/preview_sdf3dc.gdshader @@ -2,6 +2,7 @@ uniform float variation = 0.0; vec2 calcdist(vec3 uv) { float _seed_variation_ = variation; + vec4 _controlled_variation_ = vec4(0.0); $(code) vec2 v = $(value); v.x = v.x == 0.0 ? 1.0 : v.x; diff --git a/addons/material_maker/nodes/preview_tex3d.gdshader b/addons/material_maker/nodes/preview_tex3d.gdshader index 5afef6723..65ce251bc 100644 --- a/addons/material_maker/nodes/preview_tex3d.gdshader +++ b/addons/material_maker/nodes/preview_tex3d.gdshader @@ -6,6 +6,7 @@ float calcdist(vec3 p) { vec3 calcColor(vec4 uv) { float _seed_variation_ = variation; + vec4 _controlled_variation_ = vec4(0.0); $(code) return $(value); } diff --git a/addons/material_maker/nodes/preview_tex3d_gs.gdshader b/addons/material_maker/nodes/preview_tex3d_gs.gdshader index 6c55707bb..9354b309e 100644 --- a/addons/material_maker/nodes/preview_tex3d_gs.gdshader +++ b/addons/material_maker/nodes/preview_tex3d_gs.gdshader @@ -6,6 +6,7 @@ float calcdist(vec3 p) { vec3 calcColor(vec4 uv) { float _seed_variation_ = variation; + vec4 _controlled_variation_ = vec4(0.0); $(code) return vec3($(value)); } diff --git a/addons/material_maker/nodes/preview_v4v4.gdshader b/addons/material_maker/nodes/preview_v4v4.gdshader index 002e15648..4e150205d 100644 --- a/addons/material_maker/nodes/preview_v4v4.gdshader +++ b/addons/material_maker/nodes/preview_v4v4.gdshader @@ -1,9 +1,10 @@ uniform float variation = 0.0; vec4 mfield(vec4 uv) { - float _seed_variation_ = variation; + float _seed_variation_ = variation; + vec4 _controlled_variation_ = vec4(0.0); $(code) - return $(value); + return $(value); } float raymarch(vec3 ro, vec3 rd) { diff --git a/material_maker/doc/images/node_miscellaneous_variations_controlled.png b/material_maker/doc/images/node_miscellaneous_variations_controlled.png new file mode 100644 index 000000000..15bcf7d91 Binary files /dev/null and b/material_maker/doc/images/node_miscellaneous_variations_controlled.png differ diff --git a/material_maker/doc/images/node_miscellaneous_variations_iterate.png b/material_maker/doc/images/node_miscellaneous_variations_iterate.png new file mode 100644 index 000000000..281edf686 Binary files /dev/null and b/material_maker/doc/images/node_miscellaneous_variations_iterate.png differ diff --git a/material_maker/doc/images/node_miscellaneous_variations_layer.png b/material_maker/doc/images/node_miscellaneous_variations_layer.png new file mode 100644 index 000000000..d052d3966 Binary files /dev/null and b/material_maker/doc/images/node_miscellaneous_variations_layer.png differ diff --git a/material_maker/doc/images/node_miscellaneous_variations_layer_color.png b/material_maker/doc/images/node_miscellaneous_variations_layer_color.png new file mode 100644 index 000000000..9bab5a33f Binary files /dev/null and b/material_maker/doc/images/node_miscellaneous_variations_layer_color.png differ diff --git a/material_maker/doc/node_miscellaneous_variations.rst b/material_maker/doc/node_miscellaneous_variations.rst index 2aef8a677..d94a794f9 100644 --- a/material_maker/doc/node_miscellaneous_variations.rst +++ b/material_maker/doc/node_miscellaneous_variations.rst @@ -2,6 +2,7 @@ Variations node ~~~~~~~~~~~~~~~ The **Variations** node can be used to generate several variations of its input. +Variations differ by the seeds used for all random aspects of the input. .. image:: images/node_miscellaneous_variations.png :align: center diff --git a/material_maker/doc/node_miscellaneous_variations_controlled.rst b/material_maker/doc/node_miscellaneous_variations_controlled.rst new file mode 100644 index 000000000..eb49e0ce5 --- /dev/null +++ b/material_maker/doc/node_miscellaneous_variations_controlled.rst @@ -0,0 +1,36 @@ +Controlled Variations node +~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The **Controlled Variations** node can be used to generate several variations of its input. +Variations differ by the value of a variable (defined in the **Variable** parameter), +that can be used in parameter expressions of the input. + +.. image:: images/node_miscellaneous_variations_controlled.png + :align: center + +Inputs +++++++ + +The **Controlled Variations** node has a single input whose variations will be generated. + +Outputs ++++++++ + +The **Controlled Variations** node is variadic and can several outputs that generate different variations. + +Parameters +++++++++++ + +The **Controlled Variations** node accepts the following parameters: + +* the *Value* selected for the variable for each output + +* the *Variable* that is controlled by the node (**$?1**, **$?2**, **$?3** or **$?4**) + +Note +++++ + +To generate variations, the **Controlled Variations** node sets different values of the variations +variable. + +The whole incoming branch is affected, until a buffer, text or image node is reached. diff --git a/material_maker/doc/node_miscellaneous_variations_iterate.rst b/material_maker/doc/node_miscellaneous_variations_iterate.rst new file mode 100644 index 000000000..d1cb03650 --- /dev/null +++ b/material_maker/doc/node_miscellaneous_variations_iterate.rst @@ -0,0 +1,45 @@ +Iterate Variations node +~~~~~~~~~~~~~~~~~~~~~~~ + +The **Iterate Variations** node can be used to combine several variations of its input. +Variations differ by the value of a variable (defined in the **Variable** parameter), +that can is modified automatically according to the **From**, **To** and **Step** +parameters. + +.. image:: images/node_miscellaneous_variations_iterate.png + :align: center + +Inputs +++++++ + +The **Iterate Variations** node has a single grayscale input whose variations will be generated and combined. + +Outputs ++++++++ + +The **Iterate Variations** node has a single grayscale output that shows the combined variations. + +Parameters +++++++++++ + +The **Iterate Variations** node accepts the following parameters: + +* *From*, the initial value of the variable + +* *To*, the maximum value of the variable + +* the *Step* used to loop through all values + +* *Combine*, the operator used to combine variations (**Add**, **Min**, **Max** or **Average**) + +* the *Variable* that is controlled by the node (**$?1**, **$?2**, **$?3** or **$?4**) + +* the *Randomize* option, that sets different seeds for different variations + +Note +++++ + +To generate variations, the **Iterate Variations** node sets different values of the variations +variable. + +The whole incoming branch is affected, until a buffer, text or image node is reached. diff --git a/material_maker/doc/node_miscellaneous_variations_layer.rst b/material_maker/doc/node_miscellaneous_variations_layer.rst new file mode 100644 index 000000000..b8205ca7c --- /dev/null +++ b/material_maker/doc/node_miscellaneous_variations_layer.rst @@ -0,0 +1,44 @@ +Layer Variations node +~~~~~~~~~~~~~~~~~~~~~ + +The **Layer Variations** node can be used to layer several variations of its input. +Variations differ by the value of a variable (defined in the **Variable** parameter), +that can is modified automatically according to the **From**, **To** and **Step** +parameters. + +.. image:: images/node_miscellaneous_variations_layer.png + :align: center + +Inputs +++++++ + +The **Layer Variations** node has a grayscale input whose variations will be generated +and stacked, and a mask input that is applied to each layer. + +Outputs ++++++++ + +The **Layer Variations** node has a single grayscale output that shows the layered variations. + +Parameters +++++++++++ + +The **Layer Variations** node accepts the following parameters: + +* *From*, the initial value of the variable + +* *To*, the maximum value of the variable + +* the *Step* used to loop through all values + +* the *Variable* that is controlled by the node (**$?1**, **$?2**, **$?3** or **$?4**) + +* the *Randomize* option, that sets different seeds for different variations + +Note +++++ + +To generate variations, the **Layer Variations** node sets different values of the variations +variable. + +The whole incoming branch is affected, until a buffer, text or image node is reached. diff --git a/material_maker/doc/node_miscellaneous_variations_layer_color.rst b/material_maker/doc/node_miscellaneous_variations_layer_color.rst new file mode 100644 index 000000000..b36d5daea --- /dev/null +++ b/material_maker/doc/node_miscellaneous_variations_layer_color.rst @@ -0,0 +1,44 @@ +Color Layer Variations node +~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The **Color Layer Variations** node can be used to layer several variations of its input. +Variations differ by the value of a variable (defined in the **Variable** parameter), +that can is modified automatically according to the **From**, **To** and **Step** +parameters. + +.. image:: images/node_miscellaneous_variations_layer_color.png + :align: center + +Inputs +++++++ + +The **Color Layer Variations** node has a grayscale input whose variations will be generated +and stacked, and a mask input that is applied to each layer. + +Outputs ++++++++ + +The **Color Layer Variations** node has a single grayscale output that shows the layered variations. + +Parameters +++++++++++ + +The **Color Layer Variations** node accepts the following parameters: + +* *From*, the initial value of the variable + +* *To*, the maximum value of the variable + +* the *Step* used to loop through all values + +* the *Variable* that is controlled by the node (**$?1**, **$?2**, **$?3** or **$?4**) + +* the *Randomize* option, that sets different seeds for different variations + +Note +++++ + +To generate variations, the **Color Layer Variations** node sets different values of the variations +variable. + +The whole incoming branch is affected, until a buffer, text or image node is reached. diff --git a/material_maker/doc/nodes_miscellaneous.rst b/material_maker/doc/nodes_miscellaneous.rst index 085720543..40b19a3f5 100644 --- a/material_maker/doc/nodes_miscellaneous.rst +++ b/material_maker/doc/nodes_miscellaneous.rst @@ -15,6 +15,10 @@ Miscellaneous nodes node_miscellaneous_export node_miscellaneous_debug node_miscellaneous_variations + node_miscellaneous_variations_controlled + node_miscellaneous_variations_iterate + node_miscellaneous_variations_layer + node_miscellaneous_variations_layer_color node_miscellaneous_randomize node_miscellaneous_mesh_map node_miscellaneous_mesh_triplanar diff --git a/material_maker/library/base.json b/material_maker/library/base.json index 111d1c64d..ab9f0cd72 100644 --- a/material_maker/library/base.json +++ b/material_maker/library/base.json @@ -8015,8 +8015,68 @@ "tree_item": "Transform/Directional Warp", "type": "directional_warp" }, + { + "display_name": "Controlled", + "generic_size": 1.0, + "icon_data": "iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAAAXNSR0IArs4c6QAAAMVJREFUeJzt2rENwzAQxdBLkCXtAe0xkyobWHiFyAE+CAJqDnrNzHc25q0FNAXQApoCaAFNAbSApgBaQFMALaApgBbQFEALaAqgBTQF0AKa7QN8Vowex7Fidu77fnxzSYCZmeu6Ht07z/PRvT/bP4ECaAFNAbSApgBaQFMALaApgBbQFEALaAqgBTQF0AKaAmgBzbKb4Kob3tO8pq+ye1MALaApgBbQFEALaAqgBTQF0AKaAmgBTQG0gKYAWkBTAC2g2T7AD/p7CZEtpDlJAAAAAElFTkSuQmCC", + "name": "controlled_variations_2", + "parameters": { + "v1": 0.5, + "variable": 0.0 + }, + "seed_int": 0.0, + "tree_item": "Miscellaneous/Variations/Controlled", + "type": "controlled_variations" + }, + { + "display_name": "Iterate", + "icon_data": "iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAAAXNSR0IArs4c6QAAAqJJREFUeJztmb+K8kAUxa9GkQSxCoqmskghKD6GhfoCVra2tjZ29naWlloJ4isEgmAnFhapxCKgYCQo+Ge7+eKibDZzM+O3zq+6o+Tc4yHXTJIIANzhg4nyNsAbEQBvA7wRAfA2wBsRAG8DvIm9+kKWZYhGcfO5Xq9wOp1QNWl5GQAAQCqVQm223+9R9TAQI8C0WSwGyWSSrI/HI8v2T/EdQC6XQ2283W7fIgAxAlybx/61v1wufDwEOUhVVZAkiapxJpMhtW3bMJ/PqfSCEvgMwN4j8OJv/AoKUP4DvLMcBE3TQNM0sp5MJrSWfIMSQDqdxpABAPZ7AzECvA08o1arkdowDNjtdqH1Qg8gm82i6hmGgar3HTECvA38RKlUIrXjOLBYLFD1Qw0A4waq0WiQejAYUOt9R4wAbwO/pVAokHq1WlHrMQsA4+rQ7XZJPRqNwg3gdruR668kSegPRN6FlwGcz2dSK4rCxMxv8fpyXTeQRgR8vB5XFOVh9lRVhXg8Ttbes8N7qr/6XFEUkGU5kOFnmKYJ7XY70LG+/wM2mw2pVVUN1MxLIpGg1sDAVwCu6z6cYuVyOTRDrPnvLoPP0HUdptMpWdfrdd/HBgrAtm1SY1zeaDW8x3tH1Q+BAvDux6vVahCJt0FshTFEvC89sZ8HhA11ALPZjNSVSoVWjjkfPwIfHwDqPsAwDPIMr1gsQrPZxJQPBdQAHMfBlGOCGIGwhA+HA/T7fbLu9XphtaIitACWyyWp8/l8WG2oESPAqtFwOCR1q9Vi1fZHmARgWRZYlgUAAJFI5K0CECPAo6lpmqTWdZ3rDRTzAO73O3Q6HbIej8esLTwgRoC3AQCA9XrNrbev9wJ/mY8fAREAbwO8EQHwNsAbEQBvA7z5+AC+AIRYlV6uwUK/AAAAAElFTkSuQmCC", + "name": "iterate_variations_2", + "parameters": { + "combine": 1.0, + "randomize": false, + "step": 0.1, + "v1": 0.0, + "v2": 1.0, + "variable": 0.0 + }, + "seed_int": 0.0, + "tree_item": "Miscellaneous/Variations/Iterate", + "type": "iterate_variations" + }, + { + "display_name": "Layer", + "icon_data": "iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAAAXNSR0IArs4c6QAAA4NJREFUeJztmt2V4yAMheU924SZMpw2nDJcVHpyG1CG94k5DJHQDyJMzua+TcbG3A8hZPACABf8x/ozuwOz9QEwuwOz9QEwuwOz9dejkeuas5Asy9LdxvAIiDGOfkSXFuisA7jRbwEIIfQ8GgD6o6ALQI/5lrRgeiAMA8CZTykBAMC6rqpnYnCmAPAwX0sLo9TX15fpPncAVvO1LDAsEEzL4Gjz9bU9kcHJFAEWABLz+f5WEuRgaKNADWC0+VLcaoDBGApghHnJUildFjMQDYTuUpgyYB311nUcCE2OyRIDwEbfat5aIElBXNclrg3c3wU8zaeU0PZijM12zvMUP0OUA6Sj3zIvNW4pkrCI2LZNFAWmHKAx32u8/j8GQjo1MLERUI++t3lL4uJqgRACrOsKIQQ2CpoArOZHGS8lgbBtGwC0X5a6lkGt+V7TWFsUiBjjdxS0RALgRl9j3mpcUh2mlNhoaC2LogiQmKekuVYydWKMKAQA20sTWgeUo491yuvtLK/n3LqO3YepFZVUGf8EYPQOr8Uw1Q6mEkINBPP21ucC0khowf4BACPUs3PrmfUpaSOp9uhyMCKVxxJJVYLWgTJPAY9EmF92PFYVLhKo/4sAeBxgeEoDgYP7A4DHWdtscZFQe3zZKtBTTGGy3I/BeUqCy7KQq8HIg06ubWwaSspgTmgESKeC9eGadZq7pm6LAgWAb5aqpsCIZOhRAtfSDAwJoDchliNTdnxEcSRpk9oqn1oKW3KKdx5qAsCioDUNevbtLUWR9Pm32428h40AbipYEyFXFreA1Pe2+tAyD2CcAtZkmDvqXRNQkkwXEQBLQixHpQZW/u25XVbrfr+z1wxNghiE8jepeey6ur0S6r7vIvMACgB1FJQPbI32uq5PncR2az2zuyZiu47HufWdmuv59/M8IaX0dB2WY7hoCiHAcRwAoAOg2hCh3hMo5Y5mg2WH8yaG5iCzbLPUcRzfv2vzlXpHqIRQviBlc635ioGQCLs+/5ZHPfdNK/ctsVaSK0FIIVD5Zd93NAFq5fKZnPUssMwFj8cDAOjkmkeayv7Wd5eXASiFvQ6XuQCDwP32cgAAus9mKJUwSghU6HuaBxj8sXQt6YeU1AcPFJRpAAB8jtK43dw6YXqZB3AAADDuPJE7HvfYxf7VADj9GgDvrLc+HfbQB8DsDszWB8DsDszWP8r9grAlvpVDAAAAAElFTkSuQmCC", + "name": "layer_variations", + "parameters": { + "randomize": false, + "step": 0.1, + "v1": 0.0, + "v2": 1.0, + "variable": 0.0 + }, + "seed_int": 0.0, + "tree_item": "Miscellaneous/Variations/Layer", + "type": "layer_variations" + }, + { + "display_name": "Layer Color", + "icon_data": "iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAIAAAAlC+aJAAAAAXNSR0IArs4c6QAAChNJREFUaIHVmntsFccVh79rGy5+YMP1i9qXYN6+NjGER0FJgRYpxaloKJCmonlVUGLSqApJFWhT2qoqakhSOUVIEY5VRPMQCimUUEohTcAkqZrSYGIgvlDMK9gmcI2NH/iF8faPvbs7szt7HzZt1aMr3ZkzZ86e386ZOTNn1qPx/00Jt0GH/zboGDAlDVZBKXwLgD6oN34NUA9dg7YuBvIMyoVK4AcRBb4wwOiomgfzMDUNAkAWbHBt7Mgh7aqqoVWAVA+NA358mAYB4FeQrW65XkDdQoCMS2QFGXk+op5ewev0X08cVgwUwBMwVd0SKuLiXDtzeCPZQXx1Meu/LKO67io4IACL4T51S+NMGmdE6pp2hawgWafjedx5eMG1MX4As2CluuXiPEKBWNWkNJEdJCsYmwXPuS4AcQLIh5+pW+oWcr0gUtdKGANfd/CHtZAdJDtIQp975wPwR3VLPAA88AKkK1qCS7iR49rvJGwWqt+BBSoxbztZQbJrSXJO4m5Y42JUHADWQKGdpyVwYjm9aa6dNkGtiv8QzHPpMqQz7F1DbwjczfCZQjhmAA8q3ltvGieWo7lsR47A76JpfQzudm9N6iErSHYQbxsch1cUMrEB+Ao8bOfdyCG4xLXH83AhFs0ArIDZEQUS+sgOkvUQySfsTTEAGAdr7TwzVDmpCrZH1QkaiR5uiZzHIeIKzOgt5D5hZ0YD4IUXwSvxlKEK6IENoNxAiNRJdh2lfQzL50guNWJTIpS5RkgyzjJxgp0ZDcA6GCsxGmfQOFMhuA/eiawKrjHpIvNFjpfWYnbYxLxQBsWO7p5+ZhTAJZkZCcAjcI/EuDiXUJFdqgU2QEdE0+uZc5U73VoL2Z1CyMZMhTKYLDNnPgqvSxx3AAvgQYmhDFV/gL+6aQCNhDpK28l3FwlTFsE7+MjJT4fVMN6oTtpL+jclARcAhfbA4QxVDbAB+l0M6iSzjtI+UqKabplC/10uC68PVsMYGHUM/2o4IvRSAEiHF62aMlS9Bn9zsaOZiRf4aux222gsB0dyVtmUA2taWLhRMk91pBTevTNUnYHfuDy7gdlXKInHWg/aMrgbzzMm6zwLmpg8kX1O6atwcCQLx8EIa4PtGIGVMCtcdIaqLXBMZUcdpW2xn+21ebAUybs6RAw6lfBGkuNYPQc2bSNpt7XkyQDug8Xh4vUx1JVKnXfA+7K6Lnx1lN4kNQajC2EpFLhLKDDk8c9RfCpypsDL7+E7CU+HOYILTbWsB7v1gHPD1kRhJOs1HyyFL7sbLavXym0YGpl1jcnFvGVyOqDNj+8sBCAoAsgGOUonN9PliwKgC5+DB9r9sCg2o22kwNBDejWrJvNOKld1AO36mjw/DMCYnk/ZlaU3ONXbqYtMO0t7daDWGw/Ryp3c0yz+nLlAB/QMB2AaJEIYwDTIsvdJr7dznL5yi6FSXbt/IDbbSY2hicJqVnUD0J0BoG9KkgA+hX57lnF4DCPgoNjefTfUQi0EoclgVsiPcviSSG1+hrXCfDhozoHD8DVJKOGWvVsMAGQ6ALVwKjbhsjgwtPnJ+QxywW++9iqF3HA5bRYFgOaY0Ltitl4ne+xS+xLmPAbmmwCugMNnbPM4UW51LKBLpdpPI1jqQortuIQhgZt64dYQgzVXdPzD9t7OeSxSp30Jktf7JgZCZU6WhSGFaya3Y1S4IAD4wN41NeLhSh0EdHotUscotN7JCmNIphnQtw5thhfJm7lPQD5tJfZyS14qTZKCgCbnW+Sd6vRKgP4kujLpzKTLR1cmXT76lZcTITgJUxwY8CRzDbgBadDmJ++oE8BhO4D0elrGuQEQR0CYAEckMd16IKGP1CukXlGoCi6To/5m24qkk6aPQAekqV0IOANtdgBu1M0IoVZgFaMmgxwU2Olg2SdDJ8YcMM+u+gA6klLyVLYtRC7eJJCM33z9USntCwfrVbGyE9DTMCaANj9EBeCVDVKHAk3IET5rFYvedrNWQZP+5GAdFV6H50OTbQHIBwWADpCT9yIGl1i2VMkd5n4roaSMzx2sZxVi0UYAhxcJ08AEoEkdjbPVjy2WzXkqhN9dikcCjD/g0iAnKU0A3SPglPJMXC3V0uutXJAJQFiCPJZoi2HKu5IG24qyWijb5qqvjmYx96Zf4LIT8Br+JCagene5XXRXWUVxHgsAjCCgLQsXtlliGRetsmI9dKeCQ3Jdv8jynAaSjTBsAkhqIeG6GwDBixJ7rbJqBIz0+PfC/6LzxGW9TtnmbYIcG5ONOyYdQPI5pvlIanMDcBkuW7U0I/qYAKyNkOcZ66UsAqheFYf1TpnRZhQPH9vDcTFFGIH0GoqNZJ37txJVVtE83JgAhokXnyYGOek3MKp9wMYIBzlzBDr7mDTNanYHIHiRuRCZG+g7+KiQ3ZaEiaEChEHQaSYV5i8qgO6RmHoAPOGVYSjtemGtfEca8WsVYzkabriTGAdSCE2n0kurHcOvw4xew3pRpRODWLcht9HUVo5ms0je6kYEUCXI3QJIcxxritmRb27fdAyZUEL1Kn6oMtdJZow9d69Res5s3GuWfnmcrfMUx4yIAP5lzU/di0bAK/C4LJVLTYmZtNcxPBmufaI6oYjUD28YZSt3P8YoePbo/0/X1SxaB8cVGqJ98GTMBDFJMQMqYIUglUT3dCrTqbcwVETxB53MZJolLO9LnuRQ547K8uePsF+tIRqAqvC/c189GyrgMYEzgb+M4z0wMKxWvH9xTMxSwyxBwrg7TObysZ7K326rSz4BW10NjOGW8kcwEaDmEW663Fd8AG8K1WOs0EhEK2dd2vSXADbCOM63CPdtIjbr9RfhferNOz0Pr4cJLRTvAA3WYqxAAwMwE74fLvZ5CRXRFDDyezIdxErDXuKeEEVo5ZQJS5dGyjXGNNJ+g+RmUq6R2EP1HgjUMv73uZ7D+fzjXngA0huYpE/gl+274/gBAFvsjP4kQgFCAWPZFuhdI/Z0knWKJWjlbEsjAEUgwb4AO/V9TgFVPs6kwXoYCZlnGHsQgLfgkF3/gAB81/XDBs1DU4BQgE45u2reutby7W5tqxFCOmGneToZQucE9uu7tMXwDQByaxj9MQAfyn45KAB58PPoUk2TaQrQkWtx9sCf4QolDcwxEiIAw2mYwH4P/UAOrDeu0v1/Z5S+Vp6TLsIGDQD4BXwpRlGaJxAK0J4Xru6CfXhreBTI4YSfj03J5Vj3gWMPknkGgG5Ya0TyaBTnB09e8Bu/fPBHOee3jKUpQOtogLfRl9gwFcBPhOqkvcLBY2McX4oM7rtRnfJkVBkKkdbRhIq4XsB2qIKVciKyeAfJxmmO191vcFV0OwA4yWeMjw5plNXSnkcoYJ0bk3qYsl34ROt9iCeXwX8KgJOSBa/zg5+OfJoCFFQJMkHYFLfi/xYAJYlzKQ/WDUTH/xTA7aB/A2i56hwFze3YAAAAAElFTkSuQmCC", + "name": "layer_variations_color", + "parameters": { + "randomize": false, + "step": 0.1, + "v1": 0.0, + "v2": 1.0, + "variable": 0.0 + }, + "seed_int": 0.0, + "tree_item": "Miscellaneous/Variations/Layer Color", + "type": "layer_variations_color" + }, { "display_name": "In", + "name": "portal", "icon_data": "iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAAXNSR0IArs4c6QAAAERlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAA6ABAAMAAAABAAEAAKACAAQAAAABAAAAMKADAAQAAAABAAAAMAAAAADbN2wMAAAGTUlEQVR42u1aA3RjaxDu7rNtG2vbtm17g7XNrK1aSda22aB2U/MF67q98/657b/9c9c49+bhnjNH0Xwz3zhOz/H8/yi08KHCGzqM84J3/zFKzz0LLyu1oJygARMR4EUL3EQNhBMZNnculHZY5ZVqqDBBDdFU8QfJRC3oiWd+djjl5Wr4g1jYTBV9lCg1kKj0hW8cietfEcVS7RRVA4xzy8ka55Z9S+6dnywEgZ6a6g0fOAQAwvHddhb24Qp7zzdFtxx+8mSjfrt2ofSaF7iLKH3Xjk4a2CI97zXQWkAPrs+C5ERUvsmAXbvqd3dxrt5u1aqaRNopjnooNRzHvJ+b6As1pNMeoJQwaIesMZvbjdfpUPm63Xc4V2+/cmWlZnNnl6knl/9Rd7xswLLwEwI6XZWOOmpoxSoj88wvaC/X6dH6dbvu4C1fufnsOWXrK2S/VRs06JdqAweWqTW0l9wr9wb7OYUvVJUGgAYOsIoMWJ6ezlOHcP6e8nUVsl+I8t+V7dzps58aN/7q12ZN+iz2XyvwgrPoyk/eDV+THy68Z0WvwsJ2Mp2e8r5Ss1k8bajyXxHlP/62RpWPv6hc5dfqfesp1YWZDIAs0as1VlXWiiM23LzecsTJU42KrY98Zy3/8TfVq7777k8/v/3255+gjHe/oxUUuE7iAtCCnQI9Z0aEIn3Q+uu9/M7P23B8F1X+3U/++AWVdkJxKvMq+fgr49xutRHQaKNoymM/Q37QyuZ9Erw6av2952LjDl9Lhx37Qv2adBrTDJVHpQXF7w3y2Vy2sIlnfR8oz1pvzPasO8T6p+oS62O+33cujgegPpsM2w/H2VS+IZ0eUgAvs98j3w1fiFO8tNCD/eGhqy0WPnV2c95RsensOfvOm2IO+2XwAJyPxMO6PSZY6BW+ee5Ww5uCIrjUrgj6QhOxWofZ7A/3mmeKwuyD9MHMs/9CXORhv3TQnE0B56MEwF4TLPKOhKk7wiLHrw2uwgDoawdAC6PEapu92R/uMi0kiAfQfvVKLFoHL8ZH8BQ6gx5AAOiBCJjuHArj1gfmDV5umIpxRBJBLUGDt0asAuZ3z2pqDjoodHosXsh/TJ2HLidEoAcohagHEMDYdYEwSGWErvP8zvVcGVNJ0NwdfsIWBkoTURM58SwSZ4bMqAwAlMg0jjOE22xXg9JSzugSTSevxUeeDTRzR2gMHE2AtXtiCAD0QBiMXU8ALDcQANeg1bRLN4jV85jJ7fKTAngLXtDDEbmVmQep1iyISr4D/jE34VygGfgY4AHwQcx7YNoOpBAL4DLIvPPYWhAsPgCOIwDyIc2WDZFJtwmAGwSABYQUwhi4D8DUSzDOI5sFECcBAOKBu3mQZs3mPWCMvgHngxgAhEIUQFEMBPAAuhVRCEa73WUBWCTzQCoP4HYJgGsUQDwfAyyFBquMlEKOAAAQAPUApRADIOH+GFCVUGisu9QUAqRQSRCjB84RDxwRVGJKIUEWeuYgLkVkCxHts0hYKtwJTAJACUjguMsB5owzfklxxy6aQg9diDGSLFRAPSCsAxRAtyIPZCgFaVSSQoZjJFbimh2wkA0ceORKQjjvgTM0BiiF2CD2OzBwfdrvwkImSSvRdTppJfqV9EIHsJV4UBYqioHMISrjCPyeB7cSEjZzuIHAGfjAxTi+F9KcFXogzCBbE/Qb8z39hM2cJO30kNVWM50HcJDffz42RpCFCokHlgzfanjlUe008UhjiQaazLt0HqATGZ0Hth80pS5y0zWRbqB5ipGSdqR7cSIjMbB5Z+Dpas36NcCRskyZMq8+YKTMY0dKSYf6HrMiwtALuI1b6Xr5xFTVQY/vKnTqXDTU//Sz09tvf1I8G7+K8qChXvq1yvBTJ2k6tdsJ/fagtUqmVgCgo+SLrfZksYWbibrFiy2czux2Q99WroLya5VedSVfbD1wtajKSKNbaYwFutSlIHCtWLxaXCf1apEGYku75a5XQT6uF+lyl4KgWzp+uVt7WM9HLnelX69bzIRKmJF4KmE84KoFPYEyYFmYlOv1pzhwYEAjCL420APHMekPHE97YsJ4QCA95wYcJMpnOtyJiTnypdx35HMnRz7XrLtyz7y/xD3yiXBmnaKFbx3z0K2BsMcAMOCh+/+/Gvz/Zw+Rnr8BVrClNOJTRW8AAAAASUVORK5CYII=", "io": 0.0, "name": "portal", diff --git a/material_maker/nodes/debug/debug_popup.gd b/material_maker/nodes/debug/debug_popup.gd index 6a716d414..7df647bcd 100644 --- a/material_maker/nodes/debug/debug_popup.gd +++ b/material_maker/nodes/debug/debug_popup.gd @@ -47,6 +47,7 @@ func generate_shadertoy() -> String: code += "void mainImage(out vec4 fragColor, in vec2 fragCoord) {\n" code += "float minSize = min(iResolution.x, iResolution.y);\n" code += "float _seed_variation_ = SEED_VARIATION;\n" + code += "vec4 _controlled_variation_ = vec4(0.0);\n" 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"): @@ -71,6 +72,7 @@ func generate_godot_canvasitem() -> String: code += "\n" code += "void fragment() {\n" code += "float _seed_variation_ = seed_variation;\n" + code += "vec4 _controlled_variation_ = vec4(0.0);\n" code += src_code.code if src_code.output_values.has("rgba"): code += "COLOR = "+src_code.output_values.rgba+";\n" @@ -94,6 +96,7 @@ func generate_godot_spatial() -> String: code += "\n" code += "void fragment() {\n" code += "float _seed_variation_ = seed_variation;\n" + code += "vec4 _controlled_variation_ = vec4(0.0);\n" code += src_code.code if src_code.output_values.has("rgb"): code += "ALBEDO = "+src_code.output_values.rgb+";\n" diff --git a/material_maker/panels/preview_2d/preview_2d.gd b/material_maker/panels/preview_2d/preview_2d.gd index b6fc2db72..dc9a73d10 100644 --- a/material_maker/panels/preview_2d/preview_2d.gd +++ b/material_maker/panels/preview_2d/preview_2d.gd @@ -148,7 +148,7 @@ func export_as_image_file(file_name : String, image_size : Vector2i) -> void: func export_to_reference(image_size : Vector2i): if generator != null: var texture : MMTexture = await generator.render_output_to_texture(output, image_size) - mm_globals.main_window.get_panel("Reference").add_reference(await texture.get_texture()) + mm_globals.main_window.get_panel("Reference").add_reference(ImageTexture.create_from_image(await texture.get_image())) func _on_Preview2D_visibility_changed(): diff --git a/material_maker/tools/painter/painter.gd b/material_maker/tools/painter/painter.gd index 3567d6b75..015bf5bd1 100644 --- a/material_maker/tools/painter/painter.gd +++ b/material_maker/tools/painter/painter.gd @@ -519,6 +519,7 @@ func get_output_code(index : int) -> Dictionary: new_code += source_mask.defs+"\n" new_code += "\nfloat brush_function(vec2 uv) {\n" new_code += "float _seed_variation_ = 0.0;\n" + new_code += "vec4 _controlled_variation_ = vec4(0.0);\n" new_code += source_mask.code+"\n" new_code += "vec2 __brush_box = abs(uv-vec2(0.5));\n" new_code += "return (max(__brush_box.x, __brush_box.y) < 0.5) ? "+source_mask.output_values.f+" : 0.0;\n" @@ -526,6 +527,7 @@ func get_output_code(index : int) -> Dictionary: new_code += source.defs+"\n" new_code += "\nvec4 pattern_function(vec2 uv) {\n" new_code += "float _seed_variation_ = 0.0;\n" + new_code += "vec4 _controlled_variation_ = vec4(0.0);\n" new_code += source.code+"\n" new_code += "return "+source.output_values.rgba+";\n" new_code += "}\n" diff --git a/material_maker/tools/painter/shaders/paint_shader_template.tres b/material_maker/tools/painter/shaders/paint_shader_template.tres index 8bcdcec41..dfb145398 100644 --- a/material_maker/tools/painter/shaders/paint_shader_template.tres +++ b/material_maker/tools/painter/shaders/paint_shader_template.tres @@ -358,6 +358,7 @@ void do_paint_111a(vec4 paint_value, float brush_value, vec4 old_stroke_value, v void main() { const float _seed_variation_ = 0.0; + const vec4 _controlled_variation_ = vec4(0.0); ivec2 pixel = ivec2(gl_GlobalInvocationID.xy)+ivec2(0, mm_chunk_y); ivec2 image_size = imageSize(GENERATED_IMAGE); vec2 UV = vec2(pixel)/image_size; diff --git a/material_maker/windows/export_taa/accumulate_compute.tres b/material_maker/windows/export_taa/accumulate_compute.tres index 2026a346d..6e5ac0871 100644 --- a/material_maker/windows/export_taa/accumulate_compute.tres +++ b/material_maker/windows/export_taa/accumulate_compute.tres @@ -23,6 +23,7 @@ const float seed_variation = 0.0; vec4 mm_image(vec2 uv) { float _seed_variation_ = seed_variation; + vec4 _controlled_variation_ = vec4(0.0); @CODE return @OUTPUT_VALUE; } diff --git a/material_maker/windows/sdf_builder/preview_2d.gdshader b/material_maker/windows/sdf_builder/preview_2d.gdshader index 851f5266a..75ebe5027 100644 --- a/material_maker/windows/sdf_builder/preview_2d.gdshader +++ b/material_maker/windows/sdf_builder/preview_2d.gdshader @@ -58,6 +58,7 @@ float sstep(float v1, float v2) { void fragment() { float _seed_variation_ = 0.0; + vec4 _controlled_variation_ = vec4(0.0); vec2 ratio = preview_2d_size; vec2 uv = preview_2d_center-vec2(0.5)+(UV-0.5)*preview_2d_scale*ratio/min(ratio.x, ratio.y); @@ -65,8 +66,8 @@ void fragment() { float edgewidth = 0.0001; float d = -DIST_FCT(uv, 0, _seed_variation_); - float d2 = -DIST_FCT(uv, int(round(INDEX_UNIFORM)), _seed_variation_); - float d3 = -DIST_FCT(uv, -int(round(INDEX_UNIFORM)), _seed_variation_); + float d2 = -DIST_FCT(uv, int(round(INDEX_UNIFORM)), _seed_variation_, _controlled_variation_); + float d3 = -DIST_FCT(uv, -int(round(INDEX_UNIFORM)), _seed_variation_, _controlled_variation_); float color = 0.5*sstep(0.0, d); color += sstep(abs(d2), 0.002*preview_2d_scale); color += sstep(abs(d3), 0.003*preview_2d_scale); @@ -75,7 +76,7 @@ void fragment() { float metallic; float roughness; vec3 emission; - COLOR_FCT(uv, albedo, metallic, roughness, emission, _seed_variation_); + COLOR_FCT(uv, albedo, metallic, roughness, emission, _seed_variation_, _controlled_variation_); vec4 image; if (view_style == 0) { image = clamp(albedo+vec4(vec3(clamp(color, 0.0, 1.0)), 1.0), vec4(0.0), vec4(1.0)); diff --git a/material_maker/windows/sdf_builder/preview_3d.gdshader b/material_maker/windows/sdf_builder/preview_3d.gdshader index f06406cf6..122e9649b 100644 --- a/material_maker/windows/sdf_builder/preview_3d.gdshader +++ b/material_maker/windows/sdf_builder/preview_3d.gdshader @@ -92,6 +92,7 @@ void vertex() { void fragment() { float _seed_variation_ = 0.0; + vec4 _controlled_variation_ = vec4(0.0); vec3 ro = world_camera; vec3 rd = normalize(world_position - world_camera);