From 8d4eb234832e04c0cca85b3cd6df4292a534226b Mon Sep 17 00:00:00 2001 From: RodZill4 Date: Sat, 15 Feb 2020 11:16:18 +0100 Subject: [PATCH] Added splatter and 2D fBm --- addons/material_maker/nodes/bricks.mmg | 2 +- addons/material_maker/nodes/shape.mmg | 25 +++-- addons/material_maker/nodes/splatter.mmg | 87 ++++++++++++++++++ .../material_maker/nodes/splatter_color.mmg | 87 ++++++++++++++++++ material_maker/library/base.json | 40 ++++++++ material_maker/library/base/noise_fbm.png | Bin 0 -> 2934 bytes .../library/base/transform_splatter.png | Bin 0 -> 1747 bytes .../library/base/transform_splatter_color.png | Bin 0 -> 1388 bytes 8 files changed, 232 insertions(+), 9 deletions(-) create mode 100644 addons/material_maker/nodes/splatter.mmg create mode 100644 addons/material_maker/nodes/splatter_color.mmg create mode 100644 material_maker/library/base/noise_fbm.png create mode 100644 material_maker/library/base/transform_splatter.png create mode 100644 material_maker/library/base/transform_splatter_color.png diff --git a/addons/material_maker/nodes/bricks.mmg b/addons/material_maker/nodes/bricks.mmg index 6c2ee20..aba14ac 100644 --- a/addons/material_maker/nodes/bricks.mmg +++ b/addons/material_maker/nodes/bricks.mmg @@ -10,7 +10,7 @@ "corner": 0, "mortar": 0.1, "pattern": 0, - "repeat": 147, + "repeat": 2, "round": 0, "row_offset": 0.5, "rows": 6 diff --git a/addons/material_maker/nodes/shape.mmg b/addons/material_maker/nodes/shape.mmg index ced36f9..7093eed 100644 --- a/addons/material_maker/nodes/shape.mmg +++ b/addons/material_maker/nodes/shape.mmg @@ -5,18 +5,23 @@ "y": 0 }, "parameters": { - "edge": 0.2, - "radius": 1, - "shape": 0, - "sides": 3 + "edge": 0.5, + "radius": 0.9, + "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((size-cos(floor(0.5+angle/slice)*slice-angle)*length(uv))/(edge*size), 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((size-cos(floor(1.5+angle/slice-2.0*step(0.5*slice, mod(angle, slice)))*slice-angle)*length(uv))/(edge*size), 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((size-cos(floor(0.5+0.5*angle/slice)*2.0*slice-angle)*length(uv))/(edge*size), 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": [ + + ], "instance": "", "name": "Shape", "outputs": [ { - "f": "shape_$(shape)($(uv), $(sides), $(radius), $(edge))" + "f": "shape_$(shape)($(uv), $(sides), $(radius), $(edge))", + "type": "f" } ], "parameters": [ @@ -49,6 +54,7 @@ ] }, { + "control": "None", "default": 3, "label": "", "max": 32, @@ -58,23 +64,26 @@ "type": "float" }, { + "control": "None", "default": 1, "label": "", "max": 1, "min": 0, "name": "radius", - "step": 0, + "step": 0.01, "type": "float" }, { + "control": "None", "default": 0.2, "label": "", "max": 1, "min": 0, "name": "edge", - "step": 0, + "step": 0.01, "type": "float" } ] - } + }, + "type": "shader" } \ No newline at end of file diff --git a/addons/material_maker/nodes/splatter.mmg b/addons/material_maker/nodes/splatter.mmg new file mode 100644 index 0000000..c697b39 --- /dev/null +++ b/addons/material_maker/nodes/splatter.mmg @@ -0,0 +1,87 @@ +{ + "name": "splatter", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "count": 25, + "rotate": 0, + "scale": 0, + "select_inputs": 0 + }, + "shader_model": { + "code": "", + "global": "", + "inputs": [ + { + "default": "0.0", + "function": true, + "label": "", + "name": "in", + "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}", + "name": "Splatter", + "outputs": [ + { + "f": "splatter_$(name)($uv, int($count), vec2($seed))", + "type": "f" + } + ], + "parameters": [ + { + "control": "None", + "default": 10, + "label": "Count", + "max": 100, + "min": 1, + "name": "count", + "step": 1, + "type": "float" + }, + { + "default": 0, + "label": "Inputs", + "name": "select_inputs", + "type": "enum", + "values": [ + { + "name": "1", + "value": " " + }, + { + "name": "4", + "value": "pv = clamp(0.5*(pv+floor(rand2(seed)*2.0)), vec2(0.0), vec2(1.0));" + }, + { + "name": "16", + "value": "pv = clamp(0.25*(pv+floor(rand2(seed)*4.0)), vec2(0.0), vec2(1.0));" + } + ] + }, + { + "control": "None", + "default": 0, + "label": "Rotate", + "max": 180, + "min": 0, + "name": "rotate", + "step": 0.1, + "type": "float" + }, + { + "control": "None", + "default": 0, + "label": "Scale", + "max": 1, + "min": 0, + "name": "scale", + "step": 0.01, + "type": "float" + } + ] + }, + "type": "shader" +} \ No newline at end of file diff --git a/addons/material_maker/nodes/splatter_color.mmg b/addons/material_maker/nodes/splatter_color.mmg new file mode 100644 index 0000000..3c44c61 --- /dev/null +++ b/addons/material_maker/nodes/splatter_color.mmg @@ -0,0 +1,87 @@ +{ + "name": "splatter_color", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "count": 25, + "rotate": 0, + "scale": 0, + "select_inputs": 0 + }, + "shader_model": { + "code": "", + "global": "", + "inputs": [ + { + "default": "vec4(0.0)", + "function": true, + "label": "", + "name": "in", + "type": "rgba" + } + ], + "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}", + "name": "Color Splatter", + "outputs": [ + { + "rgba": "splatter_$(name)($uv, int($count), vec2($seed))", + "type": "rgba" + } + ], + "parameters": [ + { + "control": "None", + "default": 10, + "label": "Count", + "max": 100, + "min": 1, + "name": "count", + "step": 1, + "type": "float" + }, + { + "default": 0, + "label": "Inputs", + "name": "select_inputs", + "type": "enum", + "values": [ + { + "name": "1", + "value": " " + }, + { + "name": "4", + "value": "pv = clamp(0.5*(pv+floor(rand2(seed)*2.0)), vec2(0.0), vec2(1.0));" + }, + { + "name": "16", + "value": "pv = clamp(0.25*(pv+floor(rand2(seed)*4.0)), vec2(0.0), vec2(1.0));" + } + ] + }, + { + "control": "None", + "default": 0, + "label": "Rotate", + "max": 180, + "min": 0, + "name": "rotate", + "step": 0.1, + "type": "float" + }, + { + "control": "None", + "default": 0, + "label": "Scale", + "max": 1, + "min": 0, + "name": "scale", + "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 c3252e4..9171b0b 100644 --- a/material_maker/library/base.json +++ b/material_maker/library/base.json @@ -2217,6 +2217,20 @@ "tree_item": "Noise/Color", "type": "color_noise" }, + { + "collapsed": true, + "icon": "noise_fbm", + "name": "fbm", + "parameters": { + "iterations": 5, + "noise": 0, + "persistence": 0.5, + "scale_x": 2, + "scale_y": 2 + }, + "tree_item": "Noise/FBM", + "type": "fbm" + }, { "collapsed": false, "tree_item": "Filter" @@ -2567,6 +2581,32 @@ "tree_item": "Transform/CustomUV", "type": "custom_uv" }, + { + "collapsed": true, + "icon": "transform_splatter", + "name": "splatter", + "parameters": { + "count": 25, + "rotate": 0, + "scale": 0, + "select_inputs": 0 + }, + "tree_item": "Transform/Splatter", + "type": "splatter" + }, + { + "collapsed": true, + "icon": "transform_splatter_color", + "name": "splatter_color", + "parameters": { + "count": 25, + "rotate": 0, + "scale": 0, + "select_inputs": 0 + }, + "tree_item": "Transform/Splatter/Color", + "type": "splatter_color" + }, { "collapsed": false, "tree_item": "Workflow" diff --git a/material_maker/library/base/noise_fbm.png b/material_maker/library/base/noise_fbm.png new file mode 100644 index 0000000000000000000000000000000000000000..728878d6dcde0df359e687f952e2022a0198f1ed GIT binary patch literal 2934 zcmV-+3yJiJP)Px=FiAu~RCt_~n_F_*I1ojfBqU{V+5b{pmiU^FVCi1!2*c z8h&ZIBH$jE^t-V{eG`$n)+V+v4&;BAl%P-=XrJm9>-A)F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Fu=Hh!1kT7z| z>lZW}zs$+AMJu1DR*rjzeRE1nvcNbQdp1a(%%11hyTpbvh8s0sezC!vz+9Kaq_RY* g(U5D}d6`=O0d09BNnG2w=>Px#07*qoM6N<$g4M~^#Q*>R literal 0 HcmV?d00001 diff --git a/material_maker/library/base/transform_splatter.png b/material_maker/library/base/transform_splatter.png new file mode 100644 index 0000000000000000000000000000000000000000..dcb0be60489a22477a0214f72f9f95f17f2ac9e6 GIT binary patch literal 1747 zcmV;^1}yoBP)Px*jY&j7RCt`_TU|(#Z5Y1ZKBc1C%1)v|OJRcpS>(U-rNEZ@&6{H(c<% z&+g}bp8IcbaY7 zyLXRg&Ya=EzyJ>(Jh-w5P*`Ibv3KuYilQ*B@dRka*|TSvDo&^K|3iR?;o)I=y7BOlN1O;SLyr#C}s#Q)7IAmJox3gM`Q9 zAxW-Zzg~jT1uHaCdp8qbQLQfxLGCMG5z2m&fA zEAi^ptDO2~vl)>{1OPBRJghd`H2MAew-ml`;X+!R98twQNw&AQ%U*li?RKe&+U<6_ zTrQeSCQY?}{``4*JRX`%CVu$vL9HEinLl{&fF$|xThLg+hw-bIl;}cwDi)RMFHA)u6Pr zRFQt_45D*+mYx75$TWj=baX5q0@kftm-AaM1OfpD0)ax<)^0=`gtQDs212`$#l=OA zjErz`anWdJmY#s}^75qqSzcbQDE+o=+YBXO6*P$7??+u-9a>si001p5EvT!jgWvC$ zZDVqB60NPR002P{;Pd%pr?prt8RK{F-ktM1Rdiue%i8|_{remn8&hSYudj~)=x{jL z+}xa0o{EZ!yf!s0gc2nf4607MYSk+2*|P@#P*qihmoHz+PAdok=H}+GcJ11vW%DP5CB}cas>cnZ`PK4gv2Ymo8nB!Zw>t z3g5kZH>3WOCr{+$ZM^exv2o)@&d$!Vy}g}dV`EZ$wl@WG&M1~00b)NEk$So-ijD`X z#yg#gcs$Mn2M#1nVYRijX`7-*BqFQptT+OG{P;nV8E>rYb~`_P`a}S{cJ11Ks|A#l zlrSETC)M)v=g-shNOF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