mirror of
https://github.com/Relintai/broken_seals.git
synced 2024-11-13 20:47:19 +01:00
Notes from bricks.mmg. Also improvements to beehive notes.
This commit is contained in:
parent
b622bb2f73
commit
b31eb46120
@ -5,7 +5,20 @@ const Commons = preload("res://addons/mat_maker_gd/nodes/common/commons.gd")
|
||||
|
||||
#----------------------
|
||||
#beehive.mmg
|
||||
#Outputs: 3 beehive_1c, beehive_2c, beehive_3c
|
||||
#Outputs: (beehive_1c, beehive_2c, beehive_3c TODO make common code parameters)
|
||||
#Common
|
||||
#vec2 $(name_uv)_uv = $uv*vec2($sx, $sy*1.73205080757);
|
||||
#vec4 $(name_uv)_center = beehive_center($(name_uv)_uv);
|
||||
|
||||
#Output (float) - Shows the greyscale pattern
|
||||
#1.0-2.0*beehive_dist($(name_uv)_center.xy)
|
||||
|
||||
#Random color (rgb) - Shows a random color for each hexagonal tile
|
||||
#rand3(fract($(name_uv)_center.zw/vec2($sx, $sy))+vec2(float($seed)))
|
||||
|
||||
#UV map (rgb) - Shows an UV map to be connected to the UV map port of the Custom UV node
|
||||
#vec3(vec2(0.5)+$(name_uv)_center.xy, rand(fract($(name_uv)_center.zw/vec2($sx, $sy))+vec2(float($seed))))
|
||||
|
||||
#Inputs:
|
||||
#size, vector2, default: 2, min: 1, max: 64, step: 1
|
||||
|
||||
@ -18,6 +31,47 @@ const Commons = preload("res://addons/mat_maker_gd/nodes/common/commons.gd")
|
||||
#Pattern_y_type, enum, default: 5, values (CombinerAxisType): Sine, Triangle, Square, Sawtooth, Constant, Bounce
|
||||
#Pattern_Repeat, vector2, min: 0, max: 32, default:4, step: 1
|
||||
|
||||
#----------------------
|
||||
#bricks.mmg
|
||||
|
||||
#Outputs:
|
||||
|
||||
#Common
|
||||
#vec4 $(name_uv)_rect = bricks_$pattern($uv, vec2($columns, $rows), $repeat, $row_offset);
|
||||
#vec4 $(name_uv) = brick($uv, $(name_uv)_rect.xy, $(name_uv)_rect.zw, $mortar*$mortar_map($uv), $round*$round_map($uv), max(0.001, $bevel*$bevel_map($uv)));
|
||||
|
||||
#Bricks pattern (float) - A greyscale image that shows the bricks pattern
|
||||
#$(name_uv).x
|
||||
|
||||
#Random color (rgb) - A random color for each brick
|
||||
#brick_random_color($(name_uv)_rect.xy, $(name_uv)_rect.zw, float($seed))
|
||||
|
||||
#Position.x (float) - The position of each brick along the X axis",
|
||||
#$(name_uv).y
|
||||
|
||||
#Position.y (float) - The position of each brick along the Y axis
|
||||
#$(name_uv).z
|
||||
|
||||
#Brick UV (rgb) - An UV map output for each brick, to be connected to the Map input of a CustomUV node
|
||||
#brick_uv($uv, $(name_uv)_rect.xy, $(name_uv)_rect.zw, float($seed))
|
||||
|
||||
#Corner UV (rgb) - An UV map output for each brick corner, to be connected to the Map input of a CustomUV node
|
||||
#brick_corner_uv($uv, $(name_uv)_rect.xy, $(name_uv)_rect.zw, $mortar*$mortar_map($uv), $corner, float($seed))
|
||||
|
||||
#Direction (float) - The direction of each brick (white: horizontal, black: vertical)
|
||||
#0.5*(sign($(name_uv)_rect.z-$(name_uv)_rect.x-$(name_uv)_rect.w+$(name_uv)_rect.y)+1.0)
|
||||
|
||||
#Inputs:
|
||||
#type / Pattern, enum, default: 0, values: Running Bond,Running Bond (2),HerringBone,Basket Weave,Spanish Bond
|
||||
#repeat, int, min: 1, max: 8, default: 1, step:1
|
||||
#rows, int, min: 1, max: 64, default: 6, step:1
|
||||
#columns, int, min: 1, max: 64, default: 6, step:1
|
||||
#offset, float, min: 0, max: 1, default: 0.5, step:0.01
|
||||
#mortar, float, min: 0, max: 0.5, default: 0.1, step:0.01 (universal input)
|
||||
#bevel, float, min: 0, max: 0.5, default: 0.1, step:0.01 (universal input)
|
||||
#round, float, min: 0, max: 0.5, default: 0.1, step:0.01 (universal input)
|
||||
#corner, float, min: 0, max: 0.5, default: 0.1, step:0.01
|
||||
|
||||
enum CombinerAxisType {
|
||||
SINE,
|
||||
TRIANGLE,
|
||||
@ -27,7 +81,7 @@ enum CombinerAxisType {
|
||||
BOUNCE
|
||||
}
|
||||
|
||||
enum CombinerType {
|
||||
enum CombinerType {
|
||||
MULTIPLY,
|
||||
ADD,
|
||||
MAX,
|
||||
@ -36,7 +90,7 @@ enum CombinerType {
|
||||
POW
|
||||
}
|
||||
|
||||
#float $(name)_fct(vec2 uv) {\n\t
|
||||
#float $(name)_fct(vec2 uv) {
|
||||
# return mix_$(mix)(wave_$(x_wave)($(x_scale)*uv.x), wave_$(y_wave)($(y_scale)*uv.y));
|
||||
#}
|
||||
|
||||
@ -314,6 +368,18 @@ static func beehive_center(p : Vector2) -> Color:
|
||||
|
||||
#return dot(h.xy, h.xy) < dot(h.zw, h.zw) ? Color(h.xy, hC.xy) : Color(h.zw, hC.zw + 9.73);
|
||||
|
||||
#vec3 brick_corner_uv(vec2 uv, vec2 bmin, vec2 bmax, float mortar, float corner, float seed) {
|
||||
# vec2 center = 0.5*(bmin + bmax);
|
||||
# vec2 size = bmax - bmin;
|
||||
#
|
||||
# float max_size = max(size.x, size.y);
|
||||
# float min_size = min(size.x, size.y);
|
||||
#
|
||||
# mortar *= min_size;
|
||||
# corner *= min_size;
|
||||
#
|
||||
# return vec3(clamp((0.5*size-vec2(mortar)-abs(uv-center))/corner, vec2(0.0), vec2(1.0)), rand(fract(center)+vec2(seed)+ceil(vec2(uv-center))));
|
||||
#}
|
||||
|
||||
static func brick_corner_uv(uv : Vector2, bmin : Vector2, bmax : Vector2, mortar : float, corner : float, pseed : float) -> Vector3:
|
||||
var center : Vector2 = 0.5 * (bmin + bmax)
|
||||
@ -333,6 +399,23 @@ static func brick_corner_uv(uv : Vector2, bmin : Vector2, bmax : Vector2, mortar
|
||||
|
||||
# return vec3(clamp((0.5*size-vec2(mortar)-abs(uv-center))/corner, vec2(0.0), vec2(1.0)), rand(fract(center)+vec2(seed)));
|
||||
|
||||
#vec4 brick(vec2 uv, vec2 bmin, vec2 bmax, float mortar, float round, float bevel) {
|
||||
# float color;
|
||||
# vec2 size = bmax - bmin;
|
||||
# float min_size = min(size.x, size.y);
|
||||
#
|
||||
# mortar *= min_size;
|
||||
# bevel *= min_size;
|
||||
# round *= min_size;
|
||||
# vec2 center = 0.5*(bmin+bmax);
|
||||
# vec2 d = abs(uv-center)-0.5*(size)+vec2(round+mortar);
|
||||
#
|
||||
# color = length(max(d,vec2(0))) + min(max(d.x,d.y),0.0)-round;
|
||||
# color = clamp(-color/bevel, 0.0, 1.0);
|
||||
# vec2 tiled_brick_pos = mod(bmin, vec2(1.0, 1.0));
|
||||
#
|
||||
# return vec4(color, center, tiled_brick_pos.x+7.0*tiled_brick_pos.y);
|
||||
#}
|
||||
|
||||
static func brick(uv : Vector2, bmin : Vector2, bmax : Vector2, mortar : float, pround : float, bevel : float) -> Color:
|
||||
var color : float
|
||||
@ -362,6 +445,25 @@ static func brick(uv : Vector2, bmin : Vector2, bmax : Vector2, mortar : float,
|
||||
|
||||
return Color(color, center.x, center.y, tiled_brick_pos_x + 7.0 * tiled_brick_pos_y)
|
||||
|
||||
#vec3 brick_random_color(vec2 bmin, vec2 bmax, float seed) {
|
||||
# vec2 center = 0.5*(bmin + bmax);
|
||||
# return rand3(fract(center + vec2(seed)));
|
||||
#}
|
||||
|
||||
static func brick_random_color(uv : Vector2, bmin : Vector2, bmax : Vector2, pseed : float) -> Vector3:
|
||||
var center : Vector2 = 0.5 * (bmin + bmax)
|
||||
|
||||
return Commons.rand3(Commons.fractv2(center + Vector2(pseed, pseed)));
|
||||
|
||||
#vec3 brick_uv(vec2 uv, vec2 bmin, vec2 bmax, float seed) {
|
||||
# vec2 center = 0.5*(bmin + bmax);
|
||||
# vec2 size = bmax - bmin;
|
||||
#
|
||||
# float max_size = max(size.x, size.y);
|
||||
#
|
||||
# return vec3(0.5+(uv-center)/max_size, rand(fract(center)+vec2(seed)));
|
||||
#}
|
||||
|
||||
static func brick_uv(uv : Vector2, bmin : Vector2, bmax : Vector2, pseed : float) -> Vector3:
|
||||
var center : Vector2 = 0.5 * (bmin + bmax)
|
||||
var size : Vector2 = bmax - bmin
|
||||
@ -371,7 +473,18 @@ static func brick_uv(uv : Vector2, bmin : Vector2, bmax : Vector2, pseed : float
|
||||
var y : float = 0.5+ (uv.y - center.y) /max_size
|
||||
|
||||
return Vector3(x, y, Commons.rand(Commons.fractv2(center) + Vector2(pseed, pseed)))
|
||||
|
||||
|
||||
#vec4 bricks_rb(vec2 uv, vec2 count, float repeat, float offset) {
|
||||
# count *= repeat;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 vec4(bmin, bmin+vec2(1.0)/count);
|
||||
#}
|
||||
|
||||
static func bricks_rb(uv : Vector2, count : Vector2, repeat : float, offset : float) -> Color:
|
||||
count *= repeat
|
||||
|
||||
@ -386,7 +499,21 @@ static func bricks_rb(uv : Vector2, count : Vector2, repeat : float, offset : fl
|
||||
var bmc : Vector2 = bmin + Vector2(1.0, 1.0) / count
|
||||
|
||||
return Color(bmin.x, bmin.y, bmc.x, bmc.y)
|
||||
|
||||
|
||||
#vec4 bricks_rb2(vec2 uv, vec2 count, float repeat, float offset) {
|
||||
# count *= repeat;
|
||||
#
|
||||
# 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 vec4(bmin, bmin+vec2(1.0)/count);
|
||||
#}
|
||||
|
||||
static func bricks_rb2(uv : Vector2, count : Vector2, repeat : float, offset : float) -> Color:
|
||||
count *= repeat
|
||||
|
||||
@ -403,7 +530,20 @@ static func bricks_rb2(uv : Vector2, count : Vector2, repeat : float, offset : f
|
||||
var b : Vector2 = bmin + Vector2(1, 1) / count
|
||||
|
||||
return Color(bmin.x, bmin.y, b.x, b.y)
|
||||
|
||||
|
||||
#vec4 bricks_hb(vec2 uv, vec2 count, float repeat, float offset) {
|
||||
# float pc = count.x+count.y;
|
||||
# float c = pc*repeat;
|
||||
# vec2 corner = floor(uv*c);
|
||||
# float cdiff = mod(corner.x-corner.y, pc);
|
||||
#
|
||||
# if (cdiff < count.x) {
|
||||
# return vec4((corner-vec2(cdiff, 0.0))/c, (corner-vec2(cdiff, 0.0)+vec2(count.x, 1.0))/c);
|
||||
# } else {
|
||||
# return vec4((corner-vec2(0.0, pc-cdiff-1.0))/c, (corner-vec2(0.0, pc-cdiff-1.0)+vec2(1.0, count.y))/c);
|
||||
# }
|
||||
#}
|
||||
|
||||
static func bricks_hb(uv : Vector2, count : Vector2, repeat : float, offset : float) -> Color:
|
||||
var pc : float = count.x + count.y
|
||||
var c : float = pc * repeat
|
||||
@ -431,7 +571,27 @@ static func bricks_hb(uv : Vector2, count : Vector2, repeat : float, offset : fl
|
||||
col.a = (corner.y - (pc - cdiff - 1.0) + count.y) / c
|
||||
|
||||
return col
|
||||
|
||||
|
||||
#vec4 bricks_bw(vec2 uv, vec2 count, float repeat, float offset) {
|
||||
# vec2 c = 2.0*count*repeat;
|
||||
# float mc = max(c.x, c.y);
|
||||
# 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) {
|
||||
# orner = 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 vec4(corner/c, (corner+size)/c);
|
||||
#}
|
||||
|
||||
static func bricks_bw(uv : Vector2, count : Vector2, repeat : float, offset : float) -> Color:
|
||||
var c : Vector2 = 2.0 * count * repeat
|
||||
var mc : float = max(c.x, c.y)
|
||||
@ -453,6 +613,35 @@ static func bricks_bw(uv : Vector2, count : Vector2, repeat : float, offset : fl
|
||||
|
||||
return Color(corner.x / c.x, corner.y / c.y, (corner.x + size.x) / c.x, (corner.y + size.y) / c.y)
|
||||
|
||||
#vec4 bricks_sb(vec2 uv, vec2 count, float repeat, float offset) {
|
||||
# vec2 c = (count+vec2(1.0))*repeat;
|
||||
# float mc = max(c.x, c.y);
|
||||
# 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 vec4(corner/c, (corner+size)/c);
|
||||
#}
|
||||
|
||||
static func bricks_sb(uv : Vector2, count : Vector2, repeat : float, offset : float) -> Color:
|
||||
var c : Vector2 = (count + Vector2(1, 1)) * repeat
|
||||
var mc : float = max(c.x, c.y)
|
||||
@ -480,127 +669,3 @@ static func bricks_sb(uv : Vector2, count : Vector2, repeat : float, offset : fl
|
||||
size = Vector2(count.x-1.0, count.y-1.0)
|
||||
|
||||
return Color(corner.x / c.x, corner.y / c.y, (corner.x + size.x) / c.x, (corner.y + size.y) / c.y)
|
||||
|
||||
#
|
||||
#vec4 $(name_uv)_rect = bricks_$pattern($uv, vec2($columns, $rows), $repeat, $row_offset);
|
||||
#vec4 $(name_uv) = brick($uv, $(name_uv)_rect.xy, $(name_uv)_rect.zw, $mortar*$mortar_map($uv), $round*$round_map($uv), max(0.001, $bevel*$bevel_map($uv)));
|
||||
#
|
||||
#vec4 brick(vec2 uv, vec2 bmin, vec2 bmax, float mortar, float round, float bevel) {
|
||||
# float color;
|
||||
# vec2 size = bmax - bmin;
|
||||
# float min_size = min(size.x, size.y);
|
||||
# mortar *= min_size;
|
||||
# bevel *= min_size;
|
||||
# round *= min_size;
|
||||
# vec2 center = 0.5*(bmin+bmax);
|
||||
#
|
||||
# vec2 d = abs(uv-center)-0.5*(size)+vec2(round+mortar);
|
||||
# color = length(max(d,vec2(0))) + min(max(d.x,d.y),0.0)-round;
|
||||
# color = clamp(-color/bevel, 0.0, 1.0);
|
||||
# vec2 tiled_brick_pos = mod(bmin, vec2(1.0, 1.0));
|
||||
#
|
||||
# return vec4(color, center, tiled_brick_pos.x+7.0*tiled_brick_pos.y);
|
||||
#}
|
||||
#
|
||||
#vec3 brick_uv(vec2 uv, vec2 bmin, vec2 bmax, float seed) {
|
||||
# vec2 center = 0.5*(bmin + bmax);
|
||||
# vec2 size = bmax - bmin;
|
||||
# float max_size = max(size.x, size.y);
|
||||
#
|
||||
# return vec3(0.5+(uv-center)/max_size, rand(fract(center)+vec2(seed)));
|
||||
#}
|
||||
#
|
||||
#vec3 brick_corner_uv(vec2 uv, vec2 bmin, vec2 bmax, float mortar, float corner, float seed) {
|
||||
# vec2 center = 0.5*(bmin + bmax);
|
||||
# vec2 size = bmax - bmin;
|
||||
# float max_size = max(size.x, size.y);
|
||||
# float min_size = min(size.x, size.y);
|
||||
# mortar *= min_size;corner *= min_size;
|
||||
#
|
||||
# return vec3(clamp((0.5*size-vec2(mortar)-abs(uv-center))/corner, vec2(0.0), vec2(1.0)), rand(fract(center)+vec2(seed)));
|
||||
#}
|
||||
#
|
||||
#vec4 bricks_rb(vec2 uv, vec2 count, float repeat, float offset) {
|
||||
# count *= repeat;
|
||||
# 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 vec4(bmin, bmin+vec2(1.0)/count);
|
||||
#}
|
||||
#
|
||||
#vec4 bricks_rb2(vec2 uv, vec2 count, float repeat, float offset) {
|
||||
# count *= repeat;
|
||||
#
|
||||
# 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 vec4(bmin, bmin+vec2(1.0)/count);
|
||||
#}
|
||||
#
|
||||
#vec4 bricks_hb(vec2 uv, vec2 count, float repeat, float offset) {
|
||||
# float pc = count.x+count.y;
|
||||
# float c = pc*repeat;
|
||||
# vec2 corner = floor(uv*c);
|
||||
# float cdiff = mod(corner.x-corner.y, pc);
|
||||
#
|
||||
# if (cdiff < count.x) {
|
||||
# return vec4((corner-vec2(cdiff, 0.0))/c, (corner-vec2(cdiff, 0.0)+vec2(count.x, 1.0))/c);
|
||||
# } else {
|
||||
# return vec4((corner-vec2(0.0, pc-cdiff-1.0))/c, (corner-vec2(0.0, pc-cdiff-1.0)+vec2(1.0, count.y))/c);
|
||||
# }
|
||||
#}
|
||||
#
|
||||
#vec4 bricks_bw(vec2 uv, vec2 count, float repeat, float offset) {
|
||||
# vec2 c = 2.0*count*repeat;
|
||||
# float mc = max(c.x, c.y);
|
||||
# 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 vec4(corner/c, (corner+size)/c);
|
||||
#}
|
||||
#
|
||||
#vec4 bricks_sb(vec2 uv, vec2 count, float repeat, float offset) {
|
||||
# vec2 c = (count+vec2(1.0))*repeat;
|
||||
# float mc = max(c.x, c.y);
|
||||
# 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 vec4(corner/c, (corner+size)/c);
|
||||
#}
|
||||
|
||||
|
@ -1,225 +0,0 @@
|
||||
{
|
||||
"name": "bricks",
|
||||
"node_position": {
|
||||
"x": 0,
|
||||
"y": 0
|
||||
},
|
||||
"parameters": {
|
||||
"bevel": 0.1,
|
||||
"columns": 3,
|
||||
"corner": 0.3,
|
||||
"mortar": 0.1,
|
||||
"pattern": 0,
|
||||
"repeat": 1,
|
||||
"round": 0,
|
||||
"row_offset": 0.5,
|
||||
"rows": 6
|
||||
},
|
||||
"shader_model": {
|
||||
"code": "vec4 $(name_uv)_rect = bricks_$pattern($uv, vec2($columns, $rows), $repeat, $row_offset);\nvec4 $(name_uv) = brick($uv, $(name_uv)_rect.xy, $(name_uv)_rect.zw, $mortar*$mortar_map($uv), $round*$round_map($uv), max(0.001, $bevel*$bevel_map($uv)));\n",
|
||||
"global": "vec4 brick(vec2 uv, vec2 bmin, vec2 bmax, float mortar, float round, float bevel) {\n\tfloat color;\n\tvec2 size = bmax - bmin;\n\tfloat min_size = min(size.x, size.y);\n\tmortar *= min_size;\n\tbevel *= min_size;\n\tround *= min_size;\n\tvec2 center = 0.5*(bmin+bmax);\n vec2 d = abs(uv-center)-0.5*(size)+vec2(round+mortar);\n color = length(max(d,vec2(0))) + min(max(d.x,d.y),0.0)-round;\n\tcolor = clamp(-color/bevel, 0.0, 1.0);\n\tvec2 tiled_brick_pos = mod(bmin, vec2(1.0, 1.0));\n\treturn vec4(color, center, tiled_brick_pos.x+7.0*tiled_brick_pos.y);\n}\n\nvec3 brick_random_color(vec2 bmin, vec2 bmax, float seed) {\n\tvec2 center = 0.5*(bmin + bmax);\n\treturn rand3(fract(center + vec2(seed)));\n}\n\nvec3 brick_uv(vec2 uv, vec2 bmin, vec2 bmax, float seed) {\n\tvec2 center = 0.5*(bmin + bmax);\n\tvec2 size = bmax - bmin;\n\tfloat max_size = max(size.x, size.y);\n\treturn vec3(0.5+(uv-center)/max_size, rand(fract(center)+vec2(seed)));\n}\n\nvec3 brick_corner_uv(vec2 uv, vec2 bmin, vec2 bmax, float mortar, float corner, float seed) {\n\tvec2 center = 0.5*(bmin + bmax);\n\tvec2 size = bmax - bmin;\n\tfloat max_size = max(size.x, size.y);\n\tfloat min_size = min(size.x, size.y);\n\tmortar *= min_size;\n\tcorner *= min_size;\n\treturn vec3(clamp((0.5*size-vec2(mortar)-abs(uv-center))/corner, vec2(0.0), vec2(1.0)), rand(fract(center)+vec2(seed)+ceil(vec2(uv-center))));\n}\n\nvec4 bricks_rb(vec2 uv, vec2 count, float repeat, float offset) {\n\tcount *= repeat;\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 vec4(bmin, bmin+vec2(1.0)/count);\n}\n\nvec4 bricks_rb2(vec2 uv, vec2 count, float repeat, float offset) {\n\tcount *= repeat;\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 vec4(bmin, bmin+vec2(1.0)/count);\n}\n\nvec4 bricks_hb(vec2 uv, vec2 count, float repeat, float offset) {\n\tfloat pc = count.x+count.y;\n\tfloat c = pc*repeat;\n\tvec2 corner = floor(uv*c);\n\tfloat cdiff = mod(corner.x-corner.y, pc);\n\tif (cdiff < count.x) {\n\t\treturn vec4((corner-vec2(cdiff, 0.0))/c, (corner-vec2(cdiff, 0.0)+vec2(count.x, 1.0))/c);\n\t} else {\n\t\treturn vec4((corner-vec2(0.0, pc-cdiff-1.0))/c, (corner-vec2(0.0, pc-cdiff-1.0)+vec2(1.0, count.y))/c);\n\t}\n}\n\nvec4 bricks_bw(vec2 uv, vec2 count, float repeat, float offset) {\n\tvec2 c = 2.0*count*repeat;\n\tfloat mc = max(c.x, c.y);\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 vec4(corner/c, (corner+size)/c);\n}\n\nvec4 bricks_sb(vec2 uv, vec2 count, float repeat, float offset) {\n\tvec2 c = (count+vec2(1.0))*repeat;\n\tfloat mc = max(c.x, c.y);\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 vec4(corner/c, (corner+size)/c);\n}",
|
||||
"inputs": [
|
||||
{
|
||||
"default": "1.0",
|
||||
"label": "6:",
|
||||
"longdesc": "A map that affects the Mortar parameter",
|
||||
"name": "mortar_map",
|
||||
"shortdesc": "Mortar map",
|
||||
"type": "f"
|
||||
},
|
||||
{
|
||||
"default": "1.0",
|
||||
"label": "",
|
||||
"longdesc": "A map that affects the Bevel parameter",
|
||||
"name": "bevel_map",
|
||||
"shortdesc": "Bevel map",
|
||||
"type": "f"
|
||||
},
|
||||
{
|
||||
"default": "1.0",
|
||||
"label": "",
|
||||
"longdesc": "A map that affects the Round parameter",
|
||||
"name": "round_map",
|
||||
"shortdesc": "Round map",
|
||||
"type": "f"
|
||||
}
|
||||
],
|
||||
"instance": "",
|
||||
"longdesc": "Generates different bricks patterns, with many useful outputs.",
|
||||
"name": "Bricks",
|
||||
"outputs": [
|
||||
{
|
||||
"f": "$(name_uv).x",
|
||||
"longdesc": "A greyscale image that shows the bricks pattern",
|
||||
"shortdesc": "Bricks pattern",
|
||||
"type": "f"
|
||||
},
|
||||
{
|
||||
"longdesc": "A random color for each brick",
|
||||
"rgb": "brick_random_color($(name_uv)_rect.xy, $(name_uv)_rect.zw, float($seed))",
|
||||
"shortdesc": "Random color",
|
||||
"type": "rgb"
|
||||
},
|
||||
{
|
||||
"f": "$(name_uv).y",
|
||||
"longdesc": "The position of each brick along the X axis",
|
||||
"shortdesc": "Position.x",
|
||||
"type": "f"
|
||||
},
|
||||
{
|
||||
"f": "$(name_uv).z",
|
||||
"longdesc": "The position of each brick along the Y axis",
|
||||
"shortdesc": "Position.y",
|
||||
"type": "f"
|
||||
},
|
||||
{
|
||||
"longdesc": "An UV map output for each brick, to be connected to the Map input of a CustomUV node",
|
||||
"rgb": "brick_uv($uv, $(name_uv)_rect.xy, $(name_uv)_rect.zw, float($seed))",
|
||||
"shortdesc": "Brick UV",
|
||||
"type": "rgb"
|
||||
},
|
||||
{
|
||||
"longdesc": "An UV map output for each brick corner, to be connected to the Map input of a CustomUV node",
|
||||
"rgb": "brick_corner_uv($uv, $(name_uv)_rect.xy, $(name_uv)_rect.zw, $mortar*$mortar_map($uv), $corner, float($seed))",
|
||||
"shortdesc": "Corner UV",
|
||||
"type": "rgb"
|
||||
},
|
||||
{
|
||||
"f": "0.5*(sign($(name_uv)_rect.z-$(name_uv)_rect.x-$(name_uv)_rect.w+$(name_uv)_rect.y)+1.0)",
|
||||
"longdesc": "The direction of each brick (white: horizontal, black: vertical)",
|
||||
"shortdesc": "Direction",
|
||||
"type": "f"
|
||||
}
|
||||
],
|
||||
"parameters": [
|
||||
{
|
||||
"default": 0,
|
||||
"label": "",
|
||||
"longdesc": "The type of brick pattern",
|
||||
"name": "pattern",
|
||||
"shortdesc": "Pattern",
|
||||
"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"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"control": "None",
|
||||
"default": 1,
|
||||
"label": "Repeat:",
|
||||
"longdesc": "The number of repetitions of the whole pattern",
|
||||
"max": 8,
|
||||
"min": 1,
|
||||
"name": "repeat",
|
||||
"shortdesc": "Repeat",
|
||||
"step": 1,
|
||||
"type": "float"
|
||||
},
|
||||
{
|
||||
"control": "None",
|
||||
"default": 6,
|
||||
"label": "Rows:",
|
||||
"longdesc": "The number of rows of a pattern",
|
||||
"max": 64,
|
||||
"min": 1,
|
||||
"name": "rows",
|
||||
"shortdesc": "Rows",
|
||||
"step": 1,
|
||||
"type": "float"
|
||||
},
|
||||
{
|
||||
"control": "None",
|
||||
"default": 3,
|
||||
"label": "Columns:",
|
||||
"longdesc": "The number of columns of a pattern",
|
||||
"max": 64,
|
||||
"min": 1,
|
||||
"name": "columns",
|
||||
"shortdesc": "Columns",
|
||||
"step": 1,
|
||||
"type": "float"
|
||||
},
|
||||
{
|
||||
"control": "None",
|
||||
"default": 0.5,
|
||||
"label": "Offset:",
|
||||
"longdesc": "The offset of the pattern (not useful for all patterns)",
|
||||
"max": 1,
|
||||
"min": 0,
|
||||
"name": "row_offset",
|
||||
"shortdesc": "Offset",
|
||||
"step": 0.01,
|
||||
"type": "float"
|
||||
},
|
||||
{
|
||||
"control": "None",
|
||||
"default": 0.1,
|
||||
"label": "Mortar:",
|
||||
"longdesc": "The width of the space between bricks",
|
||||
"max": 0.5,
|
||||
"min": 0,
|
||||
"name": "mortar",
|
||||
"shortdesc": "Mortar",
|
||||
"step": 0.01,
|
||||
"type": "float"
|
||||
},
|
||||
{
|
||||
"control": "None",
|
||||
"default": 0.1,
|
||||
"label": "Bevel:",
|
||||
"longdesc": "The width of the edge of each brick",
|
||||
"max": 0.5,
|
||||
"min": 0,
|
||||
"name": "bevel",
|
||||
"shortdesc": "Bevel",
|
||||
"step": 0.01,
|
||||
"type": "float"
|
||||
},
|
||||
{
|
||||
"control": "None",
|
||||
"default": 0,
|
||||
"label": "Round:",
|
||||
"longdesc": "The radius of the round corners of bricks",
|
||||
"max": 0.5,
|
||||
"min": 0,
|
||||
"name": "round",
|
||||
"shortdesc": "Round",
|
||||
"step": 0.01,
|
||||
"type": "float"
|
||||
},
|
||||
{
|
||||
"control": "None",
|
||||
"default": 0.1,
|
||||
"label": "Corner:",
|
||||
"longdesc": "The size of the corner part of each brick (only used by the Corner UV output)",
|
||||
"max": 0.5,
|
||||
"min": 0,
|
||||
"name": "corner",
|
||||
"shortdesc": "Corner",
|
||||
"step": 0.01,
|
||||
"type": "float"
|
||||
}
|
||||
],
|
||||
"shortdesc": "Simple bricks patterns"
|
||||
},
|
||||
"type": "shader"
|
||||
}
|
Loading…
Reference in New Issue
Block a user