diff --git a/addons/material_maker/nodes/sdcirclerepeat.mmg b/addons/material_maker/nodes/sdcirclerepeat.mmg new file mode 100644 index 00000000..81d07f8f --- /dev/null +++ b/addons/material_maker/nodes/sdcirclerepeat.mmg @@ -0,0 +1,47 @@ +{ + "name": "sdcirclerepeat", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "c": 6 + }, + "seed_value": 44955, + "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", + "includes": [ + "" + ], + "inputs": [ + { + "default": "0.0", + "label": "", + "name": "in", + "type": "sdf2d" + } + ], + "instance": "", + "name": "Circle Repeat", + "outputs": [ + { + "sdf2d": "$in(circle_repeat_transform_2d($uv-vec2(0.5), $c)+vec2(0.5))", + "type": "sdf2d" + } + ], + "parameters": [ + { + "control": "None", + "default": 4, + "label": "", + "max": 32, + "min": 1, + "name": "c", + "step": 1, + "type": "float" + } + ] + }, + "type": "shader" +} \ No newline at end of file diff --git a/addons/material_maker/nodes/sdrepeat.mmg b/addons/material_maker/nodes/sdrepeat.mmg new file mode 100644 index 00000000..1ade0a52 --- /dev/null +++ b/addons/material_maker/nodes/sdrepeat.mmg @@ -0,0 +1,68 @@ +{ + "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", + "includes": [ + "" + ], + "inputs": [ + { + "default": "0.0", + "label": "", + "name": "in", + "type": "sdf2d" + } + ], + "instance": "", + "name": "Repeat", + "outputs": [ + { + "sdf2d": "$in(repeat_2d($uv, vec2(1.0/$rx, 1.0/$ry), float($seed), $r))", + "type": "sdf2d" + } + ], + "parameters": [ + { + "control": "None", + "default": 4, + "label": "X", + "max": 32, + "min": 1, + "name": "rx", + "step": 1, + "type": "float" + }, + { + "control": "None", + "default": 4, + "label": "Y", + "max": 32, + "min": 1, + "name": "ry", + "step": 1, + "type": "float" + }, + { + "control": "None", + "default": 0.5, + "label": "R", + "max": 1, + "min": 0, + "name": "r", + "step": 0.01, + "type": "float" + } + ] + }, + "type": "shader" +} \ No newline at end of file diff --git a/material_maker/library/base.json b/material_maker/library/base.json index c65683b2..fe5a565d 100644 --- a/material_maker/library/base.json +++ b/material_maker/library/base.json @@ -383,6 +383,28 @@ "tree_item": "Simple/SDF/Operators/sdMorph", "type": "sdmorph" }, + { + "collapsed": true, + "icon": "simple_sdf_operators_sdrepeat", + "name": "sdrepeat", + "parameters": { + "r": 0.5, + "rx": 3, + "ry": 3 + }, + "tree_item": "Simple/SDF/Operators/sdRepeat", + "type": "sdrepeat" + }, + { + "collapsed": true, + "icon": "simple_sdf_operators_sdcirclerepeat", + "name": "sdcirclerepeat", + "parameters": { + "c": 6 + }, + "tree_item": "Simple/SDF/Operators/sdCircleRepeat", + "type": "sdcirclerepeat" + }, { "collapsed": false, "tree_item": "Simple/SDF/Transforms" diff --git a/material_maker/library/base/simple_sdf_operators_sdcirclerepeat.png b/material_maker/library/base/simple_sdf_operators_sdcirclerepeat.png new file mode 100644 index 00000000..c0fd6b3d Binary files /dev/null and b/material_maker/library/base/simple_sdf_operators_sdcirclerepeat.png differ diff --git a/material_maker/library/base/simple_sdf_operators_sdrepeat.png b/material_maker/library/base/simple_sdf_operators_sdrepeat.png new file mode 100644 index 00000000..fdc5914c Binary files /dev/null and b/material_maker/library/base/simple_sdf_operators_sdrepeat.png differ