diff --git a/game/addons/mat_maker_gd/nodes/common/sdf2d.gd b/game/addons/mat_maker_gd/nodes/common/sdf2d.gd index 5dd7be93..1c1eaa8a 100644 --- a/game/addons/mat_maker_gd/nodes/common/sdf2d.gd +++ b/game/addons/mat_maker_gd/nodes/common/sdf2d.gd @@ -3,6 +3,975 @@ extends Reference const Commons = preload("res://addons/mat_maker_gd/nodes/common/commons.gd") +#---------------------- +#sdarc.mmg +#An arc as a signed distance function + +#"outputs": [ +#{ +# "longdesc": "The arc as a signed distance function", +# "sdf2d": "sdArc($uv-vec2(0.5), mod($a1, 360.0)*0.01745329251, mod($a2, 360.0)*0.01745329251, $r1, $r2)", +# "shortdesc": "Output", +# "type": "sdf2d" +#} +#], +#"parameters": [ +#{ +# "control": "Angle1.a", +# "default": 0, +# "label": "Angle 1", +# "longdesc": "The first angle of the arc", +# "max": 180, +# "min": -180, +# "name": "a1", +# "shortdesc": "Angle1", +# "step": 1, +# "type": "float" +#}, +#{ +# "control": "Angle2.a", +# "default": 0, +# "label": "Angle 2", +# "longdesc": "The second angle of the arc", +# "max": 180, +# "min": -180, +# "name": "a2", +# "shortdesc": "Angle2", +# "step": 1, +# "type": "float" +#}, +#{ +# "control": "Radius1.r", +# "default": 0.5, +# "label": "Radius", +# "longdesc": "The radius of the arc", +# "max": 1, +# "min": 0, +# "name": "r1", +# "shortdesc": "Radius", +# "step": 0.01, +# "type": "float" +#}, +#{ +# "control": "Radius11.r", +# "default": 0.1, +# "label": "Width", +# "longdesc": "The width of the shape around the arc", +# "max": 1, +# "min": 0, +# "name": "r2", +# "shortdesc": "Width", +# "step": 0.01, +# "type": "float" +#} +#] + +#---------------------- +#sdboolean.mmg +#Performs a boolean operation (union, intersection or difference) between two shapes + +#"inputs": [ +#{ +# "default": "0.0", +# "label": "", +# "longdesc": "The first shape, defined as a signed distance function", +# "name": "in1", +# "shortdesc": "Input1", +# "type": "sdf2d" +#}, +#{ +# "default": "0.0", +# "label": "", +# "longdesc": "The second shape, defined as a signed distance function", +# "name": "in2", +# "shortdesc": "Input2", +# "type": "sdf2d" +#} +#], +#"outputs": [ +#{ +# "longdesc": "The shape generated by the boolean operation", +# "sdf2d": "$op $in1($uv), $in2($uv))", +# "shortdesc": "Output", +# "type": "sdf2d" +#} +#], +#"parameters": [ +#{ +# "default": 2, +# "label": "", +# "longdesc": "The operation performed by this node", +# "name": "op", +# "shortdesc": "Operation", +# "type": "enum", +# "values": [ +# { +# "name": "Union", +# "value": "min(" +# }, +# { +# "name": "Subtraction", +# "value": "max(-" +# }, +# { +# "name": "Intersection", +# "value": "max(" +# } +# ] +#} +#], + +#---------------------- +#sdbox.mmg +#A rectangle described as a signed distance function + +# "code": "vec2 $(name_uv)_d = abs($uv-vec2($cx+0.5, $cy+0.5))-vec2($w, $h);", +# "outputs": [ +# { +# "longdesc": "The generated signed distance function", +# "sdf2d": "length(max($(name_uv)_d,vec2(0)))+min(max($(name_uv)_d.x,$(name_uv)_d.y),0.0)", +# "shortdesc": "Output", +# "type": "sdf2d" +# } +# ], +# "parameters": [ +# { +# "control": "Rect1.x", +# "default": 0.5, +# "label": "Width", +# "longdesc": "The width of the box", +# "max": 1, +# "min": 0, +# "name": "w", +# "shortdesc": "Width", +# "step": 0.01, +# "type": "float" +# }, +# { +# "control": "Rect1.y", +# "default": 1, +# "label": "Height", +# "longdesc": "The height of the box", +# "max": 1, +# "min": 0, +# "name": "h", +# "shortdesc": "Height", +# "step": 0.01, +# "type": "float" +# }, +# { +# "control": "P1.x", +# "default": 0, +# "label": "Center X", +# "longdesc": "The position of the center of the box on the X axis", +# "max": 1, +# "min": -1, +# "name": "cx", +# "shortdesc": "Center.x", +# "step": 0.01, +# "type": "float" +# }, +# { +# "control": "P1.y", +# "default": 0, +# "label": "Center Y", +# "longdesc": "The position of the center of the box on the Y axis", +# "max": 1, +# "min": -1, +# "name": "cy", +# "shortdesc": "Center.y", +# "step": 0.01, +# "type": "float" +# } +# ], + +#---------------------- +#sdcircle.mmg +#A circle described as a signed distance function + +# "outputs": [ +# { +# "longdesc": "The generated signed distance function", +# "sdf2d": "length($uv-vec2($cx+0.5, $cy+0.5))-$r", +# "shortdesc": "Output", +# "type": "sdf2d" +# } +# ], +# "parameters": [ +# { +# "control": "Radius1.r", +# "default": 0.5, +# "label": "Radius", +# "longdesc": "The radius of the circle", +# "max": 1, +# "min": 0, +# "name": "r", +# "shortdesc": "Radius", +# "step": 0.01, +# "type": "float" +# }, +# { +# "control": "P1.x", +# "default": 0, +# "label": "Center X", +# "longdesc": "The position of the center on the X axis", +# "max": 1, +# "min": -1, +# "name": "cx", +# "shortdesc": "Center.x", +# "step": 0.01, +# "type": "float" +# }, +# { +# "control": "P1.y", +# "default": 0, +# "label": "Center Y", +# "longdesc": "The position of the center on the Y axis", +# "max": 1, +# "min": -1, +# "name": "cy", +# "shortdesc": "Center.y", +# "step": 0.01, +# "type": "float" +# } +# ], + +#---------------------- +#sdcirclerepeat.mmg +#Repeats its input shape around a circle + +# "inputs": [ +# { +# "default": "0.0", +# "label": "", +# "longdesc": "The input shape, defined as a signed distance function", +# "name": "in", +# "shortdesc": "Input", +# "type": "sdf2d" +# } +# ], +# "outputs": [ +# { +# "longdesc": "The shape generated by the repeat operation", +# "sdf2d": "$in(circle_repeat_transform_2d($uv-vec2(0.5), $c)+vec2(0.5))", +# "shortdesc": "Output", +# "type": "sdf2d" +# } +# ], +# "parameters": [ +# { +# "control": "None", +# "default": 4, +# "label": "", +# "longdesc": "The number of repetitions of the input shape around the circle", +# "max": 32, +# "min": 1, +# "name": "c", +# "shortdesc": "Count", +# "step": 1, +# "type": "float" +# } +# ], + + +#---------------------- +#sdelongation.mmg + +# "inputs": [ +# { +# "default": "0.0", +# "label": "", +# "name": "in", +# "type": "sdf2d" +# } +# ], +# "outputs": [ +# { +# "sdf2d": "$in($uv-clamp($uv-vec2(0.5), -vec2($x, $y), vec2($x, $y)))", +# "type": "sdf2d" +# } +# ], +# "parameters": [ +# { +# "control": "Rect1.x", +# "default": 0, +# "label": "X", +# "max": 1, +# "min": 0, +# "name": "x", +# "step": 0.01, +# "type": "float" +# }, +# { +# "control": "Rect1.y", +# "default": 0, +# "label": "Y", +# "max": 1, +# "min": 0, +# "name": "y", +# "step": 0.01, +# "type": "float" +# } +# ] + +#---------------------- +#sdline.mmg +#A line or a capsule shape described as a signed distance function + +# "code": "vec2 $(name_uv)_sdl = sdLine($uv, vec2($ax+0.5, $ay+0.5), vec2($bx+0.5, $by+0.5));", +# "outputs": [ +# { +# "longdesc": "The shape as signed distance function", +# "sdf2d": "$(name_uv)_sdl.x-$r*$profile($(name_uv)_sdl.y)", +# "shortdesc": "Output", +# "type": "sdf2d" +# } +# ], +# "parameters": [ +# { +# "control": "P1.x", +# "default": 0, +# "label": "A X", +# "longdesc": "The position on the X axis of the first point of the line", +# "max": 1, +# "min": -1, +# "name": "ax", +# "shortdesc": "A.x", +# "step": 0.01, +# "type": "float" +# }, +# { +# "control": "P1.y", +# "default": 0, +# "label": "A Y", +# "longdesc": "The position on the Y axis of the first point of the line", +# "max": 1, +# "min": -1, +# "name": "ay", +# "shortdesc": "A.y", +# "step": 0.01, +# "type": "float" +# }, +# { +# "control": "P2.x", +# "default": 1, +# "label": "B X", +# "longdesc": "The position on the X axis of the second point of the line", +# "max": 1, +# "min": -1, +# "name": "bx", +# "shortdesc": "B.x", +# "step": 0.01, +# "type": "float" +# }, +# { +# "control": "P2.y", +# "default": 1, +# "label": "B Y", +# "longdesc": "The position on the Y axis of the second point of the line", +# "max": 1, +# "min": -1, +# "name": "by", +# "shortdesc": "B.y", +# "step": 0.01, +# "type": "float" +# }, +# { +# "control": "Radius1.r", +# "default": 0, +# "label": "Width", +# "longdesc": "The width of the capsule shape around the line", +# "max": 1, +# "min": 0, +# "name": "r", +# "shortdesc": "Width", +# "step": 0.01, +# "type": "float" +# }, +# { +# "default": { +# "points": [ +# { +# "ls": 0, +# "rs": 0, +# "x": 0, +# "y": 1 +# }, +# { +# "ls": 0, +# "rs": 0, +# "x": 1, +# "y": 1 +# } +# ], +# "type": "Curve" +# }, +# "label": "Profile", +# "name": "profile", +# "type": "curve" +# } +# ], + +#---------------------- +#sdmorph.mmg +#Morphs between 2 input shapes + +# "inputs": [ +# { +# "default": "0.0", +# "label": "", +# "longdesc": "The first shape, defined as a signed distance function", +# "name": "in1", +# "shortdesc": "Input1", +# "type": "sdf2d" +# }, +# { +# "default": "0.0", +# "label": "", +# "longdesc": "The second shape, defined as a signed distance function", +# "name": "in2", +# "shortdesc": "Input2", +# "type": "sdf2d" +# } +# ], +# "outputs": [ +# { +# "longdesc": "The generated hybrid shape", +# "sdf2d": "mix($in1($uv), $in2($uv), $amount)", +# "shortdesc": "Output", +# "type": "sdf2d" +# } +# ], +# "parameters": [ +# { +# "control": "None", +# "default": 0.5, +# "label": "", +# "longdesc": "The amount of the second input in the result", +# "max": 1, +# "min": 0, +# "name": "amount", +# "shortdesc": "Amount", +# "step": 0.01, +# "type": "float" +# } +# ], + +#---------------------- +#sdngon.mmg (inc sdrotate.mmg, sdcirclerepeat.mmg) +#An n-gon described as a signed distance function + +# "outputs": [ +# { +# "longdesc": "The n-gon as a signed distance function", +# "sdf2d": "sdNgon(sdf2d_rotate($uv-vec2($cx, $cy), $rot*0.01745329251-1.57079632679)-vec2(0.5), $r, $n)", +# "shortdesc": "Output", +# "type": "sdf2d" +# } +# ], +# "parameters": [ +# { +# "control": "None", +# "default": 3, +# "label": "N", +# "longdesc": "The number of sides of the n-gon", +# "max": 12, +# "min": 3, +# "name": "n", +# "shortdesc": "N", +# "step": 1, +# "type": "float" +# }, +# { +# "control": "Radius1.r", +# "default": 0.5, +# "label": "Radius", +# "longdesc": "The radius of the n-gon", +# "max": 1, +# "min": 0, +# "name": "r", +# "shortdesc": "Radius", +# "step": 0.01, +# "type": "float" +# }, +# { +# "control": "Radius1.a", +# "default": 0, +# "label": "Rotation", +# "longdesc": "The rotation of the n-gon", +# "max": 180, +# "min": -180, +# "name": "rot", +# "shortdesc": "Rotation", +# "step": 0.01, +# "type": "float" +# }, +# { +# "control": "P1.x", +# "default": 0, +# "label": "Center X", +# "longdesc": "The position of the center on the X axis", +# "max": 0.5, +# "min": -0.5, +# "name": "cx", +# "shortdesc": "Center.x", +# "step": 0.01, +# "type": "float" +# }, +# { +# "control": "P1.y", +# "default": 0, +# "label": "Center Y", +# "longdesc": "The position of the center on the Y axis", +# "max": 0.5, +# "min": -0.5, +# "name": "cy", +# "shortdesc": "Center.y", +# "step": 0.01, +# "type": "float" +# } +# ], + +#---------------------- +#sdpolygon.mmg +#A polygon as a signed distance function + +# "instance": "float sdPolygon_$(name)(vec2 p) {vec2 v[] = $polygon;int l = v.length(); float d = dot(p-v[0],p-v[0]); float s = 1.0;int j = l-1; for(int i=0; i=v[i].y,p.ye.y*w.x); if( all(c) || all(not(c)) ) s*=-1.0;j=i; } return s*sqrt(d);}", +# "outputs": [ +# { +# "longdesc": "The polygon as a signed distance function", +# "sdf2d": "sdPolygon_$(name)($uv)", +# "shortdesc": "Output", +# "type": "sdf2d" +# } +# ], +# "parameters": [ +# { +# "default": { +# "points": [ +# { +# "x": 0.2, +# "y": 0.2 +# }, +# { +# "x": 0.4, +# "y": 0.7 +# }, +# { +# "x": 0.7, +# "y": 0.4 +# } +# ], +# "type": "Polygon" +# }, +# "label": "", +# "longdesc": "The polygon to be drawn", +# "name": "polygon", +# "shortdesc": "Polygon", +# "type": "polygon" +# } +# ], + +#---------------------- +#sdrepeat.mmg +#Repeats its input shape on a grid.This node does not support overlapping between instances. + +# "inputs": [ +# { +# "default": "0.0", +# "label": "", +# "longdesc": "The input shape, defined as a signed distance function", +# "name": "in", +# "shortdesc": "Input", +# "type": "sdf2d" +# } +# ], +# "outputs": [ +# { +# "longdesc": "The shape generated by the repeat operation", +# "sdf2d": "$in(repeat_2d($uv, vec2(1.0/$rx, 1.0/$ry), float($seed), $r))", +# "shortdesc": "Output", +# "type": "sdf2d" +# } +# ], +# "parameters": [ +# { +# "control": "None", +# "default": 4, +# "label": "X", +# "longdesc": "The number of columns in the grid", +# "max": 32, +# "min": 1, +# "name": "rx", +# "shortdesc": "Columns", +# "step": 1, +# "type": "float" +# }, +# { +# "control": "None", +# "default": 4, +# "label": "Y", +# "longdesc": "The number of lines in the grid", +# "max": 32, +# "min": 1, +# "name": "ry", +# "shortdesc": "Lines", +# "step": 1, +# "type": "float" +# }, +# { +# "control": "None", +# "default": 0.5, +# "label": "R", +# "longdesc": "The amount of random rotation on each instance of the input shape", +# "max": 1, +# "min": 0, +# "name": "r", +# "shortdesc": "Rotation", +# "step": 0.01, +# "type": "float" +# } +# ], + +#---------------------- +#sdrhombus.mmg +#A rhombus described as a signed distance function + +# "outputs": [ +# { +# "longdesc": "The rhombus as a signed distance function", +# "sdf2d": "sdRhombus($uv-vec2($cx+0.5, $cy+0.5), vec2($w, $h))", +# "shortdesc": "Output", +# "type": "sdf2d" +# } +# ], +# "parameters": [ +# { +# "control": "Rect1.x", +# "default": 0.5, +# "label": "Width", +# "longdesc": "The width of the rhombus", +# "max": 1, +# "min": 0, +# "name": "w", +# "shortdesc": "Width", +# "step": 0.01, +# "type": "float" +# }, +# { +# "control": "Rect1.y", +# "default": 1, +# "label": "Height", +# "longdesc": "The height of the rhombus", +# "max": 1, +# "min": 0, +# "name": "h", +# "shortdesc": "Height", +# "step": 0.01, +# "type": "float" +# }, +# { +# "control": "P1.x", +# "default": 0, +# "label": "Center X", +# "longdesc": "The position of the center on the X axis", +# "max": 1, +# "min": -1, +# "name": "cx", +# "shortdesc": "Center.x", +# "step": 0.01, +# "type": "float" +# }, +# { +# "control": "P1.y", +# "default": 0, +# "label": "Center Y", +# "longdesc": "The position of the center on the Y axis", +# "max": 1, +# "min": -1, +# "name": "cy", +# "shortdesc": "Center.y", +# "step": 0.01, +# "type": "float" +# } +# ], + +#---------------------- +#sdrotate.mmg +#Rotates its input shape described as a signed distance function + +# "inputs": [ +# { +# "default": "0.0", +# "label": "", +# "longdesc": "The input shape, defined as a signed distance function", +# "name": "in", +# "shortdesc": "Input", +# "type": "sdf2d" +# } +# ], +# "outputs": [ +# { +# "longdesc": "The rotated shape", +# "sdf2d": "$in(sdf2d_rotate($uv, $a*0.01745329251))", +# "shortdesc": "Output", +# "type": "sdf2d" +# } +# ], +# "parameters": [ +# { +# "control": "Radius1.a", +# "default": 0, +# "label": "", +# "longdesc": "The rotation angle", +# "max": 180, +# "min": -180, +# "name": "a", +# "shortdesc": "Angle", +# "step": 1, +# "type": "float" +# } +# ], + +#---------------------- +#sdroundedshape.mmg +#Dilates an input shape into a rounded shape + +# "inputs": [ +# { +# "default": "0.0", +# "label": "", +# "longdesc": "The input shape, defined as a signed distance function", +# "name": "in", +# "shortdesc": "Input", +# "type": "sdf2d" +# } +# ], +# "outputs": [ +# { +# "longdesc": "The shape generated by the operation", +# "sdf2d": "$in($uv)-$r", +# "shortdesc": "Output", +# "type": "sdf2d" +# } +# ], +# "parameters": [ +# { +# "control": "None", +# "default": 0, +# "label": "", +# "longdesc": "The length of the dilate operation", +# "max": 1, +# "min": 0, +# "name": "r", +# "shortdesc": "Radius", +# "step": 0.01, +# "type": "float" +# } +# ], + +#---------------------- +#sdscale.mmg +#Scales its input shape described as a signed distance function + +# "inputs": [ +# { +# "default": "0.0", +# "label": "", +# "longdesc": "The input shape, defined as a signed distance function", +# "name": "in", +# "shortdesc": "Input", +# "type": "sdf2d" +# } +# ], +# "outputs": [ +# { +# "longdesc": "The generated scaled shape", +# "sdf2d": "$in(($uv-vec2(0.5))/$s+vec2(0.5))*$s", +# "shortdesc": "Output", +# "type": "sdf2d" +# } +# ], +# "parameters": [ +# { +# "control": "Scale1.x", +# "default": 1, +# "label": "", +# "longdesc": "The scale of the transform", +# "max": 5, +# "min": 0, +# "name": "s", +# "shortdesc": "Scale", +# "step": 0.01, +# "type": "float" +# } +# ], + +#---------------------- +#sdshow.mmg +#Creates a greyscale image from a shape described as a 2D Signed Distance Function + +# "inputs": [ +# { +# "default": "0.0", +# "label": "", +# "longdesc": "The input shape", +# "name": "in", +# "shortdesc": "Input", +# "type": "sdf2d" +# } +# ], +# "outputs": [ +# { +# "f": "clamp($base-$in($uv)/max($bevel, 0.00001), 0.0, 1.0)", +# "longdesc": "Shows the shape as a greyscale image", +# "shortdesc": "Output", +# "type": "f" +# } +# ], +# "parameters": [ +# { +# "control": "None", +# "default": 0, +# "label": "Bevel", +# "longdesc": "The width of the gradient at the edges of the shape", +# "max": 1, +# "min": 0, +# "name": "bevel", +# "shortdesc": "Bevel", +# "step": 0.01, +# "type": "float" +# }, +# { +# "control": "None", +# "default": 0, +# "label": "Base", +# "longdesc": "The base value of the output", +# "max": 1, +# "min": 0, +# "name": "base", +# "shortdesc": "Base", +# "step": 0.01, +# "type": "float" +# } +# ], + +#---------------------- +#sdsmoothboolean.mmg +#Performs a smooth boolean operation (union, intersection or difference) between two shapes + +# "inputs": [ +# { +# "default": "0.0", +# "label": "", +# "longdesc": "The first shape, defined as a signed distance function", +# "name": "in1", +# "shortdesc": "Input1", +# "type": "sdf2d" +# }, +# { +# "default": "0.0", +# "label": "", +# "longdesc": "The second shape, defined as a signed distance function", +# "name": "in2", +# "shortdesc": "Input2", +# "type": "sdf2d" +# } +# ], +# "outputs": [ +# { +# "longdesc": "The shape generated by the boolean operation", +# "sdf2d": "sdSmooth$op($in1($uv), $in2($uv), $k)", +# "shortdesc": "Output", +# "type": "sdf2d" +# } +# ], +# "parameters": [ +# { +# "default": 0, +# "label": "", +# "longdesc": "The operation performed by this node", +# "name": "op", +# "shortdesc": "Operation", +# "type": "enum", +# "values": [ +# { +# "name": "Union", +# "value": "Union" +# }, +# { +# "name": "Subtraction", +# "value": "Subtraction" +# }, +# { +# "name": "Intersection", +# "value": "Intersection" +# } +# ] +# }, +# { +# "control": "None", +# "default": 0, +# "label": "", +# "longdesc": "The smoothness of the boolean operation", +# "max": 1, +# "min": 0, +# "name": "k", +# "shortdesc": "Smoothness", +# "step": 0.01, +# "type": "float" +# } +# ], + +#---------------------- +#sdtranslate.mmg +#Translates its input shape described as signed distance function + +# "inputs": [ +# { +# "default": "0.0", +# "label": "", +# "longdesc": "The input shape, defined as a signed distance function", +# "name": "in", +# "shortdesc": "Input", +# "type": "sdf2d" +# } +# ], +# "outputs": [ +# { +# "longdesc": "The translated shape", +# "sdf2d": "$in($uv-vec2($x, $y))", +# "shortdesc": "Output", +# "type": "sdf2d" +# } +# ], +# "parameters": [ +# { +# "control": "P1.x", +# "default": 0, +# "label": "X", +# "longdesc": "The translation along the X axis", +# "max": 1, +# "min": -1, +# "name": "x", +# "shortdesc": "Translate.x", +# "step": 0.01, +# "type": "float" +# }, +# { +# "control": "P1.y", +# "default": 0, +# "label": "Y", +# "longdesc": "The translation along the Y axis", +# "max": 1, +# "min": -1, +# "name": "y", +# "shortdesc": "Translate.y", +# "step": 0.01, +# "type": "float" +# } +# ], + static func sdf_show(val : float, bevel : float) -> Color: var f : float = clamp(-val / max(bevel, 0.00001), 0.0, 1.0); @@ -42,15 +1011,39 @@ static func sdf_rhombus(uv : Vector2, c : Vector2, wh : Vector2) -> float: static func sdf_arc(uv : Vector2, a : Vector2, r : Vector2) -> float: return sdArc(uv - Vector2(0.5, 0.5), Commons.modf(a.x, 360.0) * 0.01745329251, Commons.modf(a.y, 360.0)*0.01745329251, r.x, r.y) +#float sdr_ndot(vec2 a, vec2 b) { +# return a.x*b.x - a.y*b.y; +#} + static func sdr_ndot(a : Vector2, b : Vector2) -> float: return a.x * b.x - a.y * b.y; +#float sdRhombus(in vec2 p, in vec2 b) { +# vec2 q = abs(p); +# float h = clamp((-2.0*sdr_ndot(q,b)+sdr_ndot(b,b))/dot(b,b),-1.0,1.0); +# float d = length( q - 0.5*b*vec2(1.0-h,1.0+h) ); +# return d * sign( q.x*b.y + q.y*b.x - b.x*b.y ); +#} + static func sdRhombus(p : Vector2, b : Vector2) -> float: var q : Vector2 = Commons.absv2(p); var h : float = clamp((-2.0 * sdr_ndot(q,b) + sdr_ndot(b,b)) / b.dot(b), -1.0, 1.0); var d : float = ( q - 0.5*b * Vector2(1.0-h, 1.0+h)).length() return d * sign(q.x*b.y + q.y*b.x - b.x*b.y) +#float sdArc(vec2 p, float a1, float a2, float ra, float rb) { +# float amid = 0.5*(a1+a2)+1.6+3.14*step(a1, a2); +# float alength = 0.5*(a1-a2)-1.6+3.14*step(a1, a2); +# +# vec2 sca = vec2(cos(amid), sin(amid)); +# vec2 scb = vec2(cos(alength), sin(alength)); +# p *= mat2(vec2(sca.x,sca.y),vec2(-sca.y,sca.x)); +# p.x = abs(p.x); +# +# float k = (scb.y*p.x>scb.x*p.y) ? dot(p.xy,scb) : length(p.xy); +# return sqrt( dot(p,p) + ra*ra - 2.0*ra*k ) - rb; +#} + static func sdArc(p : Vector2, a1 : float, a2 : float, ra : float, rb : float) -> float: var amid : float = 0.5*(a1+a2)+1.6+3.14 * Commons.step(a1, a2); var alength : float = 0.5*(a1-a2)-1.6+3.14 * Commons.step(a1, a2); @@ -106,6 +1099,12 @@ static func sdf_annular_shape(a : float, r : float) -> float: static func sdf_morph(a : float, b : float, amount : float) -> float: return lerp(a, b, amount) +#vec2 sdLine(vec2 p, vec2 a, vec2 b) { +# vec2 pa = p-a, ba = b-a; +# float h = clamp(dot(pa,ba)/dot(ba,ba), 0.0, 1.0); +# return vec2(length(pa-ba*h), h); +#} + static func sdLine(p : Vector2, a : Vector2, b : Vector2) -> float: var pa : Vector2 = p - a var ba : Vector2 = b - a @@ -119,6 +1118,16 @@ static func sdLine(p : Vector2, a : Vector2, b : Vector2) -> float: #func sdf_translate(a : float, x : float, y : float) -> float: # return lerp(a, b, amount) +#vec2 sdf2d_rotate(vec2 uv, float a) { +# vec2 rv; +# float c = cos(a); +# float s = sin(a); +# uv -= vec2(0.5); +# rv.x = uv.x*c+uv.y*s; +# rv.y = -uv.x*s+uv.y*c; +# return rv+vec2(0.5); +#} + static func sdf2d_rotate(uv : Vector2, a : float) -> Vector2: var rv : Vector2; var c : float = cos(a); @@ -197,3 +1206,75 @@ static func sdBezier(pos : Vector2, A : Vector2, B : Vector2, C : Vector2) -> Ve # return Vector2(rvx, sqrt(res)*sign(sgn)); + +#vec2 circle_repeat_transform_2d(vec2 p, float count) { +# float r = 6.28/count; +# float pa = atan(p.x, p.y); +# float a = mod(pa+0.5*r, r)-0.5*r; +# +# vec2 rv; +# +# float c = cos(a-pa); +# float s = sin(a-pa); +# +# rv.x = p.x*c+p.y*s; +# rv.y = -p.x*s+p.y*c; +# +# return rv; +#} + +static func circle_repeat_transform_2d(pos : Vector2, count : float) -> Vector2: + return Vector2() + +#float sdNgon(vec2 p, float r, float n) { +# float PI = 3.1415926535; +# p = circle_repeat_transform_2d(p, n); +# vec2 d = abs(p)-vec2(r*tan(3.14159265359/n), r); +# return p.y < r ? p.y-r : length(max(d,vec2(0)))+min(max(d.x,d.y),0.0); +#} + +static func sdNgon(pos : Vector2, r : float, n : float) -> Vector2: + return Vector2() + + +#vec2 repeat_2d(vec2 p, vec2 r, float seed, float randomness) { +# p -= vec2(0.5); +# float a = (rand(floor(mod((p.xy+0.5*r.xy)/r.xy, 1.0/r.xy)+vec2(seed)))-0.5)*6.28*randomness; +# p = mod(p+0.5*r,r)-0.5*r; +# vec2 rv; +# float c = cos(a); +# float s = sin(a); +# rv.x = p.x*c+p.y*s; +# rv.y = -p.x*s+p.y*c; +# return rv+vec2(0.5); +#} + +static func repeat_2d(pos : Vector2, r : Vector2, pseed : float, randomness : float) -> Vector2: + return Vector2() + + +#float sdSmoothUnion( float d1, float d2, float k ) { +# float h = clamp( 0.5 + 0.5*(d2-d1)/k, 0.0, 1.0 ); +# return mix( d2, d1, h ) - k*h*(1.0-h); +#} + +static func sdSmoothUnion(d1 : float, d2 : float, k : float) -> float: + return 0.0 + +#float sdSmoothSubtraction( float d1, float d2, float k ) { +# float h = clamp( 0.5 - 0.5*(d2+d1)/k, 0.0, 1.0 ); +# return mix( d2, -d1, h ) + k*h*(1.0-h); +#} + +static func sdSmoothSubtraction(d1 : float, d2 : float, k : float) -> float: + return 0.0 + +#float sdSmoothIntersection( float d1, float d2, float k ) { +# float h = clamp( 0.5 - 0.5*(d2-d1)/k, 0.0, 1.0 ); +# return mix( d2, d1, h ) + k*h*(1.0-h); +#} + +static func sdSmoothIntersection(d1 : float, d2 : float, k : float) -> float: + return 0.0 + + diff --git a/game/addons/mat_maker_gd/nodes/material_maker_nodes/sdarc.mmg b/game/addons/mat_maker_gd/nodes/material_maker_nodes/sdarc.mmg deleted file mode 100644 index e82e476c..00000000 --- a/game/addons/mat_maker_gd/nodes/material_maker_nodes/sdarc.mmg +++ /dev/null @@ -1,83 +0,0 @@ -{ - "name": "sdarc", - "node_position": { - "x": 0, - "y": 0 - }, - "parameters": { - "a1": 30, - "a2": 150, - "r1": 0.3, - "r2": 0.1 - }, - "shader_model": { - "code": "", - "global": "float sdArc(vec2 p, float a1, float a2, float ra, float rb) {\n\tfloat amid = 0.5*(a1+a2)+1.6+3.14*step(a1, a2);\n\tfloat alength = 0.5*(a1-a2)-1.6+3.14*step(a1, a2);\n\tvec2 sca = vec2(cos(amid), sin(amid));\n\tvec2 scb = vec2(cos(alength), sin(alength));\n p *= mat2(vec2(sca.x,sca.y),vec2(-sca.y,sca.x));\n p.x = abs(p.x);\n float k = (scb.y*p.x>scb.x*p.y) ? dot(p.xy,scb) : length(p.xy);\n return sqrt( dot(p,p) + ra*ra - 2.0*ra*k ) - rb;\n}\n", - "inputs": [ - - ], - "instance": "", - "longdesc": "An arc as a signed distance function", - "name": "sdArc", - "outputs": [ - { - "longdesc": "The arc as a signed distance function", - "sdf2d": "sdArc($uv-vec2(0.5), mod($a1, 360.0)*0.01745329251, mod($a2, 360.0)*0.01745329251, $r1, $r2)", - "shortdesc": "Output", - "type": "sdf2d" - } - ], - "parameters": [ - { - "control": "Angle1.a", - "default": 0, - "label": "Angle 1", - "longdesc": "The first angle of the arc", - "max": 180, - "min": -180, - "name": "a1", - "shortdesc": "Angle1", - "step": 1, - "type": "float" - }, - { - "control": "Angle2.a", - "default": 0, - "label": "Angle 2", - "longdesc": "The second angle of the arc", - "max": 180, - "min": -180, - "name": "a2", - "shortdesc": "Angle2", - "step": 1, - "type": "float" - }, - { - "control": "Radius1.r", - "default": 0.5, - "label": "Radius", - "longdesc": "The radius of the arc", - "max": 1, - "min": 0, - "name": "r1", - "shortdesc": "Radius", - "step": 0.01, - "type": "float" - }, - { - "control": "Radius11.r", - "default": 0.1, - "label": "Width", - "longdesc": "The width of the shape around the arc", - "max": 1, - "min": 0, - "name": "r2", - "shortdesc": "Width", - "step": 0.01, - "type": "float" - } - ], - "shortdesc": "sdArc" - }, - "type": "shader" -} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/nodes/material_maker_nodes/sdboolean.mmg b/game/addons/mat_maker_gd/nodes/material_maker_nodes/sdboolean.mmg deleted file mode 100644 index 093a2a64..00000000 --- a/game/addons/mat_maker_gd/nodes/material_maker_nodes/sdboolean.mmg +++ /dev/null @@ -1,69 +0,0 @@ -{ - "name": "sdboolean", - "node_position": { - "x": 0, - "y": 0 - }, - "parameters": { - "op": 0 - }, - "shader_model": { - "code": "", - "global": "", - "inputs": [ - { - "default": "0.0", - "label": "", - "longdesc": "The first shape, defined as a signed distance function", - "name": "in1", - "shortdesc": "Input1", - "type": "sdf2d" - }, - { - "default": "0.0", - "label": "", - "longdesc": "The second shape, defined as a signed distance function", - "name": "in2", - "shortdesc": "Input2", - "type": "sdf2d" - } - ], - "instance": "", - "longdesc": "Performs a boolean operation (union, intersection or difference) between two shapes", - "name": "sdBoolean", - "outputs": [ - { - "longdesc": "The shape generated by the boolean operation", - "sdf2d": "$op $in1($uv), $in2($uv))", - "shortdesc": "Output", - "type": "sdf2d" - } - ], - "parameters": [ - { - "default": 2, - "label": "", - "longdesc": "The operation performed by this node", - "name": "op", - "shortdesc": "Operation", - "type": "enum", - "values": [ - { - "name": "Union", - "value": "min(" - }, - { - "name": "Subtraction", - "value": "max(-" - }, - { - "name": "Intersection", - "value": "max(" - } - ] - } - ], - "shortdesc": "sdBoolean" - }, - "type": "shader" -} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/nodes/material_maker_nodes/sdbox.mmg b/game/addons/mat_maker_gd/nodes/material_maker_nodes/sdbox.mmg deleted file mode 100644 index b7db8d52..00000000 --- a/game/addons/mat_maker_gd/nodes/material_maker_nodes/sdbox.mmg +++ /dev/null @@ -1,83 +0,0 @@ -{ - "name": "sdbox", - "node_position": { - "x": 0, - "y": 0 - }, - "parameters": { - "cx": 0, - "cy": 0, - "h": 0.2, - "w": 0.3 - }, - "shader_model": { - "code": "vec2 $(name_uv)_d = abs($uv-vec2($cx+0.5, $cy+0.5))-vec2($w, $h);\n", - "global": "", - "inputs": [ - - ], - "instance": "", - "longdesc": "A rectangle described as a signed distance function", - "name": "sdBox", - "outputs": [ - { - "longdesc": "The generated signed distance function", - "sdf2d": "length(max($(name_uv)_d,vec2(0)))+min(max($(name_uv)_d.x,$(name_uv)_d.y),0.0)", - "shortdesc": "Output", - "type": "sdf2d" - } - ], - "parameters": [ - { - "control": "Rect1.x", - "default": 0.5, - "label": "Width", - "longdesc": "The width of the box", - "max": 1, - "min": 0, - "name": "w", - "shortdesc": "Width", - "step": 0.01, - "type": "float" - }, - { - "control": "Rect1.y", - "default": 1, - "label": "Height", - "longdesc": "The height of the box", - "max": 1, - "min": 0, - "name": "h", - "shortdesc": "Height", - "step": 0.01, - "type": "float" - }, - { - "control": "P1.x", - "default": 0, - "label": "Center X", - "longdesc": "The position of the center of the box on the X axis", - "max": 1, - "min": -1, - "name": "cx", - "shortdesc": "Center.x", - "step": 0.01, - "type": "float" - }, - { - "control": "P1.y", - "default": 0, - "label": "Center Y", - "longdesc": "The position of the center of the box on the Y axis", - "max": 1, - "min": -1, - "name": "cy", - "shortdesc": "Center.y", - "step": 0.01, - "type": "float" - } - ], - "shortdesc": "sdBox" - }, - "type": "shader" -} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/nodes/material_maker_nodes/sdcircle.mmg b/game/addons/mat_maker_gd/nodes/material_maker_nodes/sdcircle.mmg deleted file mode 100644 index 8f73a196..00000000 --- a/game/addons/mat_maker_gd/nodes/material_maker_nodes/sdcircle.mmg +++ /dev/null @@ -1,70 +0,0 @@ -{ - "name": "sdcircle", - "node_position": { - "x": 0, - "y": 0 - }, - "parameters": { - "cx": 0, - "cy": 0, - "r": 0.4 - }, - "shader_model": { - "code": "", - "global": "", - "inputs": [ - - ], - "instance": "", - "longdesc": "A circle described as a signed distance function", - "name": "sdCircle", - "outputs": [ - { - "longdesc": "The generated signed distance function", - "sdf2d": "length($uv-vec2($cx+0.5, $cy+0.5))-$r", - "shortdesc": "Output", - "type": "sdf2d" - } - ], - "parameters": [ - { - "control": "Radius1.r", - "default": 0.5, - "label": "Radius", - "longdesc": "The radius of the circle", - "max": 1, - "min": 0, - "name": "r", - "shortdesc": "Radius", - "step": 0.01, - "type": "float" - }, - { - "control": "P1.x", - "default": 0, - "label": "Center X", - "longdesc": "The position of the center on the X axis", - "max": 1, - "min": -1, - "name": "cx", - "shortdesc": "Center.x", - "step": 0.01, - "type": "float" - }, - { - "control": "P1.y", - "default": 0, - "label": "Center Y", - "longdesc": "The position of the center on the Y axis", - "max": 1, - "min": -1, - "name": "cy", - "shortdesc": "Center.y", - "step": 0.01, - "type": "float" - } - ], - "shortdesc": "sdCircle" - }, - "type": "shader" -} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/nodes/material_maker_nodes/sdcirclerepeat.mmg b/game/addons/mat_maker_gd/nodes/material_maker_nodes/sdcirclerepeat.mmg deleted file mode 100644 index fd288b95..00000000 --- a/game/addons/mat_maker_gd/nodes/material_maker_nodes/sdcirclerepeat.mmg +++ /dev/null @@ -1,51 +0,0 @@ -{ - "name": "sdcirclerepeat", - "node_position": { - "x": 0, - "y": 0 - }, - "parameters": { - "c": 6 - }, - "shader_model": { - "code": "", - "global": "vec2 circle_repeat_transform_2d(vec2 p, float count) {\n\tfloat r = 6.28/count;\n\tfloat pa = atan(p.x, p.y);\n\tfloat a = mod(pa+0.5*r, r)-0.5*r;\n\tvec2 rv;\n\tfloat c = cos(a-pa);\n\tfloat s = sin(a-pa);\n\trv.x = p.x*c+p.y*s;\n\trv.y = -p.x*s+p.y*c;\n\treturn rv;\n}\n", - "inputs": [ - { - "default": "0.0", - "label": "", - "longdesc": "The input shape, defined as a signed distance function", - "name": "in", - "shortdesc": "Input", - "type": "sdf2d" - } - ], - "instance": "", - "longdesc": "Repeats its input shape around a circle", - "name": "Circle Repeat", - "outputs": [ - { - "longdesc": "The shape generated by the repeat operation", - "sdf2d": "$in(circle_repeat_transform_2d($uv-vec2(0.5), $c)+vec2(0.5))", - "shortdesc": "Output", - "type": "sdf2d" - } - ], - "parameters": [ - { - "control": "None", - "default": 4, - "label": "", - "longdesc": "The number of repetitions of the input shape around the circle", - "max": 32, - "min": 1, - "name": "c", - "shortdesc": "Count", - "step": 1, - "type": "float" - } - ], - "shortdesc": "Circle Repeat" - }, - "type": "shader" -} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/nodes/material_maker_nodes/sdelongation.mmg b/game/addons/mat_maker_gd/nodes/material_maker_nodes/sdelongation.mmg deleted file mode 100644 index adc95c5f..00000000 --- a/game/addons/mat_maker_gd/nodes/material_maker_nodes/sdelongation.mmg +++ /dev/null @@ -1,62 +0,0 @@ -{ - "name": "sdelongation", - "node_position": { - "x": 0, - "y": 0 - }, - "parameters": { - "bevel": 0, - "cx": 0, - "cy": 0, - "h": 0.08, - "k": 0.15, - "op": 0, - "r": 0.08, - "w": 0.28, - "x": 0, - "y": 0 - }, - "shader_model": { - "code": "", - "global": "", - "inputs": [ - { - "default": "0.0", - "label": "", - "name": "in", - "type": "sdf2d" - } - ], - "instance": "", - "name": "sdElongation", - "outputs": [ - { - "sdf2d": "$in($uv-clamp($uv-vec2(0.5), -vec2($x, $y), vec2($x, $y)))", - "type": "sdf2d" - } - ], - "parameters": [ - { - "control": "Rect1.x", - "default": 0, - "label": "X", - "max": 1, - "min": 0, - "name": "x", - "step": 0.01, - "type": "float" - }, - { - "control": "Rect1.y", - "default": 0, - "label": "Y", - "max": 1, - "min": 0, - "name": "y", - "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/sdline.mmg b/game/addons/mat_maker_gd/nodes/material_maker_nodes/sdline.mmg deleted file mode 100644 index eab624c2..00000000 --- a/game/addons/mat_maker_gd/nodes/material_maker_nodes/sdline.mmg +++ /dev/null @@ -1,135 +0,0 @@ -{ - "name": "sdline", - "node_position": { - "x": 0, - "y": 0 - }, - "parameters": { - "ax": -0.3, - "ay": -0.3, - "bx": 0.3, - "by": 0.3, - "profile": { - "points": [ - { - "ls": 0, - "rs": 0, - "x": 0, - "y": 1 - }, - { - "ls": 0, - "rs": 0, - "x": 1, - "y": 1 - } - ], - "type": "Curve" - }, - "r": 0.1 - }, - "shader_model": { - "code": "vec2 $(name_uv)_sdl = sdLine($uv, vec2($ax+0.5, $ay+0.5), vec2($bx+0.5, $by+0.5));", - "global": "vec2 sdLine(vec2 p, vec2 a, vec2 b) {\n vec2 pa = p-a, ba = b-a;\n float h = clamp(dot(pa,ba)/dot(ba,ba), 0.0, 1.0);\n return vec2(length(pa-ba*h), h);\n}\n", - "inputs": [ - - ], - "instance": "", - "longdesc": "A line or a capsule shape described as a signed distance function", - "name": "sdLine", - "outputs": [ - { - "longdesc": "The shape as signed distance function", - "sdf2d": "$(name_uv)_sdl.x-$r*$profile($(name_uv)_sdl.y)", - "shortdesc": "Output", - "type": "sdf2d" - } - ], - "parameters": [ - { - "control": "P1.x", - "default": 0, - "label": "A X", - "longdesc": "The position on the X axis of the first point of the line", - "max": 1, - "min": -1, - "name": "ax", - "shortdesc": "A.x", - "step": 0.01, - "type": "float" - }, - { - "control": "P1.y", - "default": 0, - "label": "A Y", - "longdesc": "The position on the Y axis of the first point of the line", - "max": 1, - "min": -1, - "name": "ay", - "shortdesc": "A.y", - "step": 0.01, - "type": "float" - }, - { - "control": "P2.x", - "default": 1, - "label": "B X", - "longdesc": "The position on the X axis of the second point of the line", - "max": 1, - "min": -1, - "name": "bx", - "shortdesc": "B.x", - "step": 0.01, - "type": "float" - }, - { - "control": "P2.y", - "default": 1, - "label": "B Y", - "longdesc": "The position on the Y axis of the second point of the line", - "max": 1, - "min": -1, - "name": "by", - "shortdesc": "B.y", - "step": 0.01, - "type": "float" - }, - { - "control": "Radius1.r", - "default": 0, - "label": "Width", - "longdesc": "The width of the capsule shape around the line", - "max": 1, - "min": 0, - "name": "r", - "shortdesc": "Width", - "step": 0.01, - "type": "float" - }, - { - "default": { - "points": [ - { - "ls": 0, - "rs": 0, - "x": 0, - "y": 1 - }, - { - "ls": 0, - "rs": 0, - "x": 1, - "y": 1 - } - ], - "type": "Curve" - }, - "label": "Profile", - "name": "profile", - "type": "curve" - } - ], - "shortdesc": "sdLine" - }, - "type": "shader" -} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/nodes/material_maker_nodes/sdmorph.mmg b/game/addons/mat_maker_gd/nodes/material_maker_nodes/sdmorph.mmg deleted file mode 100644 index d2cf417f..00000000 --- a/game/addons/mat_maker_gd/nodes/material_maker_nodes/sdmorph.mmg +++ /dev/null @@ -1,60 +0,0 @@ -{ - "name": "sdmorph", - "node_position": { - "x": 0, - "y": 0 - }, - "parameters": { - "amount": 0.5 - }, - "seed_value": 41515, - "shader_model": { - "code": "", - "global": "", - "inputs": [ - { - "default": "0.0", - "label": "", - "longdesc": "The first shape, defined as a signed distance function", - "name": "in1", - "shortdesc": "Input1", - "type": "sdf2d" - }, - { - "default": "0.0", - "label": "", - "longdesc": "The second shape, defined as a signed distance function", - "name": "in2", - "shortdesc": "Input2", - "type": "sdf2d" - } - ], - "instance": "", - "longdesc": "Morphs between 2 input shapes", - "name": "sdMorph", - "outputs": [ - { - "longdesc": "The generated hybrid shape", - "sdf2d": "mix($in1($uv), $in2($uv), $amount)", - "shortdesc": "Output", - "type": "sdf2d" - } - ], - "parameters": [ - { - "control": "None", - "default": 0.5, - "label": "", - "longdesc": "The amount of the second input in the result", - "max": 1, - "min": 0, - "name": "amount", - "shortdesc": "Amount", - "step": 0.01, - "type": "float" - } - ], - "shortdesc": "sdMorph" - }, - "type": "shader" -} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/nodes/material_maker_nodes/sdngon.mmg b/game/addons/mat_maker_gd/nodes/material_maker_nodes/sdngon.mmg deleted file mode 100644 index af22d982..00000000 --- a/game/addons/mat_maker_gd/nodes/material_maker_nodes/sdngon.mmg +++ /dev/null @@ -1,102 +0,0 @@ -{ - "name": "sdngon", - "node_position": { - "x": 0, - "y": 0 - }, - "parameters": { - "cx": 0, - "cy": 0, - "n": 5, - "r": 0.4, - "rot": 0 - }, - "seed": 0, - "seed_locked": false, - "shader_model": { - "code": "", - "global": "float sdNgon(vec2 p, float r, float n) {\n\tfloat PI = 3.1415926535;\n\tp = circle_repeat_transform_2d(p, n);\n\tvec2 d = abs(p)-vec2(r*tan(3.14159265359/n), r);\n\treturn p.y < r ? p.y-r : length(max(d,vec2(0)))+min(max(d.x,d.y),0.0);\n}", - "includes": [ - "sdrotate", - "sdcirclerepeat" - ], - "inputs": [ - - ], - "instance": "", - "longdesc": "An n-gon described as a signed distance function", - "name": "sdNgon", - "outputs": [ - { - "longdesc": "The n-gon as a signed distance function", - "sdf2d": "sdNgon(sdf2d_rotate($uv-vec2($cx, $cy), $rot*0.01745329251-1.57079632679)-vec2(0.5), $r, $n)", - "shortdesc": "Output", - "type": "sdf2d" - } - ], - "parameters": [ - { - "control": "None", - "default": 3, - "label": "N", - "longdesc": "The number of sides of the n-gon", - "max": 12, - "min": 3, - "name": "n", - "shortdesc": "N", - "step": 1, - "type": "float" - }, - { - "control": "Radius1.r", - "default": 0.5, - "label": "Radius", - "longdesc": "The radius of the n-gon", - "max": 1, - "min": 0, - "name": "r", - "shortdesc": "Radius", - "step": 0.01, - "type": "float" - }, - { - "control": "Radius1.a", - "default": 0, - "label": "Rotation", - "longdesc": "The rotation of the n-gon", - "max": 180, - "min": -180, - "name": "rot", - "shortdesc": "Rotation", - "step": 0.01, - "type": "float" - }, - { - "control": "P1.x", - "default": 0, - "label": "Center X", - "longdesc": "The position of the center on the X axis", - "max": 0.5, - "min": -0.5, - "name": "cx", - "shortdesc": "Center.x", - "step": 0.01, - "type": "float" - }, - { - "control": "P1.y", - "default": 0, - "label": "Center Y", - "longdesc": "The position of the center on the Y axis", - "max": 0.5, - "min": -0.5, - "name": "cy", - "shortdesc": "Center.y", - "step": 0.01, - "type": "float" - } - ], - "shortdesc": "sdNgon" - }, - "type": "shader" -} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/nodes/material_maker_nodes/sdpolygon.mmg b/game/addons/mat_maker_gd/nodes/material_maker_nodes/sdpolygon.mmg deleted file mode 100644 index 9a948b60..00000000 --- a/game/addons/mat_maker_gd/nodes/material_maker_nodes/sdpolygon.mmg +++ /dev/null @@ -1,72 +0,0 @@ -{ - "name": "sdpolygon", - "node_position": { - "x": 0, - "y": 0 - }, - "parameters": { - "polygon": { - "points": [ - { - "x": 0.2, - "y": 0.2 - }, - { - "x": 0.4, - "y": 0.7 - }, - { - "x": 0.7, - "y": 0.4 - } - ], - "type": "Polygon" - } - }, - "shader_model": { - "code": "", - "global": "", - "inputs": [ - - ], - "instance": "float sdPolygon_$(name)(vec2 p) {\n\tvec2 v[] = $polygon;\n\tint l = v.length();\n float d = dot(p-v[0],p-v[0]);\n float s = 1.0;\n\tint j = l-1;\n for(int i=0; i=v[i].y,p.ye.y*w.x);\n if( all(c) || all(not(c)) ) s*=-1.0;\n\t\tj=i;\n }\n return s*sqrt(d);\n}\n", - "longdesc": "A polygon as a signed distance function", - "name": "sdPolygon", - "outputs": [ - { - "longdesc": "The polygon as a signed distance function", - "sdf2d": "sdPolygon_$(name)($uv)", - "shortdesc": "Output", - "type": "sdf2d" - } - ], - "parameters": [ - { - "default": { - "points": [ - { - "x": 0.2, - "y": 0.2 - }, - { - "x": 0.4, - "y": 0.7 - }, - { - "x": 0.7, - "y": 0.4 - } - ], - "type": "Polygon" - }, - "label": "", - "longdesc": "The polygon to be drawn", - "name": "polygon", - "shortdesc": "Polygon", - "type": "polygon" - } - ], - "shortdesc": "sdPolygon" - }, - "type": "shader" -} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/nodes/material_maker_nodes/sdrepeat.mmg b/game/addons/mat_maker_gd/nodes/material_maker_nodes/sdrepeat.mmg deleted file mode 100644 index 0721e1a8..00000000 --- a/game/addons/mat_maker_gd/nodes/material_maker_nodes/sdrepeat.mmg +++ /dev/null @@ -1,77 +0,0 @@ -{ - "name": "sdrepeat", - "node_position": { - "x": 0, - "y": 0 - }, - "parameters": { - "r": 0.5, - "rx": 3, - "ry": 3 - }, - "shader_model": { - "code": "", - "global": "vec2 repeat_2d(vec2 p, vec2 r, float seed, float randomness) {\n\tp -= vec2(0.5);\n\tfloat a = (rand(floor(mod((p.xy+0.5*r.xy)/r.xy, 1.0/r.xy)+vec2(seed)))-0.5)*6.28*randomness;\n\tp = mod(p+0.5*r,r)-0.5*r;\n\tvec2 rv;\n\tfloat c = cos(a);\n\tfloat s = sin(a);\n\trv.x = p.x*c+p.y*s;\n\trv.y = -p.x*s+p.y*c;\n\treturn rv+vec2(0.5);\n}\n", - "inputs": [ - { - "default": "0.0", - "label": "", - "longdesc": "The input shape, defined as a signed distance function", - "name": "in", - "shortdesc": "Input", - "type": "sdf2d" - } - ], - "instance": "", - "longdesc": "Repeats its input shape on a grid.\nThis node does not support overlapping between instances.", - "name": "Repeat", - "outputs": [ - { - "longdesc": "The shape generated by the repeat operation", - "sdf2d": "$in(repeat_2d($uv, vec2(1.0/$rx, 1.0/$ry), float($seed), $r))", - "shortdesc": "Output", - "type": "sdf2d" - } - ], - "parameters": [ - { - "control": "None", - "default": 4, - "label": "X", - "longdesc": "The number of columns in the grid", - "max": 32, - "min": 1, - "name": "rx", - "shortdesc": "Columns", - "step": 1, - "type": "float" - }, - { - "control": "None", - "default": 4, - "label": "Y", - "longdesc": "The number of lines in the grid", - "max": 32, - "min": 1, - "name": "ry", - "shortdesc": "Lines", - "step": 1, - "type": "float" - }, - { - "control": "None", - "default": 0.5, - "label": "R", - "longdesc": "The amount of random rotation on each instance of the input shape", - "max": 1, - "min": 0, - "name": "r", - "shortdesc": "Rotation", - "step": 0.01, - "type": "float" - } - ], - "shortdesc": "sdRepeat" - }, - "type": "shader" -} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/nodes/material_maker_nodes/sdrhombus.mmg b/game/addons/mat_maker_gd/nodes/material_maker_nodes/sdrhombus.mmg deleted file mode 100644 index 21480dd2..00000000 --- a/game/addons/mat_maker_gd/nodes/material_maker_nodes/sdrhombus.mmg +++ /dev/null @@ -1,83 +0,0 @@ -{ - "name": "sdrhombus", - "node_position": { - "x": 0, - "y": 0 - }, - "parameters": { - "cx": 0, - "cy": 0, - "h": 0.2, - "w": 0.3 - }, - "shader_model": { - "code": "", - "global": "float sdr_ndot(vec2 a, vec2 b) { return a.x*b.x - a.y*b.y; }\nfloat sdRhombus(in vec2 p, in vec2 b) {\n vec2 q = abs(p);\n float h = clamp((-2.0*sdr_ndot(q,b)+sdr_ndot(b,b))/dot(b,b),-1.0,1.0);\n float d = length( q - 0.5*b*vec2(1.0-h,1.0+h) );\n return d * sign( q.x*b.y + q.y*b.x - b.x*b.y );\n}", - "inputs": [ - - ], - "instance": "", - "longdesc": "A rhombus described as a signed distance function", - "name": "sdRhombus", - "outputs": [ - { - "longdesc": "The rhombus as a signed distance function", - "sdf2d": "sdRhombus($uv-vec2($cx+0.5, $cy+0.5), vec2($w, $h))", - "shortdesc": "Output", - "type": "sdf2d" - } - ], - "parameters": [ - { - "control": "Rect1.x", - "default": 0.5, - "label": "Width", - "longdesc": "The width of the rhombus", - "max": 1, - "min": 0, - "name": "w", - "shortdesc": "Width", - "step": 0.01, - "type": "float" - }, - { - "control": "Rect1.y", - "default": 1, - "label": "Height", - "longdesc": "The height of the rhombus", - "max": 1, - "min": 0, - "name": "h", - "shortdesc": "Height", - "step": 0.01, - "type": "float" - }, - { - "control": "P1.x", - "default": 0, - "label": "Center X", - "longdesc": "The position of the center on the X axis", - "max": 1, - "min": -1, - "name": "cx", - "shortdesc": "Center.x", - "step": 0.01, - "type": "float" - }, - { - "control": "P1.y", - "default": 0, - "label": "Center Y", - "longdesc": "The position of the center on the Y axis", - "max": 1, - "min": -1, - "name": "cy", - "shortdesc": "Center.y", - "step": 0.01, - "type": "float" - } - ], - "shortdesc": "sdRhombus" - }, - "type": "shader" -} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/nodes/material_maker_nodes/sdrotate.mmg b/game/addons/mat_maker_gd/nodes/material_maker_nodes/sdrotate.mmg deleted file mode 100644 index 43ac6eba..00000000 --- a/game/addons/mat_maker_gd/nodes/material_maker_nodes/sdrotate.mmg +++ /dev/null @@ -1,51 +0,0 @@ -{ - "name": "sdrotate", - "node_position": { - "x": 0, - "y": 0 - }, - "parameters": { - "a": 0 - }, - "shader_model": { - "code": "", - "global": "vec2 sdf2d_rotate(vec2 uv, float a) {\n\tvec2 rv;\n\tfloat c = cos(a);\n\tfloat s = sin(a);\n\tuv -= vec2(0.5);\n\trv.x = uv.x*c+uv.y*s;\n\trv.y = -uv.x*s+uv.y*c;\n\treturn rv+vec2(0.5);\n}\n", - "inputs": [ - { - "default": "0.0", - "label": "", - "longdesc": "The input shape, defined as a signed distance function", - "name": "in", - "shortdesc": "Input", - "type": "sdf2d" - } - ], - "instance": "", - "longdesc": "Rotates its input shape described as a signed distance function", - "name": "Rotate", - "outputs": [ - { - "longdesc": "The rotated shape", - "sdf2d": "$in(sdf2d_rotate($uv, $a*0.01745329251))", - "shortdesc": "Output", - "type": "sdf2d" - } - ], - "parameters": [ - { - "control": "Radius1.a", - "default": 0, - "label": "", - "longdesc": "The rotation angle", - "max": 180, - "min": -180, - "name": "a", - "shortdesc": "Angle", - "step": 1, - "type": "float" - } - ], - "shortdesc": "sdRotate" - }, - "type": "shader" -} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/nodes/material_maker_nodes/sdroundedshape.mmg b/game/addons/mat_maker_gd/nodes/material_maker_nodes/sdroundedshape.mmg deleted file mode 100644 index 762b54dd..00000000 --- a/game/addons/mat_maker_gd/nodes/material_maker_nodes/sdroundedshape.mmg +++ /dev/null @@ -1,51 +0,0 @@ -{ - "name": "sdroundedshape", - "node_position": { - "x": 0, - "y": 0 - }, - "parameters": { - "r": 0.2 - }, - "shader_model": { - "code": "", - "global": "", - "inputs": [ - { - "default": "0.0", - "label": "", - "longdesc": "The input shape, defined as a signed distance function", - "name": "in", - "shortdesc": "Input", - "type": "sdf2d" - } - ], - "instance": "", - "longdesc": "Dilates an input shape into a rounded shape", - "name": "sdRoundedShape", - "outputs": [ - { - "longdesc": "The shape generated by the operation", - "sdf2d": "$in($uv)-$r", - "shortdesc": "Output", - "type": "sdf2d" - } - ], - "parameters": [ - { - "control": "None", - "default": 0, - "label": "", - "longdesc": "The length of the dilate operation", - "max": 1, - "min": 0, - "name": "r", - "shortdesc": "Radius", - "step": 0.01, - "type": "float" - } - ], - "shortdesc": "sdRoundedShape" - }, - "type": "shader" -} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/nodes/material_maker_nodes/sdscale.mmg b/game/addons/mat_maker_gd/nodes/material_maker_nodes/sdscale.mmg deleted file mode 100644 index 2f8d96d8..00000000 --- a/game/addons/mat_maker_gd/nodes/material_maker_nodes/sdscale.mmg +++ /dev/null @@ -1,51 +0,0 @@ -{ - "name": "sdscale", - "node_position": { - "x": 0, - "y": 0 - }, - "parameters": { - "s": 1 - }, - "shader_model": { - "code": "", - "global": "", - "inputs": [ - { - "default": "0.0", - "label": "", - "longdesc": "The input shape, defined as a signed distance function", - "name": "in", - "shortdesc": "Input", - "type": "sdf2d" - } - ], - "instance": "", - "longdesc": "Scales its input shape described as a signed distance function", - "name": "Scale", - "outputs": [ - { - "longdesc": "The generated scaled shape", - "sdf2d": "$in(($uv-vec2(0.5))/$s+vec2(0.5))*$s", - "shortdesc": "Output", - "type": "sdf2d" - } - ], - "parameters": [ - { - "control": "Scale1.x", - "default": 1, - "label": "", - "longdesc": "The scale of the transform", - "max": 5, - "min": 0, - "name": "s", - "shortdesc": "Scale", - "step": 0.01, - "type": "float" - } - ], - "shortdesc": "sdScale" - }, - "type": "shader" -} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/nodes/material_maker_nodes/sdshow.mmg b/game/addons/mat_maker_gd/nodes/material_maker_nodes/sdshow.mmg deleted file mode 100644 index 641e8a83..00000000 --- a/game/addons/mat_maker_gd/nodes/material_maker_nodes/sdshow.mmg +++ /dev/null @@ -1,64 +0,0 @@ -{ - "name": "sdshow", - "node_position": { - "x": 0, - "y": 0 - }, - "parameters": { - "base": 0, - "bevel": 0.1 - }, - "shader_model": { - "code": "", - "global": "", - "inputs": [ - { - "default": "0.0", - "label": "", - "longdesc": "The input shape", - "name": "in", - "shortdesc": "Input", - "type": "sdf2d" - } - ], - "instance": "", - "longdesc": "Creates a greyscale image from a shape described as a 2D Signed Distance Function", - "name": "sdShow", - "outputs": [ - { - "f": "clamp($base-$in($uv)/max($bevel, 0.00001), 0.0, 1.0)", - "longdesc": "Shows the shape as a greyscale image", - "shortdesc": "Output", - "type": "f" - } - ], - "parameters": [ - { - "control": "None", - "default": 0, - "label": "Bevel", - "longdesc": "The width of the gradient at the edges of the shape", - "max": 1, - "min": 0, - "name": "bevel", - "shortdesc": "Bevel", - "step": 0.01, - "type": "float" - }, - { - "control": "None", - "default": 0, - "label": "Base", - "longdesc": "The base value of the output", - "max": 1, - "min": 0, - "name": "base", - "shortdesc": "Base", - "step": 0.01, - "type": "float" - } - ], - "shortdesc": "sdShow" - }, - "type": "shader" -} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/nodes/material_maker_nodes/sdsmoothboolean.mmg b/game/addons/mat_maker_gd/nodes/material_maker_nodes/sdsmoothboolean.mmg deleted file mode 100644 index 08d58d2f..00000000 --- a/game/addons/mat_maker_gd/nodes/material_maker_nodes/sdsmoothboolean.mmg +++ /dev/null @@ -1,82 +0,0 @@ -{ - "name": "sdsmoothboolean", - "node_position": { - "x": 0, - "y": 0 - }, - "parameters": { - "k": 0.15, - "op": 0 - }, - "shader_model": { - "code": "", - "global": "float sdSmoothUnion( float d1, float d2, float k ) {\n float h = clamp( 0.5 + 0.5*(d2-d1)/k, 0.0, 1.0 );\n return mix( d2, d1, h ) - k*h*(1.0-h); }\n\nfloat sdSmoothSubtraction( float d1, float d2, float k ) {\n float h = clamp( 0.5 - 0.5*(d2+d1)/k, 0.0, 1.0 );\n return mix( d2, -d1, h ) + k*h*(1.0-h); }\n\nfloat sdSmoothIntersection( float d1, float d2, float k ) {\n float h = clamp( 0.5 - 0.5*(d2-d1)/k, 0.0, 1.0 );\n return mix( d2, d1, h ) + k*h*(1.0-h); }\n", - "inputs": [ - { - "default": "0.0", - "label": "", - "longdesc": "The first shape, defined as a signed distance function", - "name": "in1", - "shortdesc": "Input1", - "type": "sdf2d" - }, - { - "default": "0.0", - "label": "", - "longdesc": "The second shape, defined as a signed distance function", - "name": "in2", - "shortdesc": "Input2", - "type": "sdf2d" - } - ], - "instance": "", - "longdesc": "Performs a smooth boolean operation (union, intersection or difference) between two shapes", - "name": "sdSmoothBoolean", - "outputs": [ - { - "longdesc": "The shape generated by the boolean operation", - "sdf2d": "sdSmooth$op($in1($uv), $in2($uv), $k)", - "shortdesc": "Output", - "type": "sdf2d" - } - ], - "parameters": [ - { - "default": 0, - "label": "", - "longdesc": "The operation performed by this node", - "name": "op", - "shortdesc": "Operation", - "type": "enum", - "values": [ - { - "name": "Union", - "value": "Union" - }, - { - "name": "Subtraction", - "value": "Subtraction" - }, - { - "name": "Intersection", - "value": "Intersection" - } - ] - }, - { - "control": "None", - "default": 0, - "label": "", - "longdesc": "The smoothness of the boolean operation", - "max": 1, - "min": 0, - "name": "k", - "shortdesc": "Smoothness", - "step": 0.01, - "type": "float" - } - ], - "shortdesc": "sdSmoothBoolean" - }, - "type": "shader" -} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/nodes/material_maker_nodes/sdtranslate.mmg b/game/addons/mat_maker_gd/nodes/material_maker_nodes/sdtranslate.mmg deleted file mode 100644 index f03d5e5b..00000000 --- a/game/addons/mat_maker_gd/nodes/material_maker_nodes/sdtranslate.mmg +++ /dev/null @@ -1,64 +0,0 @@ -{ - "name": "sdtranslate", - "node_position": { - "x": 0, - "y": 0 - }, - "parameters": { - "x": 0, - "y": 0 - }, - "shader_model": { - "code": "", - "global": "", - "inputs": [ - { - "default": "0.0", - "label": "", - "longdesc": "The input shape, defined as a signed distance function", - "name": "in", - "shortdesc": "Input", - "type": "sdf2d" - } - ], - "instance": "", - "longdesc": "Translates its input shape described as signed distance function", - "name": "Translate", - "outputs": [ - { - "longdesc": "The translated shape", - "sdf2d": "$in($uv-vec2($x, $y))", - "shortdesc": "Output", - "type": "sdf2d" - } - ], - "parameters": [ - { - "control": "P1.x", - "default": 0, - "label": "X", - "longdesc": "The translation along the X axis", - "max": 1, - "min": -1, - "name": "x", - "shortdesc": "Translate.x", - "step": 0.01, - "type": "float" - }, - { - "control": "P1.y", - "default": 0, - "label": "Y", - "longdesc": "The translation along the Y axis", - "max": 1, - "min": -1, - "name": "y", - "shortdesc": "Translate.y", - "step": 0.01, - "type": "float" - } - ], - "shortdesc": "sdTranslate" - }, - "type": "shader" -} \ No newline at end of file