mirror of
https://github.com/Relintai/material-maker.git
synced 2024-12-23 21:16:54 +01:00
0d85cd5aef
Custom nodes now support outputs and basic (float) parameters, and are serialized/deserialized correctly.
122 lines
4.5 KiB
Plaintext
122 lines
4.5 KiB
Plaintext
{
|
|
"name":"Bricks",
|
|
"parameters":[
|
|
{ "name":"pattern", "label":"", "type":"enum", "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)))" }
|
|
]
|
|
} |