diff --git a/game/addons/mat_maker_gd/nodes/common/patterns.gd b/game/addons/mat_maker_gd/nodes/common/patterns.gd index 04f29047..478099e4 100644 --- a/game/addons/mat_maker_gd/nodes/common/patterns.gd +++ b/game/addons/mat_maker_gd/nodes/common/patterns.gd @@ -72,6 +72,45 @@ const Commons = preload("res://addons/mat_maker_gd/nodes/common/commons.gd") #round, float, min: 0, max: 0.5, default: 0.1, step:0.01 (universal input) #corner, float, min: 0, max: 0.5, default: 0.1, step:0.01 +#---------------------- +#bricks_uneven.mmg + +#Outputs: + +#Common +#vec4 $(name_uv)_rect = bricks_uneven($uv, int($iterations), $min_size, $randomness, float($seed)); +#vec4 $(name_uv) = brick2($uv, $(name_uv)_rect.xy, $(name_uv)_rect.zw, $mortar*$mortar_map($uv), $round*$round_map($uv), max(0.00001, $bevel*$bevel_map($uv))); + +#Bricks pattern (float) - A greyscale image that shows the bricks pattern +#$(name_uv).x + +#Random color (rgb) - A random color for each brick +#rand3(fract($(name_uv)_rect.xy)+rand2(vec2(float($seed)))) + +#Position.x (float) - The position of each brick along the X axis", +#$(name_uv).y + +#Position.y (float) - The position of each brick along the Y axis +#$(name_uv).z + +#Brick UV (rgb) - An UV map output for each brick, to be connected to the Map input of a CustomUV node +#brick_uv($uv, $(name_uv)_rect.xy, $(name_uv)_rect.zw, float($seed)) + +#Corner UV (rgb) - An UV map output for each brick corner, to be connected to the Map input of a CustomUV node +#brick_corner_uv($uv, $(name_uv)_rect.xy, $(name_uv)_rect.zw, $mortar*$mortar_map($uv), $corner, float($seed)) + +#Direction (float) - The direction of each brick (white: horizontal, black: vertical) +#0.5*(sign($(name_uv)_rect.z-$(name_uv)_rect.x-$(name_uv)_rect.w+$(name_uv)_rect.y)+1.0) + +#Inputs: +#iterations, int, min: 1, max: 16, default:8, step:1 +#min_size, float, min: 0, max: 0.5, default: 0.3, step:0.01 +#randomness, float, min: 0, max: 1, default: 0.5, step:0.01 +#mortar, float, min: 0, max: 0.5, default: 0.1, step:0.01 (universal input) +#bevel, float, min: 0, max: 0.5, default: 0.1, step:0.01 (universal input) +#round, float, min: 0, max: 0.5, default: 0.1, step:0.01 (universal input) +#corner, float, min: 0, max: 0.5, default: 0.1, step:0.01 + enum CombinerAxisType { SINE, TRIANGLE, @@ -669,3 +708,56 @@ static func bricks_sb(uv : Vector2, count : Vector2, repeat : float, offset : fl size = Vector2(count.x-1.0, count.y-1.0) return Color(corner.x / c.x, corner.y / c.y, (corner.x + size.x) / c.x, (corner.y + size.y) / c.y) + +#vec4 brick2(vec2 uv, vec2 bmin, vec2 bmax, float mortar, float round, float bevel) { +# float color; +# vec2 size = bmax - bmin; +# vec2 center = 0.5*(bmin+bmax); +# vec2 d = abs(uv-center)-0.5*(size)+vec2(round+mortar); +# +# color = length(max(d,vec2(0))) + min(max(d.x,d.y),0.0)-round; +# color = clamp(-color/bevel, 0.0, 1.0); +# +# vec2 tiled_brick_pos = mod(bmin, vec2(1.0, 1.0)); +# +# return vec4(color, center, tiled_brick_pos.x+7.0*tiled_brick_pos.y); +#} + +static func brick2(uv : Vector2, bmin : Vector2, bmax : Vector2, mortar : float, pround : float, bevel : float) -> Color: + return Color() + +#vec4 bricks_uneven(vec2 uv, int iterations, float min_size, float randomness, float seed) { +# vec2 a = vec2(0.0); +# vec2 b = vec2(1.0); +# for (int i = 0; i < iterations; ++i) { +# vec2 size = b-a; +# if (max(size.x, size.y) < min_size) { +# break; +# } +# +# float x = rand(rand2(vec2(rand(a+b), seed)))*randomness+(1.0-randomness)*0.5; +# +# if (size.x > size.y) { +# x *= size.x; +# +# if (uv.x > a.x+x) { +# a.x += x; +# } else { +# b.x = a.x + x; +# } +# } else { +# x *= size.y; +# +# if (uv.y > a.y+x) { +# a.y += x; +# } else { +# b.y = a.y + x; +# } +# } +# } +# +# return vec4(a, b); +#} + +static func bricks_uneven(uv : Vector2, iterations : int, min_size : float, randomness : float, pseed : float) -> Color: + return Color() diff --git a/game/addons/mat_maker_gd/nodes/material_maker_nodes/bricks_nontileable.mmg b/game/addons/mat_maker_gd/nodes/material_maker_nodes/bricks_nontileable.mmg deleted file mode 100644 index 7de37349..00000000 --- a/game/addons/mat_maker_gd/nodes/material_maker_nodes/bricks_nontileable.mmg +++ /dev/null @@ -1,228 +0,0 @@ -{ - "name": "bricks_nontileable", - "node_position": { - "x": 0, - "y": 0 - }, - "parameters": { - "bevel": 0.1, - "columns": 3, - "corner": 0.3, - "mortar": 0.1, - "pattern": 0, - "repeat": 1, - "round": 0, - "row_offset": 0.5, - "rows": 6 - }, - "shader_model": { - "code": "vec4 $(name_uv)_rect = bricks_$pattern($uv, vec2($columns, $rows), $repeat, $row_offset);\nvec4 $(name_uv) = brick($uv, $(name_uv)_rect.xy, $(name_uv)_rect.zw, $mortar*$mortar_map($uv), $round*$round_map($uv), max(0.001, $bevel*$bevel_map($uv)));\n", - "global": "vec3 brick_infinite_random_color(vec2 bmin, vec2 bmax, float seed) {\n\tvec2 center = 0.5*(bmin + bmax);\n\treturn rand3(center + vec2(seed));\n}\n", - "includes": [ - "bricks" - ], - "inputs": [ - { - "default": "1.0", - "label": "6:", - "longdesc": "A map that affects the Mortar parameter", - "name": "mortar_map", - "shortdesc": "Mortar map", - "type": "f" - }, - { - "default": "1.0", - "label": "", - "longdesc": "A map that affects the Bevel parameter", - "name": "bevel_map", - "shortdesc": "Bevel map", - "type": "f" - }, - { - "default": "1.0", - "label": "", - "longdesc": "A map that affects the Round parameter", - "name": "round_map", - "shortdesc": "Round map", - "type": "f" - } - ], - "instance": "", - "longdesc": "Generates different bricks patterns, with many useful outputs.", - "name": "Bricks NonTileable", - "outputs": [ - { - "f": "$(name_uv).x", - "longdesc": "A greyscale image that shows the bricks pattern", - "shortdesc": "Bricks pattern", - "type": "f" - }, - { - "longdesc": "A random color for each brick", - "rgb": "brick_infinite_random_color($(name_uv)_rect.xy, $(name_uv)_rect.zw, float($seed))", - "shortdesc": "Random color", - "type": "rgb" - }, - { - "f": "$(name_uv).y", - "longdesc": "The position of each brick along the X axis", - "shortdesc": "Position.x", - "type": "f" - }, - { - "f": "$(name_uv).z", - "longdesc": "The position of each brick along the Y axis", - "shortdesc": "Position.y", - "type": "f" - }, - { - "longdesc": "An UV map output for each brick, to be connected to the Map input of a CustomUV node", - "rgb": "brick_uv($uv, $(name_uv)_rect.xy, $(name_uv)_rect.zw, float($seed))", - "shortdesc": "Brick UV", - "type": "rgb" - }, - { - "longdesc": "An UV map output for each brick corner, to be connected to the Map input of a CustomUV node", - "rgb": "brick_corner_uv($uv, $(name_uv)_rect.xy, $(name_uv)_rect.zw, $mortar*$mortar_map($uv), $corner, float($seed))", - "shortdesc": "Corner UV", - "type": "rgb" - }, - { - "f": "0.5*(sign($(name_uv)_rect.z-$(name_uv)_rect.x-$(name_uv)_rect.w+$(name_uv)_rect.y)+1.0)", - "longdesc": "The direction of each brick (white: horizontal, black: vertical)", - "shortdesc": "Direction", - "type": "f" - } - ], - "parameters": [ - { - "default": 0, - "label": "", - "longdesc": "The type of brick pattern", - "name": "pattern", - "shortdesc": "Pattern", - "type": "enum", - "values": [ - { - "name": "Running bond", - "value": "rb" - }, - { - "name": "Running bond (2)", - "value": "rb2" - }, - { - "name": "HerringBone", - "value": "hb" - }, - { - "name": "Basket weave", - "value": "bw" - }, - { - "name": "Spanish bond", - "value": "sb" - } - ] - }, - { - "control": "None", - "default": 1, - "label": "Repeat:", - "longdesc": "The number of repetitions of the whole pattern", - "max": 8, - "min": 1, - "name": "repeat", - "shortdesc": "Repeat", - "step": 1, - "type": "float" - }, - { - "control": "None", - "default": 6, - "label": "Rows:", - "longdesc": "The number of rows of a pattern", - "max": 64, - "min": 1, - "name": "rows", - "shortdesc": "Rows", - "step": 1, - "type": "float" - }, - { - "control": "None", - "default": 3, - "label": "Columns:", - "longdesc": "The number of columns of a pattern", - "max": 64, - "min": 1, - "name": "columns", - "shortdesc": "Columns", - "step": 1, - "type": "float" - }, - { - "control": "None", - "default": 0.5, - "label": "Offset:", - "longdesc": "The offset of the pattern (not useful for all patterns)", - "max": 1, - "min": 0, - "name": "row_offset", - "shortdesc": "Offset", - "step": 0.01, - "type": "float" - }, - { - "control": "None", - "default": 0.1, - "label": "Mortar:", - "longdesc": "The width of the space between bricks", - "max": 0.5, - "min": 0, - "name": "mortar", - "shortdesc": "Mortar", - "step": 0.01, - "type": "float" - }, - { - "control": "None", - "default": 0.1, - "label": "Bevel:", - "longdesc": "The width of the edge of each brick", - "max": 0.5, - "min": 0, - "name": "bevel", - "shortdesc": "Bevel", - "step": 0.01, - "type": "float" - }, - { - "control": "None", - "default": 0, - "label": "Round:", - "longdesc": "The radius of the round corners of bricks", - "max": 0.5, - "min": 0, - "name": "round", - "shortdesc": "Round", - "step": 0.01, - "type": "float" - }, - { - "control": "None", - "default": 0.1, - "label": "Corner:", - "longdesc": "The size of the corner part of each brick (only used by the Corner UV output)", - "max": 0.5, - "min": 0, - "name": "corner", - "shortdesc": "Corner", - "step": 0.01, - "type": "float" - } - ], - "shortdesc": "Simple bricks patterns" - }, - "type": "shader" -} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/nodes/material_maker_nodes/bricks_uneven.mmg b/game/addons/mat_maker_gd/nodes/material_maker_nodes/bricks_uneven.mmg deleted file mode 100644 index d54992a3..00000000 --- a/game/addons/mat_maker_gd/nodes/material_maker_nodes/bricks_uneven.mmg +++ /dev/null @@ -1,184 +0,0 @@ -{ - "name": "bricks_uneven", - "node_position": { - "x": 0, - "y": 0 - }, - "parameters": { - "bevel": 0.01, - "corner": 0, - "iterations": 8, - "min_size": 0.3, - "mortar": 0.01, - "randomness": 0.5, - "round": 0 - }, - "shader_model": { - "code": "vec4 $(name_uv)_rect = bricks_uneven($uv, int($iterations), $min_size, $randomness, float($seed));\nvec4 $(name_uv) = brick2($uv, $(name_uv)_rect.xy, $(name_uv)_rect.zw, $mortar*$mortar_map($uv), $round*$round_map($uv), max(0.00001, $bevel*$bevel_map($uv)));\n", - "global": "vec4 brick2(vec2 uv, vec2 bmin, vec2 bmax, float mortar, float round, float bevel) {\n\tfloat color;\n\tvec2 size = bmax - bmin;\n\tvec2 center = 0.5*(bmin+bmax);\n vec2 d = abs(uv-center)-0.5*(size)+vec2(round+mortar);\n color = length(max(d,vec2(0))) + min(max(d.x,d.y),0.0)-round;\n\tcolor = clamp(-color/bevel, 0.0, 1.0);\n\tvec2 tiled_brick_pos = mod(bmin, vec2(1.0, 1.0));\n\treturn vec4(color, center, tiled_brick_pos.x+7.0*tiled_brick_pos.y);\n}\n\nvec4 bricks_uneven(vec2 uv, int iterations, float min_size, float randomness, float seed) {\n\tvec2 a = vec2(0.0);\n\tvec2 b = vec2(1.0);\n\t\n\tfor (int i = 0; i < iterations; ++i) {\n\t\tvec2 size = b-a;\n\t\tif (max(size.x, size.y) < min_size) {\n\t\tbreak;\n\t\t}\n\t\tfloat x = rand(rand2(vec2(rand(a+b), seed)))*randomness+(1.0-randomness)*0.5;\n\t\tif (size.x > size.y) {\n\t\t\tx *= size.x;\n\t\t\tif (uv.x > a.x+x) {\n\t\t\t\ta.x += x;\n\t\t\t} else {\n\t\t\t\tb.x = a.x + x;\n\t\t\t}\n\t\t} else {\n\t\t\tx *= size.y;\n\t\t\tif (uv.y > a.y+x) {\n\t\t\t\ta.y += x;\n\t\t\t} else {\n\t\t\t\tb.y = a.y + x;\n\t\t\t}\n\t\t}\n\t}\n\treturn vec4(a, b);\n}\n", - "includes": [ - "bricks" - ], - "inputs": [ - { - "default": "1.0", - "label": "4:", - "longdesc": "A map that affects the Mortar parameter", - "name": "mortar_map", - "shortdesc": "Mortar map", - "type": "f" - }, - { - "default": "1.0", - "label": "", - "longdesc": "A map that affects the Bevel parameter", - "name": "bevel_map", - "shortdesc": "Bevel map", - "type": "f" - }, - { - "default": "1.0", - "label": "", - "longdesc": "A map that affects the Round parameter", - "name": "round_map", - "shortdesc": "Round map", - "type": "f" - } - ], - "instance": "", - "longdesc": "Generates an uneven bricks pattern.", - "name": "Uneven Bricks", - "outputs": [ - { - "f": "$(name_uv).x", - "longdesc": "A greyscale image that shows the bricks pattern", - "shortdesc": "Bricks pattern", - "type": "f" - }, - { - "longdesc": "A random color for each brick", - "rgb": "rand3(fract($(name_uv)_rect.xy)+rand2(vec2(float($seed))))", - "shortdesc": "Random color", - "type": "rgb" - }, - { - "f": "$(name_uv).y", - "longdesc": "The position of each brick along the X axis", - "shortdesc": "Position.x", - "type": "f" - }, - { - "f": "$(name_uv).z", - "longdesc": "The position of each brick along the Y axis", - "shortdesc": "Position.y", - "type": "f" - }, - { - "longdesc": "An UV map output for each brick, to be connected to the Map input of a CustomUV node", - "rgb": "brick_uv($uv, $(name_uv)_rect.xy, $(name_uv)_rect.zw, float($seed))", - "shortdesc": "Brick UV", - "type": "rgb" - }, - { - "longdesc": "An UV map output for each brick corner, to be connected to the Map input of a CustomUV node", - "rgb": "brick_corner_uv($uv, $(name_uv)_rect.xy, $(name_uv)_rect.zw, $mortar*$mortar_map($uv), $corner, float($seed))", - "shortdesc": "Corner UV", - "type": "rgb" - }, - { - "f": "0.5*(sign($(name_uv)_rect.z-$(name_uv)_rect.x-$(name_uv)_rect.w+$(name_uv)_rect.y)+1.0)", - "longdesc": "The direction of each brick (white: horizontal, black: vertical)", - "shortdesc": "Direction", - "type": "f" - } - ], - "parameters": [ - { - "control": "None", - "default": 8, - "label": "Iterations", - "longdesc": "The number of iterations of the brick split operation", - "max": 16, - "min": 1, - "name": "iterations", - "shortdesc": "Iterations", - "step": 1, - "type": "float" - }, - { - "control": "None", - "default": 0.3, - "label": "Min size:", - "longdesc": "The minimum size of a brick", - "max": 0.5, - "min": 0, - "name": "min_size", - "shortdesc": "Minimum size", - "step": 0.01, - "type": "float" - }, - { - "control": "None", - "default": 0.5, - "label": "Randomness", - "longdesc": "The randomness of the pattern", - "max": 1, - "min": 0, - "name": "randomness", - "shortdesc": "Randomness", - "step": 0.01, - "type": "float" - }, - { - "control": "None", - "default": 0.05, - "label": "Mortar:", - "longdesc": "The width of the space between bricks", - "max": 0.5, - "min": 0, - "name": "mortar", - "shortdesc": "Mortar", - "step": 0.001, - "type": "float" - }, - { - "control": "None", - "default": 0.05, - "label": "Bevel:", - "longdesc": "The width of the edge of each brick", - "max": 0.5, - "min": 0, - "name": "bevel", - "shortdesc": "Bevel", - "step": 0.001, - "type": "float" - }, - { - "control": "None", - "default": 0, - "label": "Round:", - "longdesc": "The radius of the round corners of bricks", - "max": 0.5, - "min": 0, - "name": "round", - "shortdesc": "Round", - "step": 0.01, - "type": "float" - }, - { - "control": "None", - "default": 0.1, - "label": "Corner:", - "longdesc": "The size of the corner part of each brick (only used by the Corner UV output)", - "max": 0.5, - "min": 0, - "name": "corner", - "shortdesc": "Corner", - "step": 0.01, - "type": "float" - } - ], - "shortdesc": "Uneven bricks" - }, - "type": "shader" -} \ No newline at end of file