mirror of
https://github.com/Relintai/material-maker.git
synced 2024-12-23 21:16:54 +01:00
Added fbm, sdf3d coloring and 3d textures nodes
This commit is contained in:
parent
ddd99eee44
commit
85bc6074b8
92
addons/material_maker/nodes/fbm.mmg
Normal file
92
addons/material_maker/nodes/fbm.mmg
Normal file
@ -0,0 +1,92 @@
|
||||
{
|
||||
"name": "fbm",
|
||||
"node_position": {
|
||||
"x": 0,
|
||||
"y": 0
|
||||
},
|
||||
"parameters": {
|
||||
"iterations": 3,
|
||||
"noise": 0,
|
||||
"persistence": 0.5,
|
||||
"scale_x": 4,
|
||||
"scale_y": 4
|
||||
},
|
||||
"shader_model": {
|
||||
"code": "",
|
||||
"global": "float fbm_value(vec2 coord, vec2 size, float seed) {\n\tvec2 o = floor(coord)+rand2(vec2(float(seed), 1.0-float(seed)))+size;\n\tvec2 f = fract(coord);\n\tfloat p00 = rand(mod(o, size));\n\tfloat p01 = rand(mod(o + vec2(0.0, 1.0), size));\n\tfloat p10 = rand(mod(o + vec2(1.0, 0.0), size));\n\tfloat p11 = rand(mod(o + vec2(1.0, 1.0), size));\n\tvec2 t = f * f * (3.0 - 2.0 * f);\n\treturn mix(mix(p00, p10, t.x), mix(p01, p11, t.x), t.y);\n}\n\nfloat fbm_perlin(vec2 coord, vec2 size, float seed) {\n\tvec2 o = floor(coord)+rand2(vec2(float(seed), 1.0-float(seed)))+size;\n\tvec2 f = fract(coord);\n\tfloat a00 = rand(mod(o, size)) * 6.28318530718;\n\tfloat a01 = rand(mod(o + vec2(0.0, 1.0), size)) * 6.28318530718;\n\tfloat a10 = rand(mod(o + vec2(1.0, 0.0), size)) * 6.28318530718;\n\tfloat a11 = rand(mod(o + vec2(1.0, 1.0), size)) * 6.28318530718;\n\tvec2 v00 = vec2(cos(a00), sin(a00));\n\tvec2 v01 = vec2(cos(a01), sin(a01));\n\tvec2 v10 = vec2(cos(a10), sin(a10));\n\tvec2 v11 = vec2(cos(a11), sin(a11));\n\tfloat p00 = dot(v00, f);\n\tfloat p01 = dot(v01, f - vec2(0.0, 1.0));\n\tfloat p10 = dot(v10, f - vec2(1.0, 0.0));\n\tfloat p11 = dot(v11, f - vec2(1.0, 1.0));\n\tvec2 t = f * f * (3.0 - 2.0 * f);\n\treturn 0.5 + mix(mix(p00, p10, t.x), mix(p01, p11, t.x), t.y);\n}\n\nfloat fbm_cellular(vec2 coord, vec2 size, float seed) {\n\tvec2 o = floor(coord)+rand2(vec2(float(seed), 1.0-float(seed)))+size;\n\tvec2 f = fract(coord);\n\tfloat min_dist = 2.0;\n\tfor(float x = -1.0; x <= 1.0; x++) {\n\t\tfor(float y = -1.0; y <= 1.0; y++) {\n\t\t\tvec2 node = rand2(mod(o + vec2(x, y), size)) + vec2(x, y);\n\t\t\tfloat dist = sqrt((f - node).x * (f - node).x + (f - node).y * (f - node).y);\n\t\t\tmin_dist = min(min_dist, dist);\n\t\t}\n\t}\n\treturn min_dist;\n}\n",
|
||||
"inputs": [
|
||||
|
||||
],
|
||||
"instance": "float $(name)_fbm(vec2 coord, vec2 size, int octaves, float persistence, float seed) {\n\tfloat normalize_factor = 0.0;\n\tfloat value = 0.0;\n\tfloat scale = 1.0;\n\tfor (int i = 0; i < octaves; i++) {\n\t\tvalue += fbm_$noise(coord*size, size, seed) * scale;\n\t\tnormalize_factor += scale;\n\t\tsize *= 2.0;\n\t\tscale *= persistence;\n\t}\n\treturn value / normalize_factor;\n}\n",
|
||||
"name": "FBM",
|
||||
"outputs": [
|
||||
{
|
||||
"f": "$(name)_fbm($(uv), vec2($(scale_x), $(scale_y)), int($(iterations)), $(persistence), $(seed))",
|
||||
"type": "f"
|
||||
}
|
||||
],
|
||||
"parameters": [
|
||||
{
|
||||
"default": 2,
|
||||
"label": "Noise",
|
||||
"name": "noise",
|
||||
"type": "enum",
|
||||
"values": [
|
||||
{
|
||||
"name": "Value",
|
||||
"value": "value"
|
||||
},
|
||||
{
|
||||
"name": "Perlin",
|
||||
"value": "perlin"
|
||||
},
|
||||
{
|
||||
"name": "Cellular",
|
||||
"value": "cellular"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"control": "None",
|
||||
"default": 4,
|
||||
"label": "Scale X",
|
||||
"max": 32,
|
||||
"min": 1,
|
||||
"name": "scale_x",
|
||||
"step": 1,
|
||||
"type": "float"
|
||||
},
|
||||
{
|
||||
"control": "None",
|
||||
"default": 4,
|
||||
"label": "Scale Y",
|
||||
"max": 32,
|
||||
"min": 1,
|
||||
"name": "scale_y",
|
||||
"step": 1,
|
||||
"type": "float"
|
||||
},
|
||||
{
|
||||
"control": "None",
|
||||
"default": 3,
|
||||
"label": "Iterations",
|
||||
"max": 10,
|
||||
"min": 1,
|
||||
"name": "iterations",
|
||||
"step": 1,
|
||||
"type": "float"
|
||||
},
|
||||
{
|
||||
"control": "None",
|
||||
"default": 0.5,
|
||||
"label": "Persistance",
|
||||
"max": 1,
|
||||
"min": 0,
|
||||
"name": "persistence",
|
||||
"step": 0.05,
|
||||
"type": "float"
|
||||
}
|
||||
]
|
||||
},
|
||||
"type": "shader"
|
||||
}
|
51
addons/material_maker/nodes/sdf3d_color.mmg
Normal file
51
addons/material_maker/nodes/sdf3d_color.mmg
Normal file
@ -0,0 +1,51 @@
|
||||
{
|
||||
"name": "sdf3d_color",
|
||||
"node_position": {
|
||||
"x": 0,
|
||||
"y": 0
|
||||
},
|
||||
"parameters": {
|
||||
"bevel": 0,
|
||||
"c": 0.5,
|
||||
"cx": 0,
|
||||
"cy": 0,
|
||||
"h": 0.08,
|
||||
"k": 0.15,
|
||||
"op": 0,
|
||||
"r": 0.15,
|
||||
"w": 0.28
|
||||
},
|
||||
"shader_model": {
|
||||
"code": "",
|
||||
"global": "",
|
||||
"inputs": [
|
||||
{
|
||||
"default": "0.0",
|
||||
"label": "",
|
||||
"name": "in",
|
||||
"type": "sdf3d"
|
||||
}
|
||||
],
|
||||
"instance": "",
|
||||
"name": "Color",
|
||||
"outputs": [
|
||||
{
|
||||
"sdf3dc": "vec2($in($uv), $c)",
|
||||
"type": "sdf3dc"
|
||||
}
|
||||
],
|
||||
"parameters": [
|
||||
{
|
||||
"control": "None",
|
||||
"default": 0,
|
||||
"label": "",
|
||||
"max": 1,
|
||||
"min": 0,
|
||||
"name": "c",
|
||||
"step": 0.01,
|
||||
"type": "float"
|
||||
}
|
||||
]
|
||||
},
|
||||
"type": "shader"
|
||||
}
|
108
addons/material_maker/nodes/tex3d_blend.mmg
Normal file
108
addons/material_maker/nodes/tex3d_blend.mmg
Normal file
@ -0,0 +1,108 @@
|
||||
{
|
||||
"name": "tex3d_blend",
|
||||
"node_position": {
|
||||
"x": 0,
|
||||
"y": 0
|
||||
},
|
||||
"parameters": {
|
||||
"amount": 1,
|
||||
"blend_type": 0
|
||||
},
|
||||
"shader_model": {
|
||||
"code": "",
|
||||
"global": "vec3 blend3d_normal(vec3 c1, vec3 c2, float opacity) {\n\treturn opacity*c1 + (1.0-opacity)*c2;\n}\n\nvec3 blend3d_multiply(vec3 c1, vec3 c2, float opacity) {\n\treturn opacity*c1*c2 + (1.0-opacity)*c2;\n}\n\nvec3 blend3d_screen(vec3 c1, vec3 c2, float opacity) {\n\treturn opacity*(1.0-(1.0-c1)*(1.0-c2)) + (1.0-opacity)*c2;\n}\n\nfloat blend3d_overlay_f(float c1, float c2) {\n\treturn (c1 < 0.5) ? (2.0*c1*c2) : (1.0-2.0*(1.0-c1)*(1.0-c2));\n}\n\nvec3 blend3d_overlay(vec3 c1, vec3 c2, float opacity) {\n\treturn opacity*vec3(blend3d_overlay_f(c1.x, c2.x), blend3d_overlay_f(c1.y, c2.y), blend3d_overlay_f(c1.z, c2.z)) + (1.0-opacity)*c2;\n}\n\nvec3 blend3d_hard_light(vec3 c1, vec3 c2, float opacity) {\n\treturn opacity*0.5*(c1*c2+blend3d_overlay(c1, c2, 1.0)) + (1.0-opacity)*c2;\n}\n\nfloat blend3d_soft_light_f(float c1, float c2) {\n\treturn (c2 < 0.5) ? (2.0*c1*c2+c1*c1*(1.0-2.0*c2)) : 2.0*c1*(1.0-c2)+sqrt(c1)*(2.0*c2-1.0);\n}\n\nvec3 blend3d_soft_light(vec3 c1, vec3 c2, float opacity) {\n\treturn opacity*vec3(blend3d_soft_light_f(c1.x, c2.x), blend3d_soft_light_f(c1.y, c2.y), blend3d_soft_light_f(c1.z, c2.z)) + (1.0-opacity)*c2;\n}\n\nfloat blend3d_burn_f(float c1, float c2) {\n\treturn (c1==0.0)?c1:max((1.0-((1.0-c2)/c1)),0.0);\n}\n\nvec3 blend3d_burn(vec3 c1, vec3 c2, float opacity) {\n\treturn opacity*vec3(blend3d_burn_f(c1.x, c2.x), blend3d_burn_f(c1.y, c2.y), blend3d_burn_f(c1.z, c2.z)) + (1.0-opacity)*c2;\n}\n\nfloat blend3d_dodge_f(float c1, float c2) {\n\treturn (c1==1.0)?c1:min(c2/(1.0-c1),1.0);\n}\n\nvec3 blend3d_dodge(vec3 c1, vec3 c2, float opacity) {\n\treturn opacity*vec3(blend3d_dodge_f(c1.x, c2.x), blend3d_dodge_f(c1.y, c2.y), blend3d_dodge_f(c1.z, c2.z)) + (1.0-opacity)*c2;\n}\n\nvec3 blend_lighten(vec2 uv, vec3 c1, vec3 c2, float opacity) {\n\treturn opacity*max(c1, c2) + (1.0-opacity)*c2;\n}\n\nvec3 blend_darken(vec2 uv, vec3 c1, vec3 c2, float opacity) {\n\treturn opacity*min(c1, c2) + (1.0-opacity)*c2;\n}\n\nvec3 blend_difference(vec2 uv, vec3 c1, vec3 c2, float opacity) {\n\treturn opacity*clamp(c2-c1, vec3(0.0), vec3(1.0)) + (1.0-opacity)*c2;\n}\n",
|
||||
"inputs": [
|
||||
{
|
||||
"default": "vec3($uv.x, 1.0, 1.0)",
|
||||
"label": "Source1",
|
||||
"name": "s1",
|
||||
"type": "tex3d"
|
||||
},
|
||||
{
|
||||
"default": "vec3(1.0, $uv.y, 1.0)",
|
||||
"label": "Source2",
|
||||
"name": "s2",
|
||||
"type": "tex3d"
|
||||
},
|
||||
{
|
||||
"default": "vec3(1.0)",
|
||||
"label": "Opacity",
|
||||
"name": "a",
|
||||
"type": "tex3d"
|
||||
}
|
||||
],
|
||||
"instance": "",
|
||||
"name": "TEX3D Blend",
|
||||
"outputs": [
|
||||
{
|
||||
"tex3d": "blend3d_$blend_type($s1($uv).rgb, $s2($uv).rgb, $amount*dot($a($uv), vec3(1.0))/3.0)",
|
||||
"type": "tex3d"
|
||||
}
|
||||
],
|
||||
"parameters": [
|
||||
{
|
||||
"default": 0,
|
||||
"label": "",
|
||||
"name": "blend_type",
|
||||
"type": "enum",
|
||||
"values": [
|
||||
{
|
||||
"name": "Normal",
|
||||
"value": "normal"
|
||||
},
|
||||
{
|
||||
"name": "Multiply",
|
||||
"value": "multiply"
|
||||
},
|
||||
{
|
||||
"name": "Screen",
|
||||
"value": "screen"
|
||||
},
|
||||
{
|
||||
"name": "Overlay",
|
||||
"value": "overlay"
|
||||
},
|
||||
{
|
||||
"name": "Hard Light",
|
||||
"value": "hard_light"
|
||||
},
|
||||
{
|
||||
"name": "Soft Light",
|
||||
"value": "soft_light"
|
||||
},
|
||||
{
|
||||
"name": "Burn",
|
||||
"value": "burn"
|
||||
},
|
||||
{
|
||||
"name": "Dodge",
|
||||
"value": "dodge"
|
||||
},
|
||||
{
|
||||
"name": "Lighten",
|
||||
"value": "lighten"
|
||||
},
|
||||
{
|
||||
"name": "Darken",
|
||||
"value": "darken"
|
||||
},
|
||||
{
|
||||
"name": "Difference",
|
||||
"value": "difference"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"control": "None",
|
||||
"default": 0.5,
|
||||
"label": "3:",
|
||||
"max": 1,
|
||||
"min": 0,
|
||||
"name": "amount",
|
||||
"step": 0,
|
||||
"type": "float"
|
||||
}
|
||||
]
|
||||
},
|
||||
"type": "shader"
|
||||
}
|
99
addons/material_maker/nodes/tex3d_colorize.mmg
Normal file
99
addons/material_maker/nodes/tex3d_colorize.mmg
Normal file
@ -0,0 +1,99 @@
|
||||
{
|
||||
"name": "tex3d_colorize",
|
||||
"node_position": {
|
||||
"x": 0,
|
||||
"y": 0
|
||||
},
|
||||
"parameters": {
|
||||
"Color": {
|
||||
"a": 1,
|
||||
"b": 0,
|
||||
"g": 0.381909,
|
||||
"r": 1,
|
||||
"type": "Color"
|
||||
},
|
||||
"bevel": 0,
|
||||
"color": {
|
||||
"a": 1,
|
||||
"b": 0,
|
||||
"g": 0,
|
||||
"r": 1,
|
||||
"type": "Color"
|
||||
},
|
||||
"cx": 0,
|
||||
"cy": 0,
|
||||
"g": {
|
||||
"interpolation": 1,
|
||||
"points": [
|
||||
{
|
||||
"a": 1,
|
||||
"b": 0,
|
||||
"g": 0.071126,
|
||||
"pos": 0,
|
||||
"r": 0.119792
|
||||
},
|
||||
{
|
||||
"a": 1,
|
||||
"b": 0.372549,
|
||||
"g": 0.756863,
|
||||
"pos": 1,
|
||||
"r": 1
|
||||
}
|
||||
],
|
||||
"type": "Gradient"
|
||||
},
|
||||
"h": 0.08,
|
||||
"k": 0.15,
|
||||
"op": 0,
|
||||
"r": 0.15,
|
||||
"w": 0.28
|
||||
},
|
||||
"shader_model": {
|
||||
"code": "",
|
||||
"global": "",
|
||||
"inputs": [
|
||||
{
|
||||
"default": "vec3($uv.x+0.5)",
|
||||
"label": "",
|
||||
"name": "in",
|
||||
"type": "tex3d"
|
||||
}
|
||||
],
|
||||
"instance": "",
|
||||
"name": "TEX3D Colorize",
|
||||
"outputs": [
|
||||
{
|
||||
"tex3d": "$g(dot($in($uv), vec3(1.0))/3.0).rgb",
|
||||
"type": "tex3d"
|
||||
}
|
||||
],
|
||||
"parameters": [
|
||||
{
|
||||
"default": {
|
||||
"interpolation": 1,
|
||||
"points": [
|
||||
{
|
||||
"a": 1,
|
||||
"b": 0,
|
||||
"g": 0,
|
||||
"pos": 0,
|
||||
"r": 0
|
||||
},
|
||||
{
|
||||
"a": 1,
|
||||
"b": 1,
|
||||
"g": 1,
|
||||
"pos": 1,
|
||||
"r": 1
|
||||
}
|
||||
],
|
||||
"type": "Gradient"
|
||||
},
|
||||
"label": "",
|
||||
"name": "g",
|
||||
"type": "gradient"
|
||||
}
|
||||
]
|
||||
},
|
||||
"type": "shader"
|
||||
}
|
71
addons/material_maker/nodes/tex3d_distort.mmg
Normal file
71
addons/material_maker/nodes/tex3d_distort.mmg
Normal file
@ -0,0 +1,71 @@
|
||||
{
|
||||
"name": "tex3d_distort",
|
||||
"node_position": {
|
||||
"x": 0,
|
||||
"y": 0
|
||||
},
|
||||
"parameters": {
|
||||
"Color": {
|
||||
"a": 1,
|
||||
"b": 0.145098,
|
||||
"g": 0.443137,
|
||||
"r": 0.92549,
|
||||
"type": "Color"
|
||||
},
|
||||
"Distort": 0.3,
|
||||
"bevel": 0,
|
||||
"color": {
|
||||
"a": 1,
|
||||
"b": 0,
|
||||
"g": 0,
|
||||
"r": 1,
|
||||
"type": "Color"
|
||||
},
|
||||
"cx": 0,
|
||||
"cy": 0,
|
||||
"h": 0.08,
|
||||
"k": 0.15,
|
||||
"op": 0,
|
||||
"r": 0.15,
|
||||
"w": 0.28
|
||||
},
|
||||
"shader_model": {
|
||||
"code": "",
|
||||
"global": "",
|
||||
"inputs": [
|
||||
{
|
||||
"default": "0.0",
|
||||
"label": "",
|
||||
"name": "in1",
|
||||
"type": "tex3d"
|
||||
},
|
||||
{
|
||||
"default": "0.0",
|
||||
"label": "",
|
||||
"name": "in2",
|
||||
"type": "tex3d"
|
||||
}
|
||||
],
|
||||
"instance": "",
|
||||
"name": "TEX3D Distort",
|
||||
"outputs": [
|
||||
{
|
||||
"tex3d": "$in1(vec4($uv.xyz+($in2($uv)*$Distort*0.5-0.5), 0.0))",
|
||||
"type": "tex3d"
|
||||
}
|
||||
],
|
||||
"parameters": [
|
||||
{
|
||||
"control": "None",
|
||||
"default": 0.5,
|
||||
"label": "Distort",
|
||||
"max": 1,
|
||||
"min": 0,
|
||||
"name": "Distort",
|
||||
"step": 0.01,
|
||||
"type": "float"
|
||||
}
|
||||
]
|
||||
},
|
||||
"type": "shader"
|
||||
}
|
103
addons/material_maker/nodes/tex3d_fbm.mmg
Normal file
103
addons/material_maker/nodes/tex3d_fbm.mmg
Normal file
@ -0,0 +1,103 @@
|
||||
{
|
||||
"name": "tex3d_fbm",
|
||||
"node_position": {
|
||||
"x": 0,
|
||||
"y": 0
|
||||
},
|
||||
"parameters": {
|
||||
"iterations": 1,
|
||||
"noise": 0,
|
||||
"persistence": 0.5,
|
||||
"scale_x": 4,
|
||||
"scale_y": 4,
|
||||
"scale_z": 4
|
||||
},
|
||||
"shader_model": {
|
||||
"code": "",
|
||||
"global": "float rand31(vec3 p) {\n\treturn fract(sin(dot(p,vec3(127.1,311.7, 74.7)))*43758.5453123);\n}\nvec3 rand33(vec3 p){\n\tp = vec3( dot(p,vec3(127.1,311.7, 74.7)),\n\t\t\t dot(p,vec3(269.5,183.3,246.1)),\n\t\t\t dot(p,vec3(113.5,271.9,124.6)));\n\n\treturn -1.0 + 2.0*fract(sin(p)*43758.5453123);\n}\n\nfloat tex3d_fbm_value(vec3 coord, vec3 size, float seed) {\n\tvec3 o = floor(coord);\n\tvec3 f = fract(coord);\n\tfloat p000 = rand31(mod(o, size));\n\tfloat p001 = rand31(mod(o + vec3(0.0, 0.0, 1.0), size));\n\tfloat p010 = rand31(mod(o + vec3(0.0, 1.0, 0.0), size));\n\tfloat p011 = rand31(mod(o + vec3(0.0, 1.0, 1.0), size));\n\tfloat p100 = rand31(mod(o + vec3(1.0, 0.0, 0.0), size));\n\tfloat p101 = rand31(mod(o + vec3(1.0, 0.0, 1.0), size));\n\tfloat p110 = rand31(mod(o + vec3(1.0, 1.0, 0.0), size));\n\tfloat p111 = rand31(mod(o + vec3(1.0, 1.0, 1.0), size));\n\tvec3 t = f * f * (3.0 - 2.0 * f);\n\treturn mix(mix(mix(p000, p100, t.x), mix(p010, p110, t.x), t.y), mix(mix(p001, p101, t.x), mix(p011, p111, t.x), t.y), t.z);\n}\n\nfloat tex3d_fbm_perlin(vec3 coord, vec3 size, float seed) {\n\tvec3 o = floor(coord)+rand3(vec2(float(seed), 1.0-float(seed)))+size;\n\tvec3 f = fract(coord);\n\tvec3 v000 = normalize(rand33(mod(o, size))-vec3(0.5));\n\tvec3 v001 = normalize(rand33(mod(o + vec3(0.0, 0.0, 1.0), size))-vec3(0.5));\n\tvec3 v010 = normalize(rand33(mod(o + vec3(0.0, 1.0, 0.0), size))-vec3(0.5));\n\tvec3 v011 = normalize(rand33(mod(o + vec3(0.0, 1.0, 1.0), size))-vec3(0.5));\n\tvec3 v100 = normalize(rand33(mod(o + vec3(1.0, 0.0, 0.0), size))-vec3(0.5));\n\tvec3 v101 = normalize(rand33(mod(o + vec3(1.0, 0.0, 1.0), size))-vec3(0.5));\n\tvec3 v110 = normalize(rand33(mod(o + vec3(1.0, 1.0, 0.0), size))-vec3(0.5));\n\tvec3 v111 = normalize(rand33(mod(o + vec3(1.0, 1.0, 1.0), size))-vec3(0.5));\n\tfloat p000 = dot(v000, f);\n\tfloat p001 = dot(v001, f - vec3(0.0, 0.0, 1.0));\n\tfloat p010 = dot(v010, f - vec3(0.0, 1.0, 0.0));\n\tfloat p011 = dot(v011, f - vec3(0.0, 1.0, 1.0));\n\tfloat p100 = dot(v100, f - vec3(1.0, 0.0, 0.0));\n\tfloat p101 = dot(v101, f - vec3(1.0, 0.0, 1.0));\n\tfloat p110 = dot(v110, f - vec3(1.0, 1.0, 0.0));\n\tfloat p111 = dot(v111, f - vec3(1.0, 1.0, 1.0));\n\tvec3 t = f * f * (3.0 - 2.0 * f);\n\treturn 0.5 + mix(mix(mix(p000, p100, t.x), mix(p010, p110, t.x), t.y), mix(mix(p001, p101, t.x), mix(p011, p111, t.x), t.y), t.z);\n}\n\nfloat tex3d_fbm_cellular(vec3 coord, vec3 size, float seed) {\n\tvec3 o = floor(coord)+rand3(vec2(float(seed), 1.0-float(seed)))+size;\n\tvec3 f = fract(coord);\n\tfloat min_dist = 3.0;\n\tfor (float x = -1.0; x <= 1.0; x++) {\n\t\tfor (float y = -1.0; y <= 1.0; y++) {\n\t\t\tfor (float z = -1.0; z <= 1.0; z++) {\n\t\t\t\tvec3 node = 0.4*rand33(mod(o + vec3(x, y, z), size)) + vec3(x, y, z);\n\t\t\t\tfloat dist = sqrt((f - node).x * (f - node).x + (f - node).y * (f - node).y + (f - node).z * (f - node).z);\n\t\t\t\tmin_dist = min(min_dist, dist);\n\t\t\t}\n\t\t}\n\t}\n\treturn min_dist;\n}\n",
|
||||
"inputs": [
|
||||
|
||||
],
|
||||
"instance": "float $(name)_fbm(vec3 coord, vec3 size, int octaves, float persistence, float seed) {\n\tfloat normalize_factor = 0.0;\n\tfloat value = 0.0;\n\tfloat scale = 1.0;\n\tfor (int i = 0; i < octaves; i++) {\n\t\tvalue += tex3d_fbm_$noise(coord*size, size, seed) * scale;\n\t\tnormalize_factor += scale;\n\t\tsize *= 2.0;\n\t\tscale *= persistence;\n\t}\n\treturn value / normalize_factor;\n}\n",
|
||||
"name": "TEX3D FBM",
|
||||
"outputs": [
|
||||
{
|
||||
"tex3d": "vec3($(name)_fbm($(uv).xyz, vec3($(scale_x), $(scale_y), $(scale_z)), int($(iterations)), $(persistence), $(seed)))",
|
||||
"type": "tex3d"
|
||||
}
|
||||
],
|
||||
"parameters": [
|
||||
{
|
||||
"default": 2,
|
||||
"label": "Noise",
|
||||
"name": "noise",
|
||||
"type": "enum",
|
||||
"values": [
|
||||
{
|
||||
"name": "Value",
|
||||
"value": "value"
|
||||
},
|
||||
{
|
||||
"name": "Perlin",
|
||||
"value": "perlin"
|
||||
},
|
||||
{
|
||||
"name": "Cellular",
|
||||
"value": "cellular"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"control": "None",
|
||||
"default": 4,
|
||||
"label": "Scale X",
|
||||
"max": 32,
|
||||
"min": 1,
|
||||
"name": "scale_x",
|
||||
"step": 1,
|
||||
"type": "float"
|
||||
},
|
||||
{
|
||||
"control": "None",
|
||||
"default": 4,
|
||||
"label": "Scale Y",
|
||||
"max": 32,
|
||||
"min": 1,
|
||||
"name": "scale_y",
|
||||
"step": 1,
|
||||
"type": "float"
|
||||
},
|
||||
{
|
||||
"control": "None",
|
||||
"default": 4,
|
||||
"label": "Scale Z",
|
||||
"max": 32,
|
||||
"min": 1,
|
||||
"name": "scale_z",
|
||||
"step": 1,
|
||||
"type": "float"
|
||||
},
|
||||
{
|
||||
"control": "None",
|
||||
"default": 3,
|
||||
"label": "Iterations",
|
||||
"max": 10,
|
||||
"min": 1,
|
||||
"name": "iterations",
|
||||
"step": 1,
|
||||
"type": "float"
|
||||
},
|
||||
{
|
||||
"control": "None",
|
||||
"default": 0.5,
|
||||
"label": "Persistance",
|
||||
"max": 1,
|
||||
"min": 0,
|
||||
"name": "persistence",
|
||||
"step": 0.05,
|
||||
"type": "float"
|
||||
}
|
||||
]
|
||||
},
|
||||
"type": "shader"
|
||||
}
|
192
addons/material_maker/nodes/tex3d_pattern.mmg
Normal file
192
addons/material_maker/nodes/tex3d_pattern.mmg
Normal file
@ -0,0 +1,192 @@
|
||||
{
|
||||
"name": "tex3d_pattern",
|
||||
"node_position": {
|
||||
"x": 0,
|
||||
"y": 0
|
||||
},
|
||||
"parameters": {
|
||||
"mix": 4,
|
||||
"x_scale": 2,
|
||||
"x_wave": 2,
|
||||
"y_scale": 2,
|
||||
"y_wave": 2,
|
||||
"z_scale": 2,
|
||||
"z_wave": 2
|
||||
},
|
||||
"shader_model": {
|
||||
"code": "",
|
||||
"global": "float wave3d_constant(float x) {\n\treturn 1.0;\n}\n\nfloat wave3d_sine(float x) {\n\treturn 0.5-0.5*cos(3.14159265359*2.0*x);\n}\n\nfloat wave3d_triangle(float x) {\n\tx = fract(x);\n\treturn min(2.0*x, 2.0-2.0*x);\n}\n\nfloat wave3d_sawtooth(float x) {\n\treturn fract(x);\n}\n\nfloat wave3d_square(float x) {\n\treturn (fract(x) < 0.5) ? 0.0 : 1.0;\n}\n\nfloat wave3d_bounce(float x) {\n\tx = 2.0*(fract(x)-0.5);\n\treturn sqrt(1.0-x*x);\n}\n\nfloat mix3d_mul(float x, float y, float z) {\n\treturn x*y*z;\n}\n\nfloat mix3d_add(float x, float y, float z) {\n\treturn min(x+y+z, 1.0);\n}\n\nfloat mix3d_max(float x, float y, float z) {\n\treturn max(max(x, y), z);\n}\n\nfloat mix_min(float x, float y, float z) {\n\treturn min(min(x, y), z);\n}\n\nfloat mix3d_xor(float x, float y, float z) {\n\tfloat xy = min(x+y, 2.0-x-y);\n\treturn min(xy+z, 2.0-xy-z);\n}\n\nfloat mix3d_pow(float x, float y, float z) {\n\treturn pow(pow(x, y), z);\n}",
|
||||
"inputs": [
|
||||
|
||||
],
|
||||
"instance": "float $(name)_fct(vec3 uv) {\n\treturn mix3d_$(mix)(wave3d_$(x_wave)($(x_scale)*uv.x), wave3d_$(y_wave)($(y_scale)*uv.y), wave3d_$(z_wave)($(z_scale)*uv.z));\n}",
|
||||
"name": "TEX3D Pattern",
|
||||
"outputs": [
|
||||
{
|
||||
"tex3d": "vec3($(name)_fct($(uv).xyz))",
|
||||
"type": "tex3d"
|
||||
}
|
||||
],
|
||||
"parameters": [
|
||||
{
|
||||
"default": 0,
|
||||
"label": "Combiner",
|
||||
"name": "mix",
|
||||
"type": "enum",
|
||||
"values": [
|
||||
{
|
||||
"name": "Multiply",
|
||||
"value": "mul"
|
||||
},
|
||||
{
|
||||
"name": "Add",
|
||||
"value": "add"
|
||||
},
|
||||
{
|
||||
"name": "Max",
|
||||
"value": "max"
|
||||
},
|
||||
{
|
||||
"name": "Min",
|
||||
"value": "min"
|
||||
},
|
||||
{
|
||||
"name": "Xor",
|
||||
"value": "xor"
|
||||
},
|
||||
{
|
||||
"name": "Pow",
|
||||
"value": "pow"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"default": 0,
|
||||
"label": "X",
|
||||
"name": "x_wave",
|
||||
"type": "enum",
|
||||
"values": [
|
||||
{
|
||||
"name": "Sine",
|
||||
"value": "sine"
|
||||
},
|
||||
{
|
||||
"name": "Triangle",
|
||||
"value": "triangle"
|
||||
},
|
||||
{
|
||||
"name": "Square",
|
||||
"value": "square"
|
||||
},
|
||||
{
|
||||
"name": "Sawtooth",
|
||||
"value": "sawtooth"
|
||||
},
|
||||
{
|
||||
"name": "Constant",
|
||||
"value": "constant"
|
||||
},
|
||||
{
|
||||
"name": "Bounce",
|
||||
"value": "bounce"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"control": "None",
|
||||
"default": 4,
|
||||
"label": "2:",
|
||||
"max": 32,
|
||||
"min": 0,
|
||||
"name": "x_scale",
|
||||
"step": 1,
|
||||
"type": "float"
|
||||
},
|
||||
{
|
||||
"default": 0,
|
||||
"label": "Y",
|
||||
"name": "y_wave",
|
||||
"type": "enum",
|
||||
"values": [
|
||||
{
|
||||
"name": "Sine",
|
||||
"value": "sine"
|
||||
},
|
||||
{
|
||||
"name": "Triangle",
|
||||
"value": "triangle"
|
||||
},
|
||||
{
|
||||
"name": "Square",
|
||||
"value": "square"
|
||||
},
|
||||
{
|
||||
"name": "Sawtooth",
|
||||
"value": "sawtooth"
|
||||
},
|
||||
{
|
||||
"name": "Constant",
|
||||
"value": "constant"
|
||||
},
|
||||
{
|
||||
"name": "Bounce",
|
||||
"value": "bounce"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"control": "None",
|
||||
"default": 4,
|
||||
"label": "3:",
|
||||
"max": 32,
|
||||
"min": 0,
|
||||
"name": "y_scale",
|
||||
"step": 1,
|
||||
"type": "float"
|
||||
},
|
||||
{
|
||||
"default": 0,
|
||||
"label": "Z",
|
||||
"name": "z_wave",
|
||||
"type": "enum",
|
||||
"values": [
|
||||
{
|
||||
"name": "Sine",
|
||||
"value": "sine"
|
||||
},
|
||||
{
|
||||
"name": "Triangle",
|
||||
"value": "triangle"
|
||||
},
|
||||
{
|
||||
"name": "Square",
|
||||
"value": "square"
|
||||
},
|
||||
{
|
||||
"name": "Sawtooth",
|
||||
"value": "sawtooth"
|
||||
},
|
||||
{
|
||||
"name": "Constant",
|
||||
"value": "constant"
|
||||
},
|
||||
{
|
||||
"name": "Bounce",
|
||||
"value": "bounce"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"control": "None",
|
||||
"default": 4,
|
||||
"label": "4:",
|
||||
"max": 32,
|
||||
"min": 0,
|
||||
"name": "z_scale",
|
||||
"step": 1,
|
||||
"type": "float"
|
||||
}
|
||||
]
|
||||
},
|
||||
"type": "shader"
|
||||
}
|
69
addons/material_maker/nodes/tex3d_rotate.mmg
Normal file
69
addons/material_maker/nodes/tex3d_rotate.mmg
Normal file
@ -0,0 +1,69 @@
|
||||
{
|
||||
"name": "tex3d_rotate",
|
||||
"node_position": {
|
||||
"x": 0,
|
||||
"y": 0
|
||||
},
|
||||
"parameters": {
|
||||
"a": 0,
|
||||
"ax": 0,
|
||||
"ay": 0,
|
||||
"az": 0,
|
||||
"x": 0.35,
|
||||
"y": 0,
|
||||
"z": 0
|
||||
},
|
||||
"shader_model": {
|
||||
"code": "",
|
||||
"global": "vec3 tex3d_rotate(vec3 p, vec3 a) {\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": "vec3(1.0)",
|
||||
"label": "",
|
||||
"name": "in",
|
||||
"type": "tex3d"
|
||||
}
|
||||
],
|
||||
"instance": "",
|
||||
"name": "TEX3D Rotate",
|
||||
"outputs": [
|
||||
{
|
||||
"tex3d": "$in(vec4(tex3d_rotate($uv.xyz, -vec3($ax, $ay, $az)*0.01745329251), $uv.w))",
|
||||
"type": "tex3d"
|
||||
}
|
||||
],
|
||||
"parameters": [
|
||||
{
|
||||
"control": "None",
|
||||
"default": 0,
|
||||
"label": "X",
|
||||
"max": 180,
|
||||
"min": -180,
|
||||
"name": "ax",
|
||||
"step": 1,
|
||||
"type": "float"
|
||||
},
|
||||
{
|
||||
"control": "None",
|
||||
"default": 0,
|
||||
"label": "Y",
|
||||
"max": 180,
|
||||
"min": -180,
|
||||
"name": "ay",
|
||||
"step": 1,
|
||||
"type": "float"
|
||||
},
|
||||
{
|
||||
"control": "None",
|
||||
"default": 0,
|
||||
"label": "Z",
|
||||
"max": 180,
|
||||
"min": -180,
|
||||
"name": "az",
|
||||
"step": 1,
|
||||
"type": "float"
|
||||
}
|
||||
]
|
||||
},
|
||||
"type": "shader"
|
||||
}
|
60
addons/material_maker/nodes/tex3d_select.mmg
Normal file
60
addons/material_maker/nodes/tex3d_select.mmg
Normal file
@ -0,0 +1,60 @@
|
||||
{
|
||||
"name": "tex3d_select",
|
||||
"node_position": {
|
||||
"x": 0,
|
||||
"y": 0
|
||||
},
|
||||
"parameters": {
|
||||
"t": 0.01,
|
||||
"v": 0.5
|
||||
},
|
||||
"shader_model": {
|
||||
"code": "float $(name_uv)_d = ($uv.w-$v)/$t;",
|
||||
"global": "",
|
||||
"inputs": [
|
||||
{
|
||||
"default": "vec3(0.5)",
|
||||
"label": "",
|
||||
"name": "in1",
|
||||
"type": "tex3d"
|
||||
},
|
||||
{
|
||||
"default": "vec3(0.5)",
|
||||
"label": "",
|
||||
"name": "in2",
|
||||
"type": "tex3d"
|
||||
}
|
||||
],
|
||||
"instance": "",
|
||||
"name": "TEX3D Select",
|
||||
"outputs": [
|
||||
{
|
||||
"tex3d": "mix($in1($uv), $in2($uv), clamp(1.0-$(name_uv)_d*$(name_uv)_d, 0.0, 1.0))",
|
||||
"type": "tex3d"
|
||||
}
|
||||
],
|
||||
"parameters": [
|
||||
{
|
||||
"control": "None",
|
||||
"default": 0.5,
|
||||
"label": "Value",
|
||||
"max": 1,
|
||||
"min": 0,
|
||||
"name": "v",
|
||||
"step": 0.01,
|
||||
"type": "float"
|
||||
},
|
||||
{
|
||||
"control": "None",
|
||||
"default": 0.1,
|
||||
"label": "Tolerance",
|
||||
"max": 1,
|
||||
"min": 0.01,
|
||||
"name": "t",
|
||||
"step": 0.001,
|
||||
"type": "float"
|
||||
}
|
||||
]
|
||||
},
|
||||
"type": "shader"
|
||||
}
|
Loading…
Reference in New Issue
Block a user