From c9fe27535741156da95f5778ecc6be7ca5bda425 Mon Sep 17 00:00:00 2001 From: Relintai Date: Tue, 12 Oct 2021 19:59:24 +0200 Subject: [PATCH] Processed a 4 more mmg files. --- .../mat_maker_gd/nodes/common/patterns.gd | 61 ++++++++++ .../mat_maker_gd/nodes/common/shapes.gd | 36 ++++++ .../nodes/material_maker_nodes/shape.mmg | 115 ------------------ .../nodes/material_maker_nodes/sphere.mmg | 68 ----------- .../nodes/material_maker_nodes/truchet.mmg | 63 ---------- .../material_maker_nodes/truchet_generic.mmg | 43 ------- 6 files changed, 97 insertions(+), 289 deletions(-) delete mode 100644 game/addons/mat_maker_gd/nodes/material_maker_nodes/shape.mmg delete mode 100644 game/addons/mat_maker_gd/nodes/material_maker_nodes/sphere.mmg delete mode 100644 game/addons/mat_maker_gd/nodes/material_maker_nodes/truchet.mmg delete mode 100644 game/addons/mat_maker_gd/nodes/material_maker_nodes/truchet_generic.mmg diff --git a/game/addons/mat_maker_gd/nodes/common/patterns.gd b/game/addons/mat_maker_gd/nodes/common/patterns.gd index 47d23f90..e4460dc3 100644 --- a/game/addons/mat_maker_gd/nodes/common/patterns.gd +++ b/game/addons/mat_maker_gd/nodes/common/patterns.gd @@ -187,6 +187,33 @@ const Commons = preload("res://addons/mat_maker_gd/nodes/common/commons.gd") #stitch, float, min: 0, max: 10, default: 1, step:1 #width_map, float, default: 1, (does not need input val (label)) (universal input) +#---------------------- +#truchet.mmg + +#Outputs: + +#line: $shape = 1 +#circle: $shape = 2 + +#Output (float) - Shows a greyscale image of the truchet pattern. +#truchet$shape($uv*$size, vec2(float($seed))) + +#Inputs: +#shape, enum, default: 0, values: line, circle +#size, float, default: 4, min: 2, max: 64, step: 1 + +#---------------------- +#truchet_generic.mmg + +#Outputs: + +#Output (color) +#$in(truchet_generic_uv($uv*$size, vec2(float($seed)))) + +#Inputs: +#in, color, default: color(1.0) +#size, float, default: 4, min: 2, max: 64, step: 1 + enum CombinerAxisType { SINE, TRIANGLE, @@ -253,26 +280,48 @@ static func pattern(uv : Vector2, x_scale : float, y_scale : float, ct : int, ca return Commons.mix_pow(x, y); return 0.0 + static func truchet1c(uv : Vector2, pseed : Vector2) -> Color: var f : float = truchet1(uv, pseed) return Color(f, f, f, 1); +#float truchet1(vec2 uv, vec2 seed) { +# vec2 i = floor(uv); +# vec2 f = fract(uv)-vec2(0.5); +# +# return 1.0-abs(abs((2.0*step(rand(i+seed), 0.5)-1.0)*f.x+f.y)-0.5); +#} + static func truchet1(uv : Vector2, pseed : Vector2) -> float: var i : Vector2 = Commons.floorv2(uv); var f : Vector2 = Commons.fractv2(uv) - Vector2(0.5, 0.5); + return 1.0 - abs(abs((2.0*Commons.step(Commons.rand(i+pseed), 0.5)-1.0)*f.x+f.y)-0.5); static func truchet2c(uv : Vector2, pseed : Vector2) -> Color: var f : float = truchet2(uv, pseed) return Color(f, f, f, 1); +#float truchet2(vec2 uv, vec2 seed) { +# vec2 i = floor(uv); +# vec2 f = fract(uv); +# float random = step(rand(i+seed), 0.5); +# +# f.x *= 2.0*random-1.0; +# f.x += 1.0-random; +# +# return 1.0-min(abs(length(f)-0.5), abs(length(1.0-f)-0.5)); +#} + static func truchet2(uv : Vector2, pseed : Vector2) -> float: var i : Vector2 = Commons.floorv2(uv); var f : Vector2 = Commons.fractv2(uv); var random : float = Commons.step(Commons.rand(i+pseed), 0.5); + f.x *= 2.0 * random-1.0; f.x += 1.0 - random; + return 1.0 - min(abs(f.length() - 0.5), abs((Vector2(1, 1) - f).length() - 0.5)); static func weavec(uv : Vector2, count : Vector2, width : float) -> Color: @@ -948,3 +997,15 @@ static func brick2(uv : Vector2, bmin : Vector2, bmax : Vector2, mortar : float, static func bricks_uneven(uv : Vector2, iterations : int, min_size : float, randomness : float, pseed : float) -> Color: return Color() + + +#vec2 truchet_generic_uv(vec2 uv, vec2 seed) { +# vec2 i = floor(uv); +# vec2 f = fract(uv); +# vec2 invert = step(rand2(seed+i), vec2(0.5)); +# +# return f*(vec2(1.0)-invert)+(vec2(1.0)-f)*invert; +#} + +static func truchet_generic_uv(uv : Vector2, pseed : float) -> Vector2: + return Vector2() diff --git a/game/addons/mat_maker_gd/nodes/common/shapes.gd b/game/addons/mat_maker_gd/nodes/common/shapes.gd index ef3c19b3..eae51796 100644 --- a/game/addons/mat_maker_gd/nodes/common/shapes.gd +++ b/game/addons/mat_maker_gd/nodes/common/shapes.gd @@ -3,6 +3,42 @@ extends Reference const Commons = preload("res://addons/mat_maker_gd/nodes/common/commons.gd") +#---------------------- +#sphere.mmg + +#Outputs: + +#Output - (float) - A heightmap of the specified sphere +#sphere($uv, vec2($cx, $cy), $r) + +#Inputs: +#center, vector2, default: 0.5, min: 0, max: 1, step: 0.01 +#radius, float, min: 0, max: 1, default: 0.5, step:0.01 + +#---------------------- +#shape.mmg + +#Outputs: + +#Output - (float) - Shows a white shape on a black background +#shape_$(shape)($(uv), $(sides), $(radius)*$radius_map($uv), $(edge)*$edge_map($uv)) + +#Inputs: +#shape, enum, default: 0, values: circle, ploygon, star, curved_star, rays +#sides, int, min: 2, max: 32, default: 3, step:1 +#radius, float, min: 0, max: 1, default: 1, step:0.01 (universal input) +#edge, float, min: 0, max: 1, default: 0.2, step:0.01 (universal input) + + +#float sphere(vec2 uv, vec2 c, float r) { +# uv -= c; +# uv /= r; +# return 2.0*r*sqrt(max(0.0, 1.0-dot(uv, uv))); +#} + +static func sphere(uv : Vector2, c : Vector2, r : float) -> float: + return 0.0 + #float shape_circle(vec2 uv, float sides, float size, float edge) { # uv = 2.0*uv-1.0; # edge = max(edge, 1.0e-8); diff --git a/game/addons/mat_maker_gd/nodes/material_maker_nodes/shape.mmg b/game/addons/mat_maker_gd/nodes/material_maker_nodes/shape.mmg deleted file mode 100644 index 14d9a018..00000000 --- a/game/addons/mat_maker_gd/nodes/material_maker_nodes/shape.mmg +++ /dev/null @@ -1,115 +0,0 @@ -{ - "name": "shape", - "node_position": { - "x": 0, - "y": 0 - }, - "parameters": { - "edge": 0.1, - "radius": 0.85, - "shape": 1, - "sides": 6 - }, - "shader_model": { - "code": "", - "global": "float shape_circle(vec2 uv, float sides, float size, float edge) {\n uv = 2.0*uv-1.0;\n\tedge = max(edge, 1.0e-8);\n float distance = length(uv);\n return clamp((1.0-distance/size)/edge, 0.0, 1.0);\n}\n\nfloat shape_polygon(vec2 uv, float sides, float size, float edge) {\n uv = 2.0*uv-1.0;\n\tedge = max(edge, 1.0e-8);\n float angle = atan(uv.x, uv.y)+3.14159265359;\n float slice = 6.28318530718/sides;\n return clamp((1.0-(cos(floor(0.5+angle/slice)*slice-angle)*length(uv))/size)/edge, 0.0, 1.0);\n}\n\nfloat shape_star(vec2 uv, float sides, float size, float edge) {\n uv = 2.0*uv-1.0;\n\tedge = max(edge, 1.0e-8);\n float angle = atan(uv.x, uv.y);\n float slice = 6.28318530718/sides;\n return clamp((1.0-(cos(floor(angle*sides/6.28318530718-0.5+2.0*step(fract(angle*sides/6.28318530718), 0.5))*slice-angle)*length(uv))/size)/edge, 0.0, 1.0);\n}\n\nfloat shape_curved_star(vec2 uv, float sides, float size, float edge) {\n uv = 2.0*uv-1.0;\n\tedge = max(edge, 1.0e-8);\n float angle = 2.0*(atan(uv.x, uv.y)+3.14159265359);\n float slice = 6.28318530718/sides;\n return clamp((1.0-cos(floor(0.5+0.5*angle/slice)*2.0*slice-angle)*length(uv)/size)/edge, 0.0, 1.0);\n}\n\nfloat shape_rays(vec2 uv, float sides, float size, float edge) {\n uv = 2.0*uv-1.0;\n\tedge = 0.5*max(edge, 1.0e-8)*size;\n\tfloat slice = 6.28318530718/sides;\n float angle = mod(atan(uv.x, uv.y)+3.14159265359, slice)/slice;\n return clamp(min((size-angle)/edge, angle/edge), 0.0, 1.0);\n}\n\n", - "inputs": [ - { - "default": "1.0", - "label": "3:", - "longdesc": "An input map that affects the shape size", - "name": "radius_map", - "shortdesc": "Size map", - "type": "f" - }, - { - "default": "1.0", - "label": "", - "longdesc": "An input map that affects the edge width", - "name": "edge_map", - "shortdesc": "Edge map", - "type": "f" - } - ], - "instance": "", - "longdesc": "Draws a white shape on a black background", - "name": "Shape", - "outputs": [ - { - "f": "shape_$(shape)($(uv), $(sides), $(radius)*$radius_map($uv), $(edge)*$edge_map($uv))", - "longdesc": "Shows a white shape on a black background", - "shortdesc": "Output", - "type": "f" - } - ], - "parameters": [ - { - "default": 0, - "label": "", - "longdesc": "The type of shape drawn by this node", - "name": "shape", - "shortdesc": "Shape", - "type": "enum", - "values": [ - { - "name": "Circle", - "value": "circle" - }, - { - "name": "Polygon", - "value": "polygon" - }, - { - "name": "Star", - "value": "star" - }, - { - "name": "Curved star", - "value": "curved_star" - }, - { - "name": "Rays", - "value": "rays" - } - ] - }, - { - "control": "None", - "default": 3, - "label": "", - "longdesc": "The number of sides of the generated shape (unused for Circle)", - "max": 32, - "min": 2, - "name": "sides", - "shortdesc": "Sides count", - "step": 1, - "type": "float" - }, - { - "control": "None", - "default": 1, - "label": "", - "longdesc": "The size of the generated shape", - "max": 1, - "min": 0, - "name": "radius", - "shortdesc": "Shape size", - "step": 0.01, - "type": "float" - }, - { - "control": "None", - "default": 0.2, - "label": "", - "longdesc": "The edge width of the generated shape", - "max": 1, - "min": 0, - "name": "edge", - "shortdesc": "Edge width", - "step": 0.01, - "type": "float" - } - ] - }, - "type": "shader" -} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/nodes/material_maker_nodes/sphere.mmg b/game/addons/mat_maker_gd/nodes/material_maker_nodes/sphere.mmg deleted file mode 100644 index 8371e2da..00000000 --- a/game/addons/mat_maker_gd/nodes/material_maker_nodes/sphere.mmg +++ /dev/null @@ -1,68 +0,0 @@ -{ - "name": "sphere", - "node_position": { - "x": 0, - "y": 0 - }, - "parameters": { - "cx": 0.5, - "cy": 0.5, - "r": 0.5 - }, - "shader_model": { - "code": "", - "global": "float sphere(vec2 uv, vec2 c, float r) {\n\tuv -= c;\n\tuv /= r;\n\treturn 2.0*r*sqrt(max(0.0, 1.0-dot(uv, uv)));\n}\n", - "inputs": [ - - ], - "instance": "", - "name": "Sphere", - "outputs": [ - { - "f": "sphere($uv, vec2($cx, $cy), $r)", - "longdesc": "A heightmap of the specified sphere", - "shortdesc": "Output", - "type": "f" - } - ], - "parameters": [ - { - "control": "None", - "default": 0.5, - "label": "Center X", - "longdesc": "Position of the center along the X axis", - "max": 1, - "min": 0, - "name": "cx", - "shortdesc": "Center.x", - "step": 0.01, - "type": "float" - }, - { - "control": "None", - "default": 0.5, - "label": "Center Y", - "longdesc": "Position of the center along the Y axis", - "max": 1, - "min": 0, - "name": "cy", - "shortdesc": "Center.y", - "step": 0.01, - "type": "float" - }, - { - "control": "None", - "default": 0.5, - "label": "Radius", - "longdesc": "Radius of the sphere", - "max": 1, - "min": 0, - "name": "r", - "shortdesc": "Radius", - "step": 0.01, - "type": "float" - } - ] - }, - "type": "shader" -} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/nodes/material_maker_nodes/truchet.mmg b/game/addons/mat_maker_gd/nodes/material_maker_nodes/truchet.mmg deleted file mode 100644 index 33f42681..00000000 --- a/game/addons/mat_maker_gd/nodes/material_maker_nodes/truchet.mmg +++ /dev/null @@ -1,63 +0,0 @@ -{ - "name": "truchet", - "node_position": { - "x": 0, - "y": 0 - }, - "parameters": { - "shape": 0, - "size": 4 - }, - "shader_model": { - "code": "", - "global": "float truchet1(vec2 uv, vec2 seed) {\n vec2 i = floor(uv);\n vec2 f = fract(uv)-vec2(0.5);\n return 1.0-abs(abs((2.0*step(rand(i+seed), 0.5)-1.0)*f.x+f.y)-0.5);\n}\n\nfloat truchet2(vec2 uv, vec2 seed) {\n vec2 i = floor(uv);\n vec2 f = fract(uv);\n float random = step(rand(i+seed), 0.5);\n f.x *= 2.0*random-1.0;\n f.x += 1.0-random;\n return 1.0-min(abs(length(f)-0.5), abs(length(1.0-f)-0.5));\n}\n", - "inputs": [ - - ], - "instance": "", - "longdesc": "Generates a truchet pattern", - "name": "Truchet", - "outputs": [ - { - "f": "truchet$shape($uv*$size, vec2(float($seed)))", - "longdesc": "Shows a greyscale image of the truchet pattern.", - "shortdesc": "Output", - "type": "f" - } - ], - "parameters": [ - { - "default": 0, - "label": "Shape", - "longdesc": "The base shape of each tile of the truchet pattern", - "name": "shape", - "shortdesc": "Shape", - "type": "enum", - "values": [ - { - "name": "Line", - "value": "1" - }, - { - "name": "Circle", - "value": "2" - } - ] - }, - { - "control": "None", - "default": 4, - "label": "Size", - "longdesc": "The number of rows and columns of the truchet pattern", - "max": 64, - "min": 2, - "name": "size", - "shortdesc": "Size", - "step": 1, - "type": "float" - } - ], - "shortdesc": "Truchet pattern" - }, - "type": "shader" -} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/nodes/material_maker_nodes/truchet_generic.mmg b/game/addons/mat_maker_gd/nodes/material_maker_nodes/truchet_generic.mmg deleted file mode 100644 index c529ea83..00000000 --- a/game/addons/mat_maker_gd/nodes/material_maker_nodes/truchet_generic.mmg +++ /dev/null @@ -1,43 +0,0 @@ -{ - "name": "truchet_generic", - "node_position": { - "x": 0, - "y": 0 - }, - "parameters": { - "size": 6 - }, - "shader_model": { - "code": "", - "global": "vec2 truchet_generic_uv(vec2 uv, vec2 seed) {\n vec2 i = floor(uv);\n vec2 f = fract(uv);\n\tvec2 invert = step(rand2(seed+i), vec2(0.5));\n return f*(vec2(1.0)-invert)+(vec2(1.0)-f)*invert;\n}\n", - "inputs": [ - { - "default": "vec4(1.0)", - "label": "", - "name": "in", - "type": "rgba" - } - ], - "instance": "", - "name": "Generic Truchet", - "outputs": [ - { - "rgba": "$in(truchet_generic_uv($uv*$size, vec2(float($seed))))", - "type": "rgba" - } - ], - "parameters": [ - { - "control": "None", - "default": 4, - "label": "Size", - "max": 64, - "min": 2, - "name": "size", - "step": 1, - "type": "float" - } - ] - }, - "type": "shader" -} \ No newline at end of file