mirror of
https://github.com/Relintai/material-maker.git
synced 2024-11-13 06:27:18 +01:00
Removed old generator model file format
This commit is contained in:
parent
34349c98ca
commit
bd8becaf75
@ -26,7 +26,6 @@ func get_input_defs():
|
|||||||
func _get_shader_code(uv : String, output_index : int, context : MMGenContext):
|
func _get_shader_code(uv : String, output_index : int, context : MMGenContext):
|
||||||
var source = get_source(0)
|
var source = get_source(0)
|
||||||
if source != null:
|
if source != null:
|
||||||
print(parameters.size)
|
|
||||||
var status = source.generator.render(source.output_index, context.renderer, pow(2, 4+parameters.size))
|
var status = source.generator.render(source.output_index, context.renderer, pow(2, 4+parameters.size))
|
||||||
while status is GDScriptFunctionState:
|
while status is GDScriptFunctionState:
|
||||||
status = yield(status, "completed")
|
status = yield(status, "completed")
|
||||||
|
1
addons/material_maker/nodes/adjust_hsv.mmg
Normal file
1
addons/material_maker/nodes/adjust_hsv.mmg
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"name":"uniform","node_position":{"x":0,"y":0},"parameters":{"hue":0,"saturation":1,"value":1},"shader_model":{"global":"vec3 rgb_to_hsv(vec3 c) {\n\tvec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);\n\tvec4 p = c.g < c.b ? vec4(c.bg, K.wz) : vec4(c.gb, K.xy);\n\tvec4 q = c.r < p.x ? vec4(p.xyw, c.r) : vec4(c.r, p.yzx);\n\n\tfloat d = q.x - min(q.w, q.y);\n\tfloat e = 1.0e-10;\n\treturn vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);\n}\n\nvec3 hsv_to_rgb(vec3 c) {\n\tvec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);\n\tvec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);\n\treturn c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);\n}\n","inputs":[{"default":"vec4($uv.x, $uv.y, 0.0, 1.0)","label":"","name":"in","type":"rgba"}],"instance":"vec4 $(name)_f(vec4 c) {\n\tvec3 hsv = rgb_to_hsv(c.rgb);\n\treturn vec4(hsv_to_rgb(vec3(fract(hsv.x+$(hue)), clamp(hsv.y*$(saturation), 0.0, 1.0), clamp(hsv.z*$(value), 0.0, 1.0))), c.a);\n}","name":"AdjustHSV","outputs":[{"rgba":"$(name)_f($in($(uv)))"}],"parameters":[{"default":0,"label":"Hue","max":0.5,"min":-0.5,"name":"hue","step":0,"type":"float"},{"default":1,"label":"Saturation","max":2,"min":0,"name":"saturation","step":0,"type":"float"},{"default":1,"label":"Value","max":2,"min":0,"name":"value","step":0,"type":"float"}]}}
|
@ -1 +0,0 @@
|
|||||||
{"global":"vec3 rgb_to_hsv(vec3 c) {\n\tvec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);\n\tvec4 p = c.g < c.b ? vec4(c.bg, K.wz) : vec4(c.gb, K.xy);\n\tvec4 q = c.r < p.x ? vec4(p.xyw, c.r) : vec4(c.r, p.yzx);\n\n\tfloat d = q.x - min(q.w, q.y);\n\tfloat e = 1.0e-10;\n\treturn vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);\n}\n\nvec3 hsv_to_rgb(vec3 c) {\n\tvec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);\n\tvec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);\n\treturn c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);\n}\n","inputs":[{"default":"vec4($uv.x, $uv.y, 0.0, 1.0)","label":"","name":"in","type":"rgba"}],"instance":"vec4 $(name)_f(vec4 c) {\n\tvec3 hsv = rgb_to_hsv(c.rgb);\n\treturn vec4(hsv_to_rgb(vec3(fract(hsv.x+$(hue)), clamp(hsv.y*$(saturation), 0.0, 1.0), clamp(hsv.z*$(value), 0.0, 1.0))), c.a);\n}","name":"AdjustHSV","outputs":[{"rgba":"$(name)_f($in($(uv)))"}],"parameters":[{"default":0,"label":"Hue","max":0.5,"min":-0.5,"name":"hue","step":0,"type":"float"},{"default":1,"label":"Saturation","max":2,"min":0,"name":"saturation","step":0,"type":"float"},{"default":1,"label":"Value","max":2,"min":0,"name":"value","step":0,"type":"float"}]}
|
|
1
addons/material_maker/nodes/bricks.mmg
Normal file
1
addons/material_maker/nodes/bricks.mmg
Normal file
File diff suppressed because one or more lines are too long
@ -1,122 +0,0 @@
|
|||||||
{
|
|
||||||
"name":"Bricks",
|
|
||||||
"parameters":[
|
|
||||||
{ "name":"pattern", "label":"", "type":"enum", "default":0, "values":[
|
|
||||||
{ "name":"Running bond", "value":"rb" },
|
|
||||||
{ "name":"Running bond (2)", "value":"rb2" },
|
|
||||||
{ "name":"HerringBone", "value":"hb" },
|
|
||||||
{ "name":"Basket weave", "value":"bw" },
|
|
||||||
{ "name":"Spanish bond", "value":"sb" }
|
|
||||||
] },
|
|
||||||
{ "name":"repeat", "label":"Repeat:", "type":"float", "min":1, "max":8, "step":1, "default":1, "widget":"spinbox" },
|
|
||||||
{ "name":"rows", "label":"Rows:", "type":"float", "min":1, "max":64, "step":1, "default":6, "widget":"spinbox" },
|
|
||||||
{ "name":"columns", "label":"Columns:", "type":"float", "min":1, "max":64, "step":1, "default":3, "widget":"spinbox" },
|
|
||||||
{ "name":"row_offset", "label":"Offset:", "type":"float", "min":0, "max":1, "default":0.5 },
|
|
||||||
{ "name":"mortar", "label":"Mortar:", "type":"float", "min":0, "max":0.5, "default":0.1 },
|
|
||||||
{ "name":"bevel", "label":"Bevel:", "type":"float", "min":0, "max":0.5, "default":0.1 }
|
|
||||||
],
|
|
||||||
"include":[ "noise" ],
|
|
||||||
"global":"
|
|
||||||
vec3 brick(vec2 uv, vec2 bmin, vec2 bmax, float mortar, float bevel) {
|
|
||||||
float color = 0.5;
|
|
||||||
vec2 c1 = (uv-bmin-vec2(mortar))/bevel;
|
|
||||||
vec2 c2 = (bmax-uv-vec2(mortar))/bevel;
|
|
||||||
vec2 c = min(c1, c2);
|
|
||||||
color = clamp(min(c.x, c.y), 0.0, 1.0);
|
|
||||||
return vec3(color, mod(bmin, vec2(1.0, 1.0)));
|
|
||||||
}
|
|
||||||
|
|
||||||
vec3 bricks_rb(vec2 uv, vec2 count, float repeat, float offset, float mortar, float bevel) {
|
|
||||||
count *= repeat;
|
|
||||||
mortar /= max(count.x, count.y);
|
|
||||||
bevel /= max(count.x, count.y);
|
|
||||||
float x_offset = offset*step(0.5, fract(uv.y*count.y*0.5));
|
|
||||||
vec2 bmin = floor(vec2(uv.x*count.x-x_offset, uv.y*count.y));
|
|
||||||
bmin.x += x_offset;
|
|
||||||
bmin /= count;
|
|
||||||
return brick(uv, bmin, bmin+vec2(1.0)/count, mortar, bevel);
|
|
||||||
}
|
|
||||||
|
|
||||||
vec3 bricks_rb2(vec2 uv, vec2 count, float repeat, float offset, float mortar, float bevel) {
|
|
||||||
count *= repeat;
|
|
||||||
mortar /= max(2.0*count.x, count.y);
|
|
||||||
bevel /= max(2.0*count.x, count.y);
|
|
||||||
float x_offset = offset*step(0.5, fract(uv.y*count.y*0.5));
|
|
||||||
count.x = count.x*(1.0+step(0.5, fract(uv.y*count.y*0.5)));
|
|
||||||
vec2 bmin = floor(vec2(uv.x*count.x-x_offset, uv.y*count.y));
|
|
||||||
bmin.x += x_offset;
|
|
||||||
bmin /= count;
|
|
||||||
return brick(uv, bmin, bmin+vec2(1.0)/count, mortar, bevel);
|
|
||||||
}
|
|
||||||
|
|
||||||
vec3 bricks_hb(vec2 uv, vec2 count, float repeat, float offset, float mortar, float bevel) {
|
|
||||||
float pc = count.x+count.y;
|
|
||||||
float c = pc*repeat;
|
|
||||||
mortar /= c;
|
|
||||||
bevel /= c;
|
|
||||||
vec2 corner = floor(uv*c);
|
|
||||||
float cdiff = mod(corner.x-corner.y, pc);
|
|
||||||
if (cdiff < count.x) {
|
|
||||||
return brick(uv, (corner-vec2(cdiff, 0.0))/c, (corner-vec2(cdiff, 0.0)+vec2(count.x, 1.0))/c, mortar, bevel);
|
|
||||||
} else {
|
|
||||||
return 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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
vec3 bricks_bw(vec2 uv, vec2 count, float repeat, float offset, float mortar, float bevel) {
|
|
||||||
vec2 c = 2.0*count*repeat;
|
|
||||||
float mc = max(c.x, c.y);
|
|
||||||
mortar /= mc;
|
|
||||||
bevel /= mc;
|
|
||||||
vec2 corner1 = floor(uv*c);
|
|
||||||
vec2 corner2 = count*floor(repeat*2.0*uv);
|
|
||||||
float cdiff = mod(dot(floor(repeat*2.0*uv), vec2(1.0)), 2.0);
|
|
||||||
vec2 corner;
|
|
||||||
vec2 size;
|
|
||||||
if (cdiff == 0.0) {
|
|
||||||
corner = vec2(corner1.x, corner2.y);
|
|
||||||
size = vec2(1.0, count.y);
|
|
||||||
} else {
|
|
||||||
corner = vec2(corner2.x, corner1.y);
|
|
||||||
size = vec2(count.x, 1.0);
|
|
||||||
}
|
|
||||||
return brick(uv, corner/c, (corner+size)/c, mortar, bevel);
|
|
||||||
}
|
|
||||||
|
|
||||||
vec3 bricks_sb(vec2 uv, vec2 count, float repeat, float offset, float mortar, float bevel) {
|
|
||||||
vec2 c = (count+vec2(1.0))*repeat;
|
|
||||||
float mc = max(c.x, c.y);
|
|
||||||
mortar /= mc;
|
|
||||||
bevel /= mc;
|
|
||||||
vec2 corner1 = floor(uv*c);
|
|
||||||
vec2 corner2 = (count+vec2(1.0))*floor(repeat*uv);
|
|
||||||
vec2 rcorner = corner1 - corner2;
|
|
||||||
vec2 corner;
|
|
||||||
vec2 size;
|
|
||||||
if (rcorner.x == 0.0 && rcorner.y < count.y) {
|
|
||||||
corner = corner2;
|
|
||||||
size = vec2(1.0, count.y);
|
|
||||||
} else if (rcorner.y == 0.0) {
|
|
||||||
corner = corner2+vec2(1.0, 0.0);
|
|
||||||
size = vec2(count.x, 1.0);
|
|
||||||
} else if (rcorner.x == count.x) {
|
|
||||||
corner = corner2+vec2(count.x, 1.0);
|
|
||||||
size = vec2(1.0, count.y);
|
|
||||||
} else if (rcorner.y == count.y) {
|
|
||||||
corner = corner2+vec2(0.0, count.y);
|
|
||||||
size = vec2(count.x, 1.0);
|
|
||||||
} else {
|
|
||||||
corner = corner2+vec2(1.0);
|
|
||||||
size = vec2(count.x-1.0, count.y-1.0);
|
|
||||||
}
|
|
||||||
return brick(uv, corner/c, (corner+size)/c, mortar, bevel);
|
|
||||||
}",
|
|
||||||
"instance":"
|
|
||||||
vec3 $(name)_xyz(vec2 uv) {
|
|
||||||
return bricks_$(pattern)(uv, vec2($(columns), $(rows)), $(repeat), $(row_offset), $(mortar), max(0.001, $(bevel)));
|
|
||||||
}",
|
|
||||||
"outputs":[
|
|
||||||
{ "f":"$(name)_xyz($(uv)).x" },
|
|
||||||
{ "rgb":"rand3($(name)_xyz($(uv)).yz+vec2($(seed)))" }
|
|
||||||
]
|
|
||||||
}
|
|
1
addons/material_maker/nodes/colorize.mmg
Normal file
1
addons/material_maker/nodes/colorize.mmg
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"name":"uniform","node_position":{"x":0,"y":0},"parameters":{"gradient":{"points":[{"a":1,"b":0,"g":0,"pos":0,"r":0},{"a":1,"b":1,"g":1,"pos":1,"r":1}],"type":"Gradient"}},"shader_model":{"global":"","inputs":[{"default":"$uv.x","label":"Input","name":"input","type":"f"}],"instance":"","name":"Colorize","outputs":[{"rgba":"$gradient($input($uv))"}],"parameters":[{"default":{"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":"gradient","type":"gradient"}]}}
|
@ -1 +0,0 @@
|
|||||||
{"global":"","inputs":[{"default":"$uv.x","label":"Input","name":"input","type":"f"}],"instance":"","name":"Colorize","outputs":[{"rgba":"$gradient($input($uv))"}],"parameters":[{"default":{"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":"gradient","type":"gradient"}]}
|
|
@ -1,3 +1,4 @@
|
|||||||
|
tool
|
||||||
extends GraphNode
|
extends GraphNode
|
||||||
|
|
||||||
var generator = null setget set_generator
|
var generator = null setget set_generator
|
||||||
|
1
addons/material_maker/nodes/noise.mmg
Normal file
1
addons/material_maker/nodes/noise.mmg
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"name":"uniform","node_position":{"x":0,"y":0},"parameters":{"density":0.5,"size":8},"shader_model":{"global":"float dots(vec2 uv, float size, float density, 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\tfloat color = step(rand(seed2+point_pos), density);\n return color;\n}","instance":"\n\t\tfloat $(name)_f(vec2 uv) {\n\t\t\treturn dots(uv, 1.0/$(size), $(density), $(seed));\n\t\t}","name":"Noise","outputs":[{"f":"$(name)_f($(uv))"}],"parameters":[{"default":8,"first":2,"label":"Grid Size:","last":8,"name":"size","type":"size"},{"default":0.5,"label":"Density:","max":1,"min":0,"name":"density","step":0,"type":"float"}]}}
|
@ -1 +0,0 @@
|
|||||||
{"global":"float dots(vec2 uv, float size, float density, 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\tfloat color = step(rand(seed2+point_pos), density);\n return color;\n}","instance":"\n\t\tfloat $(name)_f(vec2 uv) {\n\t\t\treturn dots(uv, 1.0/$(size), $(density), $(seed));\n\t\t}","name":"Noise","outputs":[{"f":"$(name)_f($(uv))"}],"parameters":[{"default":8,"first":2,"label":"Grid Size:","last":8,"name":"size","type":"size"},{"default":0.5,"label":"Density:","max":1,"min":0,"name":"density","step":0,"type":"float"}]}
|
|
1
addons/material_maker/nodes/pattern.mmg
Normal file
1
addons/material_maker/nodes/pattern.mmg
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"name":"uniform","node_position":{"x":0,"y":0},"parameters":{"mix":0,"x_scale":4,"x_wave":0,"y_scale":4,"y_wave":0},"shader_model":{"global":"float wave_constant(float x) {\n\treturn 1.0;\n}\n\nfloat wave_sine(float x) {\n\treturn 0.5-0.5*cos(3.14159265359*2.0*x);\n}\n\nfloat wave_triangle(float x) {\n\tx = fract(x);\n\treturn min(2.0*x, 2.0-2.0*x);\n}\n\nfloat wave_sawtooth(float x) {\n\treturn fract(x);\n}\n\nfloat wave_square(float x) {\n\treturn (fract(x) < 0.5) ? 0.0 : 1.0;\n}\n\nfloat mix_mul(float x, float y) {\n\treturn x*y;\n}\n\nfloat mix_add(float x, float y) {\n\treturn min(x+y, 1.0);\n}\n\nfloat mix_max(float x, float y) {\n\treturn max(x, y);\n}\n\nfloat mix_min(float x, float y) {\n\treturn min(x, y);\n}\n\nfloat mix_xor(float x, float y) {\n\treturn min(x+y, 2.0-x-y);\n}\n\nfloat mix_pow(float x, float y) {\n\treturn pow(x, y);\n}","instance":"float $(name)_fct(vec2 uv) {\n\treturn mix_$(mix)(wave_$(x_wave)($(x_scale)*uv.x), wave_$(y_wave)($(y_scale)*uv.y));\n}","name":"Pattern","outputs":[{"f":"$(name)_fct($(uv))"}],"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"}]},{"default":4,"label":"nonewline","max":32,"min":0,"name":"x_scale","step":1,"type":"float","widget":"spinbox"},{"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"}]},{"default":4,"label":"nonewline","max":32,"min":0,"name":"y_scale","step":1,"type":"float","widget":"spinbox"}]}}
|
@ -1 +0,0 @@
|
|||||||
{"global":"float wave_constant(float x) {\n\treturn 1.0;\n}\n\nfloat wave_sine(float x) {\n\treturn 0.5-0.5*cos(3.14159265359*2.0*x);\n}\n\nfloat wave_triangle(float x) {\n\tx = fract(x);\n\treturn min(2.0*x, 2.0-2.0*x);\n}\n\nfloat wave_sawtooth(float x) {\n\treturn fract(x);\n}\n\nfloat wave_square(float x) {\n\treturn (fract(x) < 0.5) ? 0.0 : 1.0;\n}\n\nfloat mix_mul(float x, float y) {\n\treturn x*y;\n}\n\nfloat mix_add(float x, float y) {\n\treturn min(x+y, 1.0);\n}\n\nfloat mix_max(float x, float y) {\n\treturn max(x, y);\n}\n\nfloat mix_min(float x, float y) {\n\treturn min(x, y);\n}\n\nfloat mix_xor(float x, float y) {\n\treturn min(x+y, 2.0-x-y);\n}\n\nfloat mix_pow(float x, float y) {\n\treturn pow(x, y);\n}","instance":"float $(name)_fct(vec2 uv) {\n\treturn mix_$(mix)(wave_$(x_wave)($(x_scale)*uv.x), wave_$(y_wave)($(y_scale)*uv.y));\n}","name":"Pattern","outputs":[{"f":"$(name)_fct($(uv))"}],"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"}]},{"default":4,"label":"nonewline","max":32,"min":0,"name":"x_scale","step":1,"type":"float","widget":"spinbox"},{"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"}]},{"default":4,"label":"nonewline","max":32,"min":0,"name":"y_scale","step":1,"type":"float","widget":"spinbox"}]}
|
|
1
addons/material_maker/nodes/perlin.mmg
Normal file
1
addons/material_maker/nodes/perlin.mmg
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"name":"uniform","node_position":{"x":0,"y":0},"parameters":{"iterations":3,"persistence":0.5,"scale_x":4,"scale_y":4},"shader_model":{"global":"float perlin(vec2 uv, vec2 size, int iterations, float persistence, int seed) {\n\tvec2 seed2 = rand2(vec2(float(seed), 1.0-float(seed)));\n float rv = 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 float f0 = rand(seed2+mod(xy, size));\n float f1 = rand(seed2+mod(xy+vec2(1.0, 0.0), size));\n float f2 = rand(seed2+mod(xy+vec2(0.0, 1.0), size));\n float f3 = rand(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","instance":"","name":"Perlin","outputs":[{"f":"perlin($(uv), vec2($(scale_x), $(scale_y)), int($(iterations)), $(persistence), $(seed))"}],"parameters":[{"default":4,"label":"Scale X","max":32,"min":1,"name":"scale_x","step":1,"type":"float","widget":"spinbox"},{"default":4,"label":"Scale Y","max":32,"min":1,"name":"scale_y","step":1,"type":"float","widget":"spinbox"},{"default":3,"label":"Iterations","max":10,"min":1,"name":"iterations","step":1,"type":"float","widget":"spinbox"},{"default":0.5,"label":"Persistance","max":1,"min":0,"name":"persistence","step":0.05,"type":"float","widget":"spinbox"}]}}
|
@ -1 +0,0 @@
|
|||||||
{"global":"float perlin(vec2 uv, vec2 size, int iterations, float persistence, int seed) {\n\tvec2 seed2 = rand2(vec2(float(seed), 1.0-float(seed)));\n float rv = 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 float f0 = rand(seed2+mod(xy, size));\n float f1 = rand(seed2+mod(xy+vec2(1.0, 0.0), size));\n float f2 = rand(seed2+mod(xy+vec2(0.0, 1.0), size));\n float f3 = rand(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","instance":"","name":"Perlin","outputs":[{"f":"perlin($(uv), vec2($(scale_x), $(scale_y)), int($(iterations)), $(persistence), $(seed))"}],"parameters":[{"default":4,"label":"Scale X","max":32,"min":1,"name":"scale_x","step":1,"type":"float","widget":"spinbox"},{"default":4,"label":"Scale Y","max":32,"min":1,"name":"scale_y","step":1,"type":"float","widget":"spinbox"},{"default":3,"label":"Iterations","max":10,"min":1,"name":"iterations","step":1,"type":"float","widget":"spinbox"},{"default":0.5,"label":"Persistance","max":1,"min":0,"name":"persistence","step":0.05,"type":"float","widget":"spinbox"}]}
|
|
1
addons/material_maker/nodes/shape.mmg
Normal file
1
addons/material_maker/nodes/shape.mmg
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"name":"uniform","node_position":{"x":0,"y":0},"parameters":{"edge":0.2,"radius":1,"shape":0,"sides":3},"shader_model":{"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","instance":"","name":"Shape","outputs":[{"f":"shape_$(shape)($(uv), $(sides), $(radius), $(edge))"}],"parameters":[{"default":0,"label":"","name":"shape","type":"enum","values":[{"name":"Circle","value":"circle"},{"name":"Polygon","value":"polygon"},{"name":"Star","value":"star"},{"name":"Curved star","value":"curved_star"},{"name":"Rays","value":"rays"}]},{"default":3,"label":"","max":32,"min":2,"name":"sides","step":1,"type":"float"},{"default":1,"label":"","max":1,"min":0,"name":"radius","step":0,"type":"float"},{"default":0.2,"label":"","max":1,"min":0,"name":"edge","step":0,"type":"float"}]}}
|
@ -1 +0,0 @@
|
|||||||
{"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","instance":"","name":"Shape","outputs":[{"f":"shape_$(shape)($(uv), $(sides), $(radius), $(edge))"}],"parameters":[{"default":0,"label":"","name":"shape","type":"enum","values":[{"name":"Circle","value":"circle"},{"name":"Polygon","value":"polygon"},{"name":"Star","value":"star"},{"name":"Curved star","value":"curved_star"},{"name":"Rays","value":"rays"}]},{"default":3,"label":"","max":32,"min":2,"name":"sides","step":1,"type":"float"},{"default":1,"label":"","max":1,"min":0,"name":"radius","step":0,"type":"float"},{"default":0.2,"label":"","max":1,"min":0,"name":"edge","step":0,"type":"float"}]}
|
|
1
addons/material_maker/nodes/uniform.mmg
Normal file
1
addons/material_maker/nodes/uniform.mmg
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"name":"uniform","node_position":{"x":0,"y":0},"parameters":{"color":{"a":1,"b":1,"g":1,"r":1,"type":"Color"}},"shader_model":{"global":"","instance":"","name":"Uniform","outputs":[{"rgba":"$(color)"}],"parameters":[{"default":{"a":1,"b":1,"g":1,"r":1},"label":"","name":"color","type":"color"}]}}
|
@ -1 +0,0 @@
|
|||||||
{"global":"","instance":"","name":"Uniform","outputs":[{"rgba":"$(color)"}],"parameters":[{"default":{"a":1,"b":1,"g":1,"r":1},"label":"","name":"color","type":"color"}]}
|
|
1
addons/material_maker/nodes/voronoi.mmg
Normal file
1
addons/material_maker/nodes/voronoi.mmg
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"name":"uniform","node_position":{"x":0,"y":0},"parameters":{"intensity":0.5,"scale_x":4,"scale_y":4},"shader_model":{"global":"vec4 voronoi(vec2 uv, vec2 size, float intensity, 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 += 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","instance":"","name":"Voronoi","outputs":[{"f":"voronoi($(uv), vec2($(scale_x), $(scale_y)), $(intensity), $(seed)).z"},{"f":"voronoi($(uv), vec2($(scale_x), $(scale_y)), $(intensity), $(seed)).w"},{"rgb":"rand3(fract(voronoi($(uv), vec2($(scale_x), $(scale_y)), $(intensity), $(seed)).xy))"}],"parameters":[{"default":4,"label":"Scale X","max":32,"min":1,"name":"scale_x","step":1,"type":"float","widget":"spinbox"},{"default":4,"label":"Scale Y","max":32,"min":1,"name":"scale_y","step":1,"type":"float","widget":"spinbox"},{"default":0.5,"label":"Intensity","max":1,"min":0,"name":"intensity","step":0.05,"type":"float","widget":"spinbox"}]}}
|
@ -1 +0,0 @@
|
|||||||
{"global":"vec4 voronoi(vec2 uv, vec2 size, float intensity, 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 += 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","instance":"","name":"Voronoi","outputs":[{"f":"voronoi($(uv), vec2($(scale_x), $(scale_y)), $(intensity), $(seed)).z"},{"f":"voronoi($(uv), vec2($(scale_x), $(scale_y)), $(intensity), $(seed)).w"},{"rgb":"rand3(fract(voronoi($(uv), vec2($(scale_x), $(scale_y)), $(intensity), $(seed)).xy))"}],"parameters":[{"default":4,"label":"Scale X","max":32,"min":1,"name":"scale_x","step":1,"type":"float","widget":"spinbox"},{"default":4,"label":"Scale Y","max":32,"min":1,"name":"scale_y","step":1,"type":"float","widget":"spinbox"},{"default":0.5,"label":"Intensity","max":1,"min":0,"name":"intensity","step":0.05,"type":"float","widget":"spinbox"}]}
|
|
Loading…
Reference in New Issue
Block a user