diff --git a/game/addons/mat_maker_gd/nodes/common/sdf3d.gd b/game/addons/mat_maker_gd/nodes/common/sdf3d.gd index aa795d3e..a0ddceec 100644 --- a/game/addons/mat_maker_gd/nodes/common/sdf3d.gd +++ b/game/addons/mat_maker_gd/nodes/common/sdf3d.gd @@ -69,6 +69,28 @@ const Commons = preload("res://addons/mat_maker_gd/nodes/common/commons.gd") #axis, enum, default:5, values: +X, -X, +Y, -Y, +Z, -Z #angle, float, min: 0, max: 90, default:30, step:1 +#---------------------- +#sdf3d_repeat.mmg + +#Outputs: + +#+X: $axis = length($uv.yz),-$uv.x +#-X: $axis = length($uv.yz),$uv.x +#+Y: $axis = length($uv.xz),$uv.y +#-Y: $axis = length($uv.xz),-$uv.y +#+Z: $axis = length($uv.xy),-$uv.z +#-Z: $axis = length($uv.xy),$uv.z + +#Output (sdf3d) +#Output (sdf3dc) - The shape generated by the repeat operation +#$in(repeat($uv, vec3(1.0/$rx, 1.0/$ry, 0.0), float($seed), $r)) + +#Inputs: +#in, vec2, default:vec2(100, 0.0), (sdf3d input) + +#X, int, min: 1, max: 32, default:4, step:1 +#Y, int, min: 1, max: 32, default:4, step:1 +#R, float, min: 0, max: 1, default:0.5, step:0.01 static func raymarch(uv : Vector2) -> Color: var d : Vector2 = sdf3d_raymarch(uv); @@ -281,6 +303,37 @@ static func sdf3d_elongation(p : Vector3, v : Vector3) -> Vector3: static func sdf3d_repeat(p : Vector3, r : Vector2, randomness : float, pseed : int) -> Vector3: return (repeat(p, Vector3(1.0/r.x, 1.0/r.y, 0.00001), float(pseed), randomness)) +#vec3 repeat(vec3 p, vec3 r, float seed, float randomness) { +# vec3 a = (rand3(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; +# +# vec3 rv; +# float c; +# float s; +# +# c = cos(a.x); +# s = sin(a.x); +# +# rv.x = p.x; +# rv.y = p.y*c+p.z*s;rv.z = -p.y*s+p.z*c; +# +# c = cos(a.y); +# s = sin(a.y); +# +# p.x = rv.x*c+rv.z*s; +# p.y = rv.y; +# p.z = -rv.x*s+rv.z*c; +# +# c = cos(a.z); +# s = sin(a.z); +# +# rv.x = p.x*c+p.y*s; +# rv.y = -p.x*s+p.y*c; +# rv.z = p.z; +# +# return rv; +#} + #Needs work static func repeat(p : Vector3, r : Vector3, pseed : float, randomness : float) -> Vector3: #fix division by zero diff --git a/game/addons/mat_maker_gd/nodes/material_maker_nodes/sdf3d_repeat.mmg b/game/addons/mat_maker_gd/nodes/material_maker_nodes/sdf3d_repeat.mmg deleted file mode 100644 index 972ad9df..00000000 --- a/game/addons/mat_maker_gd/nodes/material_maker_nodes/sdf3d_repeat.mmg +++ /dev/null @@ -1,77 +0,0 @@ -{ - "name": "sdf3d_repeat", - "node_position": { - "x": 0, - "y": 0 - }, - "parameters": { - "r": 0.3, - "rx": 3, - "ry": 3 - }, - "shader_model": { - "code": "", - "global": "vec3 repeat(vec3 p, vec3 r, float seed, float randomness) {\n\tvec3 a = (rand3(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\tvec3 rv;\n\tfloat c;\n\tfloat s;\n\tc = cos(a.x);\n\ts = sin(a.x);\n\trv.x = p.x;\n\trv.y = p.y*c+p.z*s;\n\trv.z = -p.y*s+p.z*c;\n\tc = cos(a.y);\n\ts = sin(a.y);\n\tp.x = rv.x*c+rv.z*s;\n\tp.y = rv.y;\n\tp.z = -rv.x*s+rv.z*c;\n\tc = cos(a.z);\n\ts = sin(a.z);\n\trv.x = p.x*c+p.y*s;\n\trv.y = -p.x*s+p.y*c;\n\trv.z = p.z;\n\treturn rv;\n}\n", - "inputs": [ - { - "default": "vec2(100, 0.0)", - "label": "", - "longdesc": "The input shape, defined as a signed distance function", - "name": "in", - "shortdesc": "Input", - "type": "sdf3dc" - } - ], - "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", - "sdf3dc": "$in(repeat($uv, vec3(1.0/$rx, 1.0/$ry, 0.0), float($seed), $r))", - "shortdesc": "Output", - "type": "sdf3dc" - } - ], - "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": "Repeat" - }, - "type": "shader" -} \ No newline at end of file