diff --git a/addons/material_maker/nodes/splatter.mmg b/addons/material_maker/nodes/splatter.mmg index c697b39..921f71c 100644 --- a/addons/material_maker/nodes/splatter.mmg +++ b/addons/material_maker/nodes/splatter.mmg @@ -5,7 +5,7 @@ "y": 0 }, "parameters": { - "count": 25, + "count": 30, "rotate": 0, "scale": 0, "select_inputs": 0 @@ -20,9 +20,16 @@ "label": "", "name": "in", "type": "f" + }, + { + "default": "1.0", + "function": true, + "label": "", + "name": "mask", + "type": "f" } ], - "instance": "float splatter_$(name)(vec2 uv, int count, vec2 seed) {\n\tfloat c = 0.0;\n\tfor (int i = 0; i < count; ++i) {\n\t\tseed = rand2(seed);\n\t\tvec2 pv = fract(uv - seed);\n\t\tseed = rand2(seed);\n\t\tpv -= vec2(0.5);\n\t\tfloat angle = (seed.x * 2.0 - 1.0) * $rotate;\n\t\tfloat ca = cos(angle);\n\t\tfloat sa = sin(angle);\n\t\tpv = vec2(ca*pv.x+sa*pv.y, -sa*pv.x+ca*pv.y);\n\t\tpv *= (seed.y-0.5)*2.0*$scale+1.0;\n\t\tpv += vec2(0.5);\n\t\t$select_inputs\n\t\tc = max(c, $in(pv));\n\t}\n\treturn c;\n}", + "instance": "float splatter_$(name)(vec2 uv, int count, vec2 seed) {\n\tfloat c = 0.0;\n\tfor (int i = 0; i < count; ++i) {\n\t\tseed = rand2(seed);\n\t\tfloat mask = $mask(seed+vec2(0.5));\n\t\tif (mask > 0.01) {\n\t\t\tvec2 pv = fract(uv - seed)-vec2(0.5);\n\t\t\tseed = rand2(seed);\n\t\t\tfloat angle = (seed.x * 2.0 - 1.0) * $rotate;\n\t\t\tfloat ca = cos(angle);\n\t\t\tfloat sa = sin(angle);\n\t\t\tpv = vec2(ca*pv.x+sa*pv.y, -sa*pv.x+ca*pv.y);\n\t\t\tpv *= (seed.y-0.5)*2.0*$scale+1.0;\n\t\t\tpv += vec2(0.5);\n\t\t\t$select_inputs\n\t\t\tc = max(c, $in(pv)*mask);\n\t\t}\n\t}\n\treturn c;\n}", "name": "Splatter", "outputs": [ { diff --git a/addons/material_maker/nodes/splatter_color.mmg b/addons/material_maker/nodes/splatter_color.mmg index 3c44c61..4158172 100644 --- a/addons/material_maker/nodes/splatter_color.mmg +++ b/addons/material_maker/nodes/splatter_color.mmg @@ -5,7 +5,7 @@ "y": 0 }, "parameters": { - "count": 25, + "count": 30, "rotate": 0, "scale": 0, "select_inputs": 0 @@ -20,9 +20,16 @@ "label": "", "name": "in", "type": "rgba" + }, + { + "default": "1.0", + "function": true, + "label": "", + "name": "mask", + "type": "f" } ], - "instance": "vec4 splatter_$(name)(vec2 uv, int count, vec2 seed) {\n\tvec4 c = vec4(0.0);\n\tfor (int i = 0; i < count; ++i) {\n\t\tseed = rand2(seed);\n\t\tvec2 pv = fract(uv - seed);\n\t\tseed = rand2(seed);\n\t\tpv -= vec2(0.5);\n\t\tfloat angle = (seed.x * 2.0 - 1.0) * $rotate;\n\t\tfloat ca = cos(angle);\n\t\tfloat sa = sin(angle);\n\t\tpv = vec2(ca*pv.x+sa*pv.y, -sa*pv.x+ca*pv.y);\n\t\tpv *= (seed.y-0.5)*2.0*$scale+1.0;\n\t\tpv += vec2(0.5);\n\t\t$select_inputs\n\t\tvec4 n = $in(pv);\n\t\tfloat a = (1.0-c.a)*(1.0*n.a);\n\t\tc = mix(c, n, n.a);\n\t}\n\treturn c;\n}", + "instance": "vec4 splatter_$(name)(vec2 uv, int count, vec2 seed) {\n\tvec4 c = vec4(0.0);\n\tfor (int i = 0; i < count; ++i) {\n\t\tseed = rand2(seed);\n\t\tfloat mask = $mask(seed+vec2(0.5));\n\t\tif (mask > 0.01) {\n\t\t\tvec2 pv = fract(uv - seed)-vec2(0.5);\n\t\t\tseed = rand2(seed);\n\t\t\tfloat angle = (seed.x * 2.0 - 1.0) * $rotate;\n\t\t\tfloat ca = cos(angle);\n\t\t\tfloat sa = sin(angle);\n\t\t\tpv = vec2(ca*pv.x+sa*pv.y, -sa*pv.x+ca*pv.y);\n\t\t\tpv *= (seed.y-0.5)*2.0*$scale+1.0;\n\t\t\tpv += vec2(0.5);\n\t\t\t$select_inputs\n\t\t\tvec4 n = $in(pv);\n\t\t\tfloat na = n.a*mask;\n\t\t\tfloat a = (1.0-c.a)*(1.0*na);\n\t\t\tc = mix(c, n, na);\n\t\t}\n\t}\n\treturn c;\n}\n", "name": "Color Splatter", "outputs": [ { diff --git a/material_maker/doc/images/node_transform_splatter.png b/material_maker/doc/images/node_transform_splatter.png index 26da7f9..6ffe833 100644 Binary files a/material_maker/doc/images/node_transform_splatter.png and b/material_maker/doc/images/node_transform_splatter.png differ diff --git a/material_maker/doc/images/node_transform_splatter_color.png b/material_maker/doc/images/node_transform_splatter_color.png index 19e1305..6ec2e3e 100644 Binary files a/material_maker/doc/images/node_transform_splatter_color.png and b/material_maker/doc/images/node_transform_splatter_color.png differ diff --git a/material_maker/doc/images/node_transform_tile2x2.png b/material_maker/doc/images/node_transform_tile2x2.png new file mode 100644 index 0000000..cc182f6 Binary files /dev/null and b/material_maker/doc/images/node_transform_tile2x2.png differ