From bcd385527334e9d3fc3069208156441dc264b62d Mon Sep 17 00:00:00 2001 From: RodZill4 Date: Fri, 22 Nov 2019 07:50:17 +0100 Subject: [PATCH] Added new node templates, updated old ones --- addons/material_maker/nodes/bricks.mmg | 27 +- .../nodes/brightness_contrast.mmg | 53 +++ .../material_maker/nodes/directional_blur.mmg | 17 +- addons/material_maker/nodes/invert.mmg | 34 ++ addons/material_maker/nodes/noise_color.mmg | 37 ++ addons/material_maker/nodes/occlusion.mmg | 319 ++++++++++++++++++ addons/material_maker/nodes/optional.mmg | 50 +++ addons/material_maker/nodes/perlin_rgb.mmg | 67 ++++ addons/material_maker/nodes/quantize.mmg | 42 +++ addons/material_maker/nodes/runes.mmg | 15 +- addons/material_maker/nodes/splatter_base.mmg | 80 +++++ .../nodes/uniform_greyscale.mmg | 37 ++ addons/material_maker/nodes/voronoi.mmg | 42 ++- addons/material_maker/nodes/weave.mmg | 17 +- 14 files changed, 790 insertions(+), 47 deletions(-) create mode 100644 addons/material_maker/nodes/brightness_contrast.mmg create mode 100644 addons/material_maker/nodes/invert.mmg create mode 100644 addons/material_maker/nodes/noise_color.mmg create mode 100644 addons/material_maker/nodes/occlusion.mmg create mode 100644 addons/material_maker/nodes/optional.mmg create mode 100644 addons/material_maker/nodes/perlin_rgb.mmg create mode 100644 addons/material_maker/nodes/quantize.mmg create mode 100644 addons/material_maker/nodes/splatter_base.mmg create mode 100644 addons/material_maker/nodes/uniform_greyscale.mmg diff --git a/addons/material_maker/nodes/bricks.mmg b/addons/material_maker/nodes/bricks.mmg index 80ed8d1..4680cf9 100644 --- a/addons/material_maker/nodes/bricks.mmg +++ b/addons/material_maker/nodes/bricks.mmg @@ -14,12 +14,12 @@ "rows": 6 }, "shader_model": { - "code": "vec3 $(name_uv) = $(name)_xyz($(uv));\n", - "global": "vec3 brick(vec2 uv, vec2 bmin, vec2 bmax, float mortar, float bevel) {\n\tfloat color = 0.5;\n\tvec2 c1 = (uv-bmin-vec2(mortar))/bevel;\n\tvec2 c2 = (bmax-uv-vec2(mortar))/bevel;\n\tvec2 c = min(c1, c2);\n\tcolor = clamp(min(c.x, c.y), 0.0, 1.0);\n\treturn vec3(color, mod(bmin, vec2(1.0, 1.0)));\n}\n\nvec3 bricks_rb(vec2 uv, vec2 count, float repeat, float offset, float mortar, float bevel) {\n\tcount *= repeat;\n\tmortar /= max(count.x, count.y);\n\tbevel /= max(count.x, count.y);\n\tfloat x_offset = offset*step(0.5, fract(uv.y*count.y*0.5));\n\tvec2 bmin = floor(vec2(uv.x*count.x-x_offset, uv.y*count.y));\n\tbmin.x += x_offset;\n\tbmin /= count;\n\treturn brick(uv, bmin, bmin+vec2(1.0)/count, mortar, bevel);\n}\n\nvec3 bricks_rb2(vec2 uv, vec2 count, float repeat, float offset, float mortar, float bevel) {\n\tcount *= repeat;\n\tmortar /= max(2.0*count.x, count.y);\n\tbevel /= max(2.0*count.x, count.y);\n\tfloat x_offset = offset*step(0.5, fract(uv.y*count.y*0.5));\n\tcount.x = count.x*(1.0+step(0.5, fract(uv.y*count.y*0.5)));\n\tvec2 bmin = floor(vec2(uv.x*count.x-x_offset, uv.y*count.y));\n\tbmin.x += x_offset;\n\tbmin /= count;\n\treturn brick(uv, bmin, bmin+vec2(1.0)/count, mortar, bevel);\n}\n\nvec3 bricks_hb(vec2 uv, vec2 count, float repeat, float offset, float mortar, float bevel) {\n\tfloat pc = count.x+count.y;\n\tfloat c = pc*repeat;\n\tmortar /= c;\n\tbevel /= c;\n\tvec2 corner = floor(uv*c);\n\tfloat cdiff = mod(corner.x-corner.y, pc);\n\tif (cdiff < count.x) {\n\t\treturn brick(uv, (corner-vec2(cdiff, 0.0))/c, (corner-vec2(cdiff, 0.0)+vec2(count.x, 1.0))/c, mortar, bevel);\n\t} else {\n\t\treturn brick(uv, (corner-vec2(0.0, pc-cdiff-1.0))/c, (corner-vec2(0.0, pc-cdiff-1.0)+vec2(1.0, count.y))/c, mortar, bevel);\n\t}\n}\n\nvec3 bricks_bw(vec2 uv, vec2 count, float repeat, float offset, float mortar, float bevel) {\n\tvec2 c = 2.0*count*repeat;\n\tfloat mc = max(c.x, c.y);\n\tmortar /= mc;\n\tbevel /= mc;\n\tvec2 corner1 = floor(uv*c);\n\tvec2 corner2 = count*floor(repeat*2.0*uv);\n\tfloat cdiff = mod(dot(floor(repeat*2.0*uv), vec2(1.0)), 2.0);\n\tvec2 corner;\n\tvec2 size;\n\tif (cdiff == 0.0) {\n\t\tcorner = vec2(corner1.x, corner2.y);\n\t\tsize = vec2(1.0, count.y);\n\t} else {\n\t\tcorner = vec2(corner2.x, corner1.y);\n\t\tsize = vec2(count.x, 1.0);\n\t}\n\treturn brick(uv, corner/c, (corner+size)/c, mortar, bevel);\n}\n\nvec3 bricks_sb(vec2 uv, vec2 count, float repeat, float offset, float mortar, float bevel) {\n\tvec2 c = (count+vec2(1.0))*repeat;\n\tfloat mc = max(c.x, c.y);\n\tmortar /= mc;\n\tbevel /= mc;\n\tvec2 corner1 = floor(uv*c);\n\tvec2 corner2 = (count+vec2(1.0))*floor(repeat*uv);\n\tvec2 rcorner = corner1 - corner2;\n\tvec2 corner;\n\tvec2 size;\n\tif (rcorner.x == 0.0 && rcorner.y < count.y) {\n\t\tcorner = corner2;\n\t\tsize = vec2(1.0, count.y);\n\t} else if (rcorner.y == 0.0) {\n\t\tcorner = corner2+vec2(1.0, 0.0);\n\t\tsize = vec2(count.x, 1.0);\n\t} else if (rcorner.x == count.x) {\n\t\tcorner = corner2+vec2(count.x, 1.0);\n\t\tsize = vec2(1.0, count.y);\n\t} else if (rcorner.y == count.y) {\n\t\tcorner = corner2+vec2(0.0, count.y);\n\t\tsize = vec2(count.x, 1.0);\n\t} else {\n\t\tcorner = corner2+vec2(1.0);\n\t\tsize = vec2(count.x-1.0, count.y-1.0);\n\t}\n\treturn brick(uv, corner/c, (corner+size)/c, mortar, bevel);\n}", + "code": "vec4 $(name_uv) = $(name)_xyzw($(uv));\n", + "global": "vec4 brick(vec2 uv, vec2 bmin, vec2 bmax, float mortar, float bevel) {\n\tfloat color;\n\tvec2 c1 = (uv-bmin-vec2(mortar))/bevel;\n\tvec2 c2 = (bmax-uv-vec2(mortar))/bevel;\n\tvec2 c = min(c1, c2);\n\tcolor = clamp(min(c.x, c.y), 0.0, 1.0);\n\tvec2 tiled_brick_pos = mod(bmin, vec2(1.0, 1.0));\n\treturn vec4(color, 0.5*(bmin+bmax), tiled_brick_pos.x+7.0*tiled_brick_pos.y);\n}\n\nvec4 bricks_rb(vec2 uv, vec2 count, float repeat, float offset, float mortar, float bevel) {\n\tcount *= repeat;\n\tmortar /= max(count.x, count.y);\n\tbevel /= max(count.x, count.y);\n\tfloat x_offset = offset*step(0.5, fract(uv.y*count.y*0.5));\n\tvec2 bmin = floor(vec2(uv.x*count.x-x_offset, uv.y*count.y));\n\tbmin.x += x_offset;\n\tbmin /= count;\n\treturn brick(uv, bmin, bmin+vec2(1.0)/count, mortar, bevel);\n}\n\nvec4 bricks_rb2(vec2 uv, vec2 count, float repeat, float offset, float mortar, float bevel) {\n\tcount *= repeat;\n\tmortar /= max(2.0*count.x, count.y);\n\tbevel /= max(2.0*count.x, count.y);\n\tfloat x_offset = offset*step(0.5, fract(uv.y*count.y*0.5));\n\tcount.x = count.x*(1.0+step(0.5, fract(uv.y*count.y*0.5)));\n\tvec2 bmin = floor(vec2(uv.x*count.x-x_offset, uv.y*count.y));\n\tbmin.x += x_offset;\n\tbmin /= count;\n\treturn brick(uv, bmin, bmin+vec2(1.0)/count, mortar, bevel);\n}\n\nvec4 bricks_hb(vec2 uv, vec2 count, float repeat, float offset, float mortar, float bevel) {\n\tfloat pc = count.x+count.y;\n\tfloat c = pc*repeat;\n\tmortar /= c;\n\tbevel /= c;\n\tvec2 corner = floor(uv*c);\n\tfloat cdiff = mod(corner.x-corner.y, pc);\n\tif (cdiff < count.x) {\n\t\treturn brick(uv, (corner-vec2(cdiff, 0.0))/c, (corner-vec2(cdiff, 0.0)+vec2(count.x, 1.0))/c, mortar, bevel);\n\t} else {\n\t\treturn brick(uv, (corner-vec2(0.0, pc-cdiff-1.0))/c, (corner-vec2(0.0, pc-cdiff-1.0)+vec2(1.0, count.y))/c, mortar, bevel);\n\t}\n}\n\nvec4 bricks_bw(vec2 uv, vec2 count, float repeat, float offset, float mortar, float bevel) {\n\tvec2 c = 2.0*count*repeat;\n\tfloat mc = max(c.x, c.y);\n\tmortar /= mc;\n\tbevel /= mc;\n\tvec2 corner1 = floor(uv*c);\n\tvec2 corner2 = count*floor(repeat*2.0*uv);\n\tfloat cdiff = mod(dot(floor(repeat*2.0*uv), vec2(1.0)), 2.0);\n\tvec2 corner;\n\tvec2 size;\n\tif (cdiff == 0.0) {\n\t\tcorner = vec2(corner1.x, corner2.y);\n\t\tsize = vec2(1.0, count.y);\n\t} else {\n\t\tcorner = vec2(corner2.x, corner1.y);\n\t\tsize = vec2(count.x, 1.0);\n\t}\n\treturn brick(uv, corner/c, (corner+size)/c, mortar, bevel);\n}\n\nvec4 bricks_sb(vec2 uv, vec2 count, float repeat, float offset, float mortar, float bevel) {\n\tvec2 c = (count+vec2(1.0))*repeat;\n\tfloat mc = max(c.x, c.y);\n\tmortar /= mc;\n\tbevel /= mc;\n\tvec2 corner1 = floor(uv*c);\n\tvec2 corner2 = (count+vec2(1.0))*floor(repeat*uv);\n\tvec2 rcorner = corner1 - corner2;\n\tvec2 corner;\n\tvec2 size;\n\tif (rcorner.x == 0.0 && rcorner.y < count.y) {\n\t\tcorner = corner2;\n\t\tsize = vec2(1.0, count.y);\n\t} else if (rcorner.y == 0.0) {\n\t\tcorner = corner2+vec2(1.0, 0.0);\n\t\tsize = vec2(count.x, 1.0);\n\t} else if (rcorner.x == count.x) {\n\t\tcorner = corner2+vec2(count.x, 1.0);\n\t\tsize = vec2(1.0, count.y);\n\t} else if (rcorner.y == count.y) {\n\t\tcorner = corner2+vec2(0.0, count.y);\n\t\tsize = vec2(count.x, 1.0);\n\t} else {\n\t\tcorner = corner2+vec2(1.0);\n\t\tsize = vec2(count.x-1.0, count.y-1.0);\n\t}\n\treturn brick(uv, corner/c, (corner+size)/c, mortar, bevel);\n}", "inputs": [ ], - "instance": "vec3 $(name)_xyz(vec2 uv) {\n return bricks_$(pattern)(uv, vec2($(columns), $(rows)), $(repeat), $(row_offset), $(mortar), max(0.001, $(bevel)));\n}", + "instance": "vec4 $(name)_xyzw(vec2 uv) {\n return bricks_$(pattern)(uv, vec2($(columns), $(rows)), $(repeat), $(row_offset), $(mortar), max(0.001, $(bevel)));\n}", "name": "Bricks", "outputs": [ { @@ -27,8 +27,16 @@ "type": "f" }, { - "rgb": "rand3($(name_uv).yz+vec2($(seed)))", + "rgb": "rand3(vec2($(name_uv).w, $(seed)))", "type": "rgb" + }, + { + "f": "$(name_uv).y", + "type": "f" + }, + { + "f": "$(name_uv).z", + "type": "f" } ], "parameters": [ @@ -67,8 +75,7 @@ "min": 1, "name": "repeat", "step": 1, - "type": "float", - "widget": "spinbox" + "type": "float" }, { "default": 6, @@ -77,8 +84,7 @@ "min": 1, "name": "rows", "step": 1, - "type": "float", - "widget": "spinbox" + "type": "float" }, { "default": 3, @@ -87,8 +93,7 @@ "min": 1, "name": "columns", "step": 1, - "type": "float", - "widget": "spinbox" + "type": "float" }, { "default": 0.5, @@ -96,7 +101,7 @@ "max": 1, "min": 0, "name": "row_offset", - "step": 0, + "step": 0.01, "type": "float" }, { diff --git a/addons/material_maker/nodes/brightness_contrast.mmg b/addons/material_maker/nodes/brightness_contrast.mmg new file mode 100644 index 0000000..de094c2 --- /dev/null +++ b/addons/material_maker/nodes/brightness_contrast.mmg @@ -0,0 +1,53 @@ +{ + "name": "brightness_contrast", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "brightness": 0, + "contrast": 1, + "steps": 6 + }, + "shader_model": { + "code": "", + "global": "", + "inputs": [ + { + "default": "0.0", + "label": "", + "name": "in", + "type": "rgba" + } + ], + "instance": "", + "name": "Brightness/Contrast", + "outputs": [ + { + "rgba": "vec4(clamp($in($uv).rgb*$contrast+vec3($brightness)+0.5-$contrast*0.5, vec3(0.0), vec3(1.0)), $in($uv).a)", + "type": "rgba" + } + ], + "parameters": [ + { + "default": 0, + "label": "Brightness", + "max": 1, + "min": -1, + "name": "brightness", + "step": 0.01, + "type": "float" + }, + { + "default": 1, + "label": "Contrast", + "max": 2, + "min": 0, + "name": "contrast", + "step": 0.01, + "type": "float" + } + ] + }, + "type": "shader" +} \ No newline at end of file diff --git a/addons/material_maker/nodes/directional_blur.mmg b/addons/material_maker/nodes/directional_blur.mmg index 0f018c4..7291262 100644 --- a/addons/material_maker/nodes/directional_blur.mmg +++ b/addons/material_maker/nodes/directional_blur.mmg @@ -32,7 +32,7 @@ } ], "label": "Directional Blur", - "name": "blur_directional", + "name": "directional_blur", "node_position": { "x": 0, "y": 0 @@ -62,7 +62,7 @@ }, "parameters": { "sigma": 50, - "size": 8 + "size": 9 }, "type": "convolution" }, @@ -73,7 +73,8 @@ "y": -271.75 }, "parameters": { - "size": 8 + "lod": 0, + "size": 9 }, "type": "buffer" }, @@ -84,7 +85,7 @@ "y": -413.666656 }, "parameters": { - "param0": 8, + "param0": 9, "param1": 50, "param2": 45 }, @@ -117,7 +118,7 @@ "type": "linked_control" }, { - "label": "Unnamed", + "label": "Angle:", "linked_widgets": [ { "node": "transform_3", @@ -170,8 +171,8 @@ { "name": "transform_3", "node_position": { - "x": -405.653931, - "y": -214.871338 + "x": -409.653931, + "y": -193.871338 }, "parameters": { "repeat": true, @@ -307,7 +308,7 @@ } ], "parameters": { - "param0": 8, + "param0": 9, "param1": 50, "param2": 45 }, diff --git a/addons/material_maker/nodes/invert.mmg b/addons/material_maker/nodes/invert.mmg new file mode 100644 index 0000000..372758e --- /dev/null +++ b/addons/material_maker/nodes/invert.mmg @@ -0,0 +1,34 @@ +{ + "name": "invert", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "steps": 6 + }, + "shader_model": { + "code": "", + "global": "", + "inputs": [ + { + "default": "0.0", + "label": "", + "name": "in", + "type": "rgba" + } + ], + "instance": "", + "name": "Invert", + "outputs": [ + { + "rgba": "vec4(vec3(1.0)-$in($uv).rgb, $in($uv).a)", + "type": "rgba" + } + ], + "parameters": [ + + ] + }, + "type": "shader" +} \ No newline at end of file diff --git a/addons/material_maker/nodes/noise_color.mmg b/addons/material_maker/nodes/noise_color.mmg new file mode 100644 index 0000000..7a37a5f --- /dev/null +++ b/addons/material_maker/nodes/noise_color.mmg @@ -0,0 +1,37 @@ +{ + "name": "noise_color", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "density": 0.5, + "size": 4 + }, + "shader_model": { + "code": "", + "global": "vec3 color_dots(vec2 uv, float size, int seed) {\n\tvec2 seed2 = rand2(vec2(float(seed), 1.0-float(seed)));\n\tuv /= size;\n\tvec2 point_pos = floor(uv)+vec2(0.5);\n return rand3(seed2+point_pos);\n}\n", + "inputs": [ + + ], + "instance": "vec3 $(name)_f(vec2 uv) {\n\treturn color_dots(uv, 1.0/$(size), $(seed));\n}\n", + "name": "Color Noise", + "outputs": [ + { + "rgb": "$(name)_f($(uv))", + "type": "rgb" + } + ], + "parameters": [ + { + "default": 8, + "first": 2, + "label": "Grid Size:", + "last": 12, + "name": "size", + "type": "size" + } + ] + }, + "type": "shader" +} \ No newline at end of file diff --git a/addons/material_maker/nodes/occlusion.mmg b/addons/material_maker/nodes/occlusion.mmg new file mode 100644 index 0000000..7116376 --- /dev/null +++ b/addons/material_maker/nodes/occlusion.mmg @@ -0,0 +1,319 @@ +{ + "connections": [ + { + "from": "buffer", + "from_port": 0, + "to": "blurx_convolution", + "to_port": 0 + }, + { + "from": "buffer_2", + "from_port": 0, + "to": "blurx_convolution_2", + "to_port": 0 + }, + { + "from": "gen_inputs", + "from_port": 0, + "to": "buffer", + "to_port": 0 + }, + { + "from": "blend", + "from_port": 0, + "to": "colorize", + "to_port": 0 + }, + { + "from": "blurx_convolution", + "from_port": 0, + "to": "buffer_2", + "to_port": 0 + }, + { + "from": "blurx_convolution_2", + "from_port": 0, + "to": "blend", + "to_port": 1 + }, + { + "from": "buffer", + "from_port": 0, + "to": "blend", + "to_port": 0 + }, + { + "from": "colorize", + "from_port": 0, + "to": "_2", + "to_port": 0 + }, + { + "from": "_2", + "from_port": 0, + "to": "gen_outputs", + "to_port": 0 + } + ], + "label": "Occlusion", + "name": "occlusion", + "node_position": { + "x": 0, + "y": 0 + }, + "nodes": [ + { + "convolution_params": { + "input_type": "rgba", + "matrix_function": "exp(-0.5*(pow(x/sigma, 2.0)))/(6.28318530718 *sigma*sigma)", + "normalized": true, + "output_type": "rgba", + "parameters": [ + { + "max": 50, + "min": 0.05, + "name": "sigma", + "type": "float" + } + ], + "x": 50, + "y": 0 + }, + "name": "blurx_convolution", + "node_position": { + "x": -407.5, + "y": -192.5 + }, + "parameters": { + "sigma": 50, + "size": 10 + }, + "type": "convolution" + }, + { + "name": "buffer_2", + "node_position": { + "x": -404.875, + "y": -116.625 + }, + "parameters": { + "lod": 0, + "size": 10 + }, + "type": "buffer" + }, + { + "convolution_params": { + "input_type": "rgba", + "matrix_function": "exp(-0.5*(pow(y/sigma, 2.0)))/(6.28318530718 *sigma*sigma)", + "normalized": true, + "output_type": "rgba", + "parameters": [ + { + "max": 50, + "min": 0.05, + "name": "sigma", + "type": "float" + } + ], + "x": 0, + "y": 50 + }, + "name": "blurx_convolution_2", + "node_position": { + "x": -407.125, + "y": -44.375 + }, + "parameters": { + "sigma": 50, + "size": 10 + }, + "type": "convolution" + }, + { + "name": "buffer", + "node_position": { + "x": -408.25, + "y": -265.75 + }, + "parameters": { + "lod": 0, + "size": 10 + }, + "type": "buffer" + }, + { + "name": "gen_parameters", + "node_position": { + "x": -447.666626, + "y": -370.666656 + }, + "parameters": { + "param0": 10, + "param1": 50, + "param2": 1 + }, + "type": "remote", + "widgets": [ + { + "label": "Grid size:", + "linked_widgets": [ + { + "node": "buffer", + "widget": "size" + }, + { + "node": "blurx_convolution", + "widget": "size" + }, + { + "node": "buffer_2", + "widget": "size" + }, + { + "node": "blurx_convolution_2", + "widget": "size" + } + ], + "name": "param0", + "type": "linked_control" + }, + { + "label": "Strength", + "linked_widgets": [ + { + "node": "_2", + "widget": "g" + } + ], + "name": "param2", + "type": "linked_control" + } + ] + }, + { + "name": "gen_inputs", + "node_position": { + "x": -585.666626, + "y": -112.392853 + }, + "parameters": { + + }, + "ports": [ + { + "name": "port0", + "type": "rgba" + } + ], + "type": "ios" + }, + { + "name": "gen_outputs", + "node_position": { + "x": 55.547607, + "y": -133.392853 + }, + "parameters": { + + }, + "ports": [ + { + "name": "port0", + "type": "rgba" + } + ], + "type": "ios" + }, + { + "name": "blend", + "node_position": { + "x": -420.79895, + "y": 27.16272 + }, + "parameters": { + "amount": 1, + "blend_type": 11 + }, + "type": "blend" + }, + { + "name": "colorize", + "node_position": { + "x": -167.79895, + "y": -178.83728 + }, + "parameters": { + "gradient": { + "interpolation": 1, + "points": [ + { + "a": 1, + "b": 1, + "g": 1, + "pos": 0, + "r": 1 + }, + { + "a": 1, + "b": 0, + "g": 0, + "pos": 1, + "r": 0 + } + ], + "type": "Gradient" + } + }, + "type": "colorize" + }, + { + "name": "_2", + "node_position": { + "x": -134.403687, + "y": -110.29187 + }, + "parameters": { + "g": 1 + }, + "shader_model": { + "code": "", + "global": "", + "inputs": [ + { + "default": "0.0", + "label": "", + "name": "in", + "type": "f" + } + ], + "instance": "", + "name": "", + "outputs": [ + { + "f": "pow($in($uv), $g)", + "type": "f" + } + ], + "parameters": [ + { + "default": 1, + "label": "", + "max": 2, + "min": 0, + "name": "g", + "step": 0.1, + "type": "float" + } + ] + }, + "type": "shader" + } + ], + "parameters": { + "param0": 10, + "param1": 50, + "param2": 1 + }, + "type": "graph" +} \ No newline at end of file diff --git a/addons/material_maker/nodes/optional.mmg b/addons/material_maker/nodes/optional.mmg new file mode 100644 index 0000000..eee1781 --- /dev/null +++ b/addons/material_maker/nodes/optional.mmg @@ -0,0 +1,50 @@ +{ + "name": "optional", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "d": { + "a": 0, + "b": 0, + "g": 0, + "r": 0, + "type": "Color" + } + }, + "shader_model": { + "code": "", + "global": "", + "inputs": [ + { + "default": "$d", + "label": "", + "name": "in", + "type": "rgba" + } + ], + "instance": "", + "name": "Optional", + "outputs": [ + { + "rgba": "$in($uv)", + "type": "rgba" + } + ], + "parameters": [ + { + "default": { + "a": 0, + "b": 0, + "g": 0, + "r": 0 + }, + "label": "", + "name": "d", + "type": "color" + } + ] + }, + "type": "shader" +} \ No newline at end of file diff --git a/addons/material_maker/nodes/perlin_rgb.mmg b/addons/material_maker/nodes/perlin_rgb.mmg new file mode 100644 index 0000000..47c96d4 --- /dev/null +++ b/addons/material_maker/nodes/perlin_rgb.mmg @@ -0,0 +1,67 @@ +{ + "name": "perlin_rgb", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "iterations": 3, + "persistence": 0.5, + "scale_x": 4, + "scale_y": 4 + }, + "shader_model": { + "code": "", + "global": "vec3 perlin_color(vec2 uv, vec2 size, int iterations, float persistence, int seed) {\n\tvec2 seed2 = rand2(vec2(float(seed), 1.0-float(seed)));\n vec3 rv = vec3(0.0);\n float coef = 1.0;\n float acc = 0.0;\n for (int i = 0; i < iterations; ++i) {\n \tvec2 step = vec2(1.0)/size;\n\t\tvec2 xy = floor(uv*size);\n vec3 f0 = rand3(seed2+mod(xy, size));\n vec3 f1 = rand3(seed2+mod(xy+vec2(1.0, 0.0), size));\n vec3 f2 = rand3(seed2+mod(xy+vec2(0.0, 1.0), size));\n vec3 f3 = rand3(seed2+mod(xy+vec2(1.0, 1.0), size));\n vec2 mixval = smoothstep(0.0, 1.0, fract(uv*size));\n rv += coef * mix(mix(f0, f1, mixval.x), mix(f2, f3, mixval.x), mixval.y);\n acc += coef;\n size *= 2.0;\n coef *= persistence;\n }\n \n return rv / acc;\n}\n", + "inputs": [ + + ], + "instance": "", + "name": "PerlinRGB", + "outputs": [ + { + "rgb": "perlin_color($(uv), vec2($(scale_x), $(scale_y)), int($(iterations)), $(persistence), $(seed))", + "type": "rgb" + } + ], + "parameters": [ + { + "default": 4, + "label": "Scale X", + "max": 32, + "min": 1, + "name": "scale_x", + "step": 1, + "type": "float" + }, + { + "default": 4, + "label": "Scale Y", + "max": 32, + "min": 1, + "name": "scale_y", + "step": 1, + "type": "float" + }, + { + "default": 3, + "label": "Iterations", + "max": 10, + "min": 1, + "name": "iterations", + "step": 1, + "type": "float" + }, + { + "default": 0.5, + "label": "Persistance", + "max": 1, + "min": 0, + "name": "persistence", + "step": 0.05, + "type": "float" + } + ] + }, + "type": "shader" +} \ No newline at end of file diff --git a/addons/material_maker/nodes/quantize.mmg b/addons/material_maker/nodes/quantize.mmg new file mode 100644 index 0000000..9f2245c --- /dev/null +++ b/addons/material_maker/nodes/quantize.mmg @@ -0,0 +1,42 @@ +{ + "name": "quantize", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "steps": 6 + }, + "shader_model": { + "code": "", + "global": "", + "inputs": [ + { + "default": "0.0", + "label": "", + "name": "in", + "type": "rgba" + } + ], + "instance": "", + "name": "Quantize", + "outputs": [ + { + "rgba": "vec4(floor($in($uv).rgb*$steps)/$steps, $in($uv).a)", + "type": "rgba" + } + ], + "parameters": [ + { + "default": 8, + "label": "", + "max": 32, + "min": 2, + "name": "steps", + "step": 1, + "type": "float" + } + ] + }, + "type": "shader" +} \ No newline at end of file diff --git a/addons/material_maker/nodes/runes.mmg b/addons/material_maker/nodes/runes.mmg index dbdf9b5..ca9193e 100644 --- a/addons/material_maker/nodes/runes.mmg +++ b/addons/material_maker/nodes/runes.mmg @@ -5,10 +5,11 @@ "y": 0 }, "parameters": { - "columns": 8, - "rows": 8 + "columns": 4, + "rows": 4 }, "shader_model": { + "code": "", "global": "float ThickLine(vec2 uv, vec2 posA, vec2 posB, float radiusInv)\n{\n\tvec2 dir = posA - posB;\n\tfloat dirLen = length(dir);\n\tvec2 dirN = normalize(dir);\n\tfloat dotTemp = clamp(dot(uv - posB, dirN), 0.0, dirLen);\n\tvec2 proj = dotTemp * dirN + posB;\n\tfloat d1 = length(uv - proj);\n\tfloat finalGray = clamp(1.0 - d1 * radiusInv, 0.0, 1.0);\n\treturn finalGray;\n}\n\n// makes a rune in the 0..1 uv space. Seed is which rune to draw.\n// passes back gray in x and derivates for lighting in yz\nfloat Rune(vec2 uv) {\n\tfloat finalLine = 0.0;\n\tvec2 seed = floor(uv)-0.41;\n\tuv = fract(uv);\n\tfor (int i = 0; i < 4; i++)\t// number of strokes\n\t{\n\t\tvec2 posA = rand2(floor(seed+0.5));\n\t\tvec2 posB = rand2(floor(seed+1.5));\n\t\tseed += 2.0;\n\t\t// expand the range and mod it to get a nicely distributed random number - hopefully. :)\n\t\tposA = fract(posA * 128.0);\n\t\tposB = fract(posB * 128.0);\n\t\t// each rune touches the edge of its box on all 4 sides\n\t\tif (i == 0) posA.y = 0.0;\n\t\tif (i == 1) posA.x = 0.999;\n\t\tif (i == 2) posA.x = 0.0;\n\t\tif (i == 3) posA.y = 0.999;\n\t\t// snap the random line endpoints to a grid 2x3\n\t\tvec2 snaps = vec2(2.0, 3.0);\n\t\tposA = (floor(posA * snaps) + 0.5) / snaps;\t// + 0.5 to center it in a grid cell\n\t\tposB = (floor(posB * snaps) + 0.5) / snaps;\n\t\t//if (distance(posA, posB) < 0.0001) continue;\t// eliminate dots.\n\t\t// Dots (degenerate lines) are not cross-GPU safe without adding 0.001 - divide by 0 error.\n\t\tfinalLine = max(finalLine, ThickLine(uv, posA, posB + 0.001, 20.0));\n\t}\n\treturn finalLine;\n}\n\n\n", "inputs": [ @@ -24,23 +25,21 @@ "parameters": [ { "default": 0, - "label": "", + "label": "Size X", "max": 32, "min": 2, "name": "columns", "step": 1, - "type": "float", - "widget": "spinbox" + "type": "float" }, { "default": 0, - "label": "", + "label": "Size Y", "max": 32, "min": 2, "name": "rows", "step": 1, - "type": "float", - "widget": "spinbox" + "type": "float" } ] }, diff --git a/addons/material_maker/nodes/splatter_base.mmg b/addons/material_maker/nodes/splatter_base.mmg new file mode 100644 index 0000000..c3fc5b5 --- /dev/null +++ b/addons/material_maker/nodes/splatter_base.mmg @@ -0,0 +1,80 @@ +{ + "name": "splatter_base", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "name": 0.5, + "offx": 0, + "offy": 0, + "repeat": 8, + "scale": 1.78, + "size": 1 + }, + "shader_model": { + "code": "vec4 $(name_uv)_xyzw = splatter($uv, $repeat, $scale, vec2($offx, $offy));", + "global": "vec4 splatter(vec2 uv, float repeat, float scale, vec2 offset) {\n\tvec2 center = (floor(uv*repeat-offset)+0.5+offset)/repeat;\n\tvec2 tmp = (uv-center)*repeat*2.0;\n\tvec2 src_uv;\n\tsrc_uv.x = tmp.x*cos(center.x)+tmp.y*sin(center.x);\n\tsrc_uv.y = tmp.x*sin(center.x)-tmp.y*cos(center.x);\n\tsrc_uv /= scale;\n\tsrc_uv += 0.5;\n\treturn vec4(src_uv, center);\n}", + "inputs": [ + { + "default": "0.0", + "label": "", + "name": "in", + "type": "f" + }, + { + "default": "0.0", + "label": "", + "name": "mask", + "type": "f" + } + ], + "instance": "", + "name": "Splatter", + "outputs": [ + { + "f": "$in($(name_uv)_xyzw.xy)*$mask($(name_uv)_xyzw.zw)", + "type": "f" + } + ], + "parameters": [ + { + "default": 4, + "label": "Repeat", + "max": 128, + "min": 2, + "name": "repeat", + "step": 1, + "type": "float" + }, + { + "default": 1, + "label": "Scale", + "max": 2, + "min": 0, + "name": "scale", + "step": 0.01, + "type": "float" + }, + { + "default": 0.5, + "label": "Offset X", + "max": 1, + "min": 0, + "name": "offx", + "step": 0.1, + "type": "float" + }, + { + "default": 0.5, + "label": "Offset Y", + "max": 1, + "min": 0, + "name": "offy", + "step": 0.1, + "type": "float" + } + ] + }, + "type": "shader" +} \ No newline at end of file diff --git a/addons/material_maker/nodes/uniform_greyscale.mmg b/addons/material_maker/nodes/uniform_greyscale.mmg new file mode 100644 index 0000000..5b6fcc7 --- /dev/null +++ b/addons/material_maker/nodes/uniform_greyscale.mmg @@ -0,0 +1,37 @@ +{ + "name": "uniform_greyscale", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "color": 0.5 + }, + "shader_model": { + "code": "", + "global": "", + "inputs": [ + + ], + "instance": "", + "name": "Greyscale Uniform", + "outputs": [ + { + "f": "$(color)", + "type": "f" + } + ], + "parameters": [ + { + "default": 0.5, + "label": "", + "max": 1, + "min": 0, + "name": "color", + "step": 0.01, + "type": "float" + } + ] + }, + "type": "shader" +} \ No newline at end of file diff --git a/addons/material_maker/nodes/voronoi.mmg b/addons/material_maker/nodes/voronoi.mmg index ea17116..2610c9d 100644 --- a/addons/material_maker/nodes/voronoi.mmg +++ b/addons/material_maker/nodes/voronoi.mmg @@ -5,14 +5,16 @@ "y": 0 }, "parameters": { - "intensity": 0.4, - "randomness": 1, - "scale_x": 16, - "scale_y": 16 + "intensity": 1, + "randomness": 0.75, + "scale_x": 4, + "scale_y": 4, + "stretch_x": 1, + "stretch_y": 1 }, "shader_model": { - "code": "", - "global": "vec4 voronoi(vec2 uv, vec2 size, float intensity, float randomness, int seed) {\n\tvec2 seed2 = rand2(vec2(float(seed), 1.0-float(seed)));\n uv *= size;\n float best_distance0 = 1.0;\n float best_distance1 = 1.0;\n vec2 point0;\n vec2 point1;\n vec2 p0 = floor(uv);\n for (int dx = -1; dx < 2; ++dx) {\n \tfor (int dy = -1; dy < 2; ++dy) {\n vec2 d = vec2(float(dx), float(dy));\n vec2 p = p0+d;\n p += randomness*rand2(seed2+mod(p, size));\n float distance = length((uv - p) / size);\n if (best_distance0 > distance) {\n \tbest_distance1 = best_distance0;\n \tbest_distance0 = distance;\n point1 = point0;\n point0 = p;\n } else if (best_distance1 > distance) {\n \tbest_distance1 = distance;\n point1 = p;\n }\n }\n }\n float edge_distance = dot(uv - 0.5*(point0+point1), normalize(point0-point1));\n \n return vec4(point0, best_distance0*length(size)*intensity, edge_distance);\n}\n", + "code": "vec4 $(name_uv)_xyzw = voronoi($uv, vec2($scale_x, $scale_y), vec2($stretch_y, $stretch_x), $intensity, $randomness, $seed);", + "global": "vec4 voronoi(vec2 uv, vec2 size, vec2 stretch, float intensity, float randomness, int seed) {\n\tvec2 seed2 = rand2(vec2(float(seed), 1.0-float(seed)));\n uv *= size;\n float best_distance0 = 1.0;\n float best_distance1 = 1.0;\n vec2 point0;\n vec2 point1;\n vec2 p0 = floor(uv);\n for (int dx = -1; dx < 2; ++dx) {\n \tfor (int dy = -1; dy < 2; ++dy) {\n vec2 d = vec2(float(dx), float(dy));\n vec2 p = p0+d;\n p += randomness*rand2(seed2+mod(p, size));\n float distance = length(stretch*(uv - p) / size);\n if (best_distance0 > distance) {\n \tbest_distance1 = best_distance0;\n \tbest_distance0 = distance;\n point1 = point0;\n point0 = p;\n } else if (best_distance1 > distance) {\n \tbest_distance1 = distance;\n point1 = p;\n }\n }\n }\n float edge_distance = dot(uv - 0.5*(point0+point1), normalize(point0-point1));\n \n return vec4(point0, best_distance0*length(size)*intensity, edge_distance);\n}\n", "inputs": [ ], @@ -20,15 +22,15 @@ "name": "Voronoi", "outputs": [ { - "f": "voronoi($uv, vec2($scale_x, $scale_y), $intensity, $randomness, $seed).z", + "f": "$(name_uv)_xyzw.z", "type": "f" }, { - "f": "voronoi($uv, vec2($scale_x, $scale_y), $intensity, $randomness, $seed).w", + "f": "$(name_uv)_xyzw.w", "type": "f" }, { - "rgb": "rand3(fract(voronoi($uv, vec2($scale_x, $scale_y), $intensity, $randomness, $seed).xy))", + "rgb": "rand3(fract($(name_uv)_xyzw.xy))", "type": "rgb" } ], @@ -52,12 +54,30 @@ "type": "float" }, { - "default": 0.5, + "default": 1, + "label": "Stretch X", + "max": 1, + "min": 0.01, + "name": "stretch_x", + "step": 0.01, + "type": "float" + }, + { + "default": 1, + "label": "Stretch Y", + "max": 1, + "min": 0.01, + "name": "stretch_y", + "step": 0.01, + "type": "float" + }, + { + "default": 0.75, "label": "Intensity", "max": 1, "min": 0, "name": "intensity", - "step": 0.05, + "step": 0.01, "type": "float" }, { diff --git a/addons/material_maker/nodes/weave.mmg b/addons/material_maker/nodes/weave.mmg index 1688e84..b2fbd4f 100644 --- a/addons/material_maker/nodes/weave.mmg +++ b/addons/material_maker/nodes/weave.mmg @@ -5,11 +5,12 @@ "y": 0 }, "parameters": { - "columns": 8, - "rows": 8, + "columns": 4, + "rows": 4, "width": 0.85 }, "shader_model": { + "code": "", "global": "float weave(vec2 uv, vec2 count, float width) {\n uv *= count;\n\tfloat c = (sin(3.1415926*(uv.x+floor(uv.y)))*0.5+0.5)*step(abs(fract(uv.y)-0.5), width*0.5);\n\tc = max(c, (sin(3.1415926*(1.0+uv.y+floor(uv.x)))*0.5+0.5)*step(abs(fract(uv.x)-0.5), width*0.5));\n\treturn c;\n}", "inputs": [ @@ -25,27 +26,25 @@ "parameters": [ { "default": 4, - "label": "", + "label": "Size X", "max": 32, "min": 2, "name": "columns", "step": 1, - "type": "float", - "widget": "spinbox" + "type": "float" }, { "default": 4, - "label": "", + "label": "Size Y", "max": 32, "min": 2, "name": "rows", "step": 1, - "type": "float", - "widget": "spinbox" + "type": "float" }, { "default": 0.8, - "label": "", + "label": "Width", "max": 1, "min": 0, "name": "width",