mirror of
https://github.com/Relintai/broken_seals.git
synced 2024-12-21 13:16:49 +01:00
Finished patterns.
This commit is contained in:
parent
cb7fd0a873
commit
743e92ad55
@ -246,316 +246,6 @@ static func ThickLine(uv : Vector2, posA : Vector2, posB : Vector2, radiusInv :
|
||||
|
||||
return finalGray;
|
||||
|
||||
static func truchet1(uv : Vector2, pseed : Vector2) -> float:
|
||||
var i : Vector2 = floorv2(uv);
|
||||
var f : Vector2 = fractv2(uv) - Vector2(0.5, 0.5);
|
||||
return 1.0 - abs(abs((2.0*step(rand(i+pseed), 0.5)-1.0)*f.x+f.y)-0.5);
|
||||
|
||||
static func truchet2(uv : Vector2, pseed : Vector2) -> float:
|
||||
var i : Vector2 = floorv2(uv);
|
||||
var f : Vector2 = fractv2(uv);
|
||||
var random : float = step(rand(i+pseed), 0.5);
|
||||
f.x *= 2.0 * random-1.0;
|
||||
f.x += 1.0 - random;
|
||||
return 1.0 - min(abs(f.length() - 0.5), abs((Vector2(1, 1) - f).length() - 0.5));
|
||||
|
||||
static func weave(uv : Vector2, count : Vector2, width : float) -> float:
|
||||
uv *= count;
|
||||
var c : float = (sin(3.1415926* (uv.x + floor(uv.y)))*0.5+0.5)*step(abs(fract(uv.y)-0.5), width*0.5);
|
||||
c = 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));
|
||||
return c;
|
||||
|
||||
|
||||
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)
|
||||
var size : Vector2 = bmax - bmin
|
||||
var max_size : float = max(size.x, size.y)
|
||||
var min_size : float = min(size.x, size.y)
|
||||
mortar *= min_size
|
||||
corner *= min_size
|
||||
|
||||
var r : Vector3 = Vector3()
|
||||
|
||||
r.x = clamp(((0.5 * size.x - mortar) - abs(uv.x - center.x)) / corner, 0, 1)
|
||||
r.y = clamp(((0.5 * size.y - mortar) - abs(uv.y - center.y)) / corner, 0, 1)
|
||||
r.z = rand(fractv2(center) + Vector2(pseed, pseed))
|
||||
|
||||
return r
|
||||
|
||||
# return vec3(clamp((0.5*size-vec2(mortar)-abs(uv-center))/corner, vec2(0.0), vec2(1.0)), rand(fract(center)+vec2(seed)));
|
||||
|
||||
|
||||
static func brick(uv : Vector2, bmin : Vector2, bmax : Vector2, mortar : float, pround : float, bevel : float) -> Color:
|
||||
var color : float
|
||||
var size : Vector2 = bmax - bmin
|
||||
|
||||
var min_size : float = min(size.x, size.y)
|
||||
mortar *= min_size
|
||||
bevel *= min_size
|
||||
pround *= min_size
|
||||
|
||||
var center : Vector2 = 0.5 * (bmin + bmax)
|
||||
var d : Vector2 = Vector2()
|
||||
|
||||
d.x = abs(uv.x - center.x) - 0.5 * (size.x) + (pround + mortar)
|
||||
d.y = abs(uv.y - center.y) - 0.5 * (size.y) + (pround + mortar)
|
||||
|
||||
color = Vector2(max(d.x, 0), max(d.y, 0)).length() + min(max(d.x, d.y), 0.0) - pround
|
||||
|
||||
color = clamp(-color / bevel, 0.0, 1.0)
|
||||
|
||||
# var tiled_brick_pos : Vector2 = Vector2(bmin.x - 1.0 * floor(bmin.x / 1.0), bmin.y - 1.0 * floor(bmin.y / 1.0))
|
||||
|
||||
var tiled_brick_pos_x : float = bmin.x - 1.0 * floor(bmin.x / 1.0)
|
||||
var tiled_brick_pos_y : float = bmin.y - 1.0 * floor(bmin.y / 1.0)
|
||||
|
||||
#vec2 tiled_brick_pos = mod(bmin, vec2(1.0, 1.0));
|
||||
|
||||
return Color(color, center.x, center.y, tiled_brick_pos_x + 7.0 * tiled_brick_pos_y)
|
||||
|
||||
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
|
||||
var max_size : float = max(size.x, size.y)
|
||||
|
||||
var x : float = 0.5+ (uv.x - center.x) / max_size
|
||||
var y : float = 0.5+ (uv.y - center.y) /max_size
|
||||
|
||||
return Vector3(x, y, rand(fractv2(center) + Vector2(pseed, pseed)))
|
||||
|
||||
static func bricks_rb(uv : Vector2, count : Vector2, repeat : float, offset : float) -> Color:
|
||||
count *= repeat
|
||||
|
||||
var x_offset : float = offset * step(0.5, fractf(uv.y * count.y * 0.5))
|
||||
|
||||
var bmin : Vector2
|
||||
bmin.x = floor(uv.x * count.x - x_offset)
|
||||
bmin.y = floor(uv.y * count.y)
|
||||
|
||||
bmin.x += x_offset;
|
||||
bmin /= count
|
||||
var bmc : Vector2 = bmin + Vector2(1.0, 1.0) / count
|
||||
|
||||
return Color(bmin.x, bmin.y, bmc.x, bmc.y)
|
||||
|
||||
static func bricks_rb2(uv : Vector2, count : Vector2, repeat : float, offset : float) -> Color:
|
||||
count *= repeat
|
||||
|
||||
var x_offset : float = offset * step(0.5, fractf(uv.y * count.y * 0.5))
|
||||
count.x = count.x * (1.0+step(0.5, fractf(uv.y * count.y * 0.5)))
|
||||
var bmin : Vector2 = Vector2()
|
||||
|
||||
bmin.x = floor(uv.x * count.x - x_offset)
|
||||
bmin.y = floor(uv.y * count.y)
|
||||
|
||||
bmin.x += x_offset
|
||||
bmin /= count
|
||||
|
||||
var b : Vector2 = bmin + Vector2(1, 1) / count
|
||||
|
||||
return Color(bmin.x, bmin.y, b.x, b.y)
|
||||
|
||||
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
|
||||
|
||||
var corner : Vector2 = Vector2(floor(uv.x * c), floor(uv.y * c))
|
||||
var cdiff : float = modf(corner.x - corner.y, pc)
|
||||
|
||||
if (cdiff < count.x):
|
||||
var col : Color = Color()
|
||||
|
||||
col.r = (corner.x - cdiff) / c
|
||||
col.g = corner.y / c
|
||||
|
||||
col.b = (corner.x - cdiff + count.x) / c
|
||||
col.a = (corner.y + 1.0) / c
|
||||
|
||||
return col
|
||||
else:
|
||||
var col : Color = Color()
|
||||
|
||||
col.r = corner.x / c
|
||||
col.g = (corner.y - (pc - cdiff - 1.0)) / c
|
||||
|
||||
col.b = (corner.x + 1.0) / c
|
||||
col.a = (corner.y - (pc - cdiff - 1.0) + count.y) / c
|
||||
|
||||
return col
|
||||
|
||||
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)
|
||||
var corner1 : Vector2 = Vector2(floor(uv.x * c.x), floor(uv.y * c.y))
|
||||
var corner2 : Vector2 = Vector2(count.x * floor(repeat* 2.0 * uv.x), count.y * floor(repeat * 2.0 * uv.y))
|
||||
|
||||
var tmp : Vector2 = Vector2(floor(repeat * 2.0 * uv.x), floor(repeat * 2.0 * uv.y))
|
||||
var cdiff : float = modf(tmp.dot(Vector2(1, 1)), 2.0)
|
||||
|
||||
var corner : Vector2
|
||||
var size : Vector2
|
||||
|
||||
if cdiff == 0:
|
||||
corner = Vector2(corner1.x, corner2.y)
|
||||
size = Vector2(1.0, count.y)
|
||||
else:
|
||||
corner = Vector2(corner2.x, corner1.y)
|
||||
size = Vector2(count.x, 1.0)
|
||||
|
||||
return Color(corner.x / c.x, corner.y / c.y, (corner.x + size.x) / c.x, (corner.y + size.y) / c.y)
|
||||
|
||||
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)
|
||||
var corner1 : Vector2 = Vector2(floor(uv.x * c.x), floor(uv.y * c.y))
|
||||
var corner2 : Vector2 = (count + Vector2(1, 1)) * Vector2(floor(repeat * uv.x), floor(repeat * uv.y))
|
||||
var rcorner : Vector2 = corner1 - corner2
|
||||
|
||||
var corner : Vector2
|
||||
var size : Vector2
|
||||
|
||||
if (rcorner.x == 0.0 && rcorner.y < count.y):
|
||||
corner = corner2
|
||||
size = Vector2(1.0, count.y)
|
||||
elif (rcorner.y == 0.0):
|
||||
corner = corner2 + Vector2(1.0, 0.0)
|
||||
size = Vector2(count.x, 1.0)
|
||||
elif (rcorner.x == count.x):
|
||||
corner = corner2 + Vector2(count.x, 1.0)
|
||||
size = Vector2(1.0, count.y)
|
||||
elif (rcorner.y == count.y):
|
||||
corner = corner2 + Vector2(0.0, count.y)
|
||||
size = Vector2(count.x, 1.0)
|
||||
else:
|
||||
corner = corner2 + Vector2(1, 1)
|
||||
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;\n\tcorner *= 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;\n\tbmin /= 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);
|
||||
#}
|
||||
|
||||
|
||||
static func sdr_ndot(a : Vector2, b : Vector2) -> float:
|
||||
return a.x * b.x - a.y * b.y;
|
||||
|
||||
|
@ -66,6 +66,38 @@ static func pattern(uv : Vector2, x_scale : float, y_scale : float, ct : int, ca
|
||||
|
||||
return 0.0
|
||||
|
||||
static func truchet1c(uv : Vector2, pseed : Vector2) -> Color:
|
||||
var f : float = truchet1(uv, pseed)
|
||||
return Color(f, f, f, 1);
|
||||
|
||||
static func truchet1(uv : Vector2, pseed : Vector2) -> float:
|
||||
var i : Vector2 = Commons.floorv2(uv);
|
||||
var f : Vector2 = Commons.fractv2(uv) - Vector2(0.5, 0.5);
|
||||
return 1.0 - abs(abs((2.0*Commons.step(Commons.rand(i+pseed), 0.5)-1.0)*f.x+f.y)-0.5);
|
||||
|
||||
static func truchet2c(uv : Vector2, pseed : Vector2) -> Color:
|
||||
var f : float = truchet2(uv, pseed)
|
||||
return Color(f, f, f, 1);
|
||||
|
||||
static func truchet2(uv : Vector2, pseed : Vector2) -> float:
|
||||
var i : Vector2 = Commons.floorv2(uv);
|
||||
var f : Vector2 = Commons.fractv2(uv);
|
||||
var random : float = Commons.step(Commons.rand(i+pseed), 0.5);
|
||||
f.x *= 2.0 * random-1.0;
|
||||
f.x += 1.0 - random;
|
||||
return 1.0 - min(abs(f.length() - 0.5), abs((Vector2(1, 1) - f).length() - 0.5));
|
||||
|
||||
static func weavec(uv : Vector2, count : Vector2, width : float) -> Color:
|
||||
var f : float = weave(uv, count, width);
|
||||
|
||||
return Color(f, f, f, 1)
|
||||
|
||||
static func weave(uv : Vector2, count : Vector2, width : float) -> float:
|
||||
uv *= count;
|
||||
var c : float = (sin(3.1415926* (uv.x + floor(uv.y)))*0.5+0.5)*Commons.step(abs(Commons.fract(uv.y)-0.5), width*0.5);
|
||||
c = max(c, (sin(3.1415926*(1.0+uv.y+floor(uv.x)))*0.5+0.5)*Commons.step(abs(Commons.fract(uv.x)-0.5), width*0.5));
|
||||
return c;
|
||||
|
||||
static func sinewavec(uv : Vector2, amplitude : float, frequency : float, phase : float) -> Color:
|
||||
var f : float = 1.0- abs(2.0 * (uv.y-0.5) - amplitude * sin((frequency* uv.x + phase) * 6.28318530718));
|
||||
|
||||
@ -232,3 +264,293 @@ 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);
|
||||
|
||||
|
||||
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)
|
||||
var size : Vector2 = bmax - bmin
|
||||
var max_size : float = max(size.x, size.y)
|
||||
var min_size : float = min(size.x, size.y)
|
||||
mortar *= min_size
|
||||
corner *= min_size
|
||||
|
||||
var r : Vector3 = Vector3()
|
||||
|
||||
r.x = clamp(((0.5 * size.x - mortar) - abs(uv.x - center.x)) / corner, 0, 1)
|
||||
r.y = clamp(((0.5 * size.y - mortar) - abs(uv.y - center.y)) / corner, 0, 1)
|
||||
r.z = Commons.rand(Commons.fractv2(center) + Vector2(pseed, pseed))
|
||||
|
||||
return r
|
||||
|
||||
# return vec3(clamp((0.5*size-vec2(mortar)-abs(uv-center))/corner, vec2(0.0), vec2(1.0)), rand(fract(center)+vec2(seed)));
|
||||
|
||||
|
||||
static func brick(uv : Vector2, bmin : Vector2, bmax : Vector2, mortar : float, pround : float, bevel : float) -> Color:
|
||||
var color : float
|
||||
var size : Vector2 = bmax - bmin
|
||||
|
||||
var min_size : float = min(size.x, size.y)
|
||||
mortar *= min_size
|
||||
bevel *= min_size
|
||||
pround *= min_size
|
||||
|
||||
var center : Vector2 = 0.5 * (bmin + bmax)
|
||||
var d : Vector2 = Vector2()
|
||||
|
||||
d.x = abs(uv.x - center.x) - 0.5 * (size.x) + (pround + mortar)
|
||||
d.y = abs(uv.y - center.y) - 0.5 * (size.y) + (pround + mortar)
|
||||
|
||||
color = Vector2(max(d.x, 0), max(d.y, 0)).length() + min(max(d.x, d.y), 0.0) - pround
|
||||
|
||||
color = clamp(-color / bevel, 0.0, 1.0)
|
||||
|
||||
# var tiled_brick_pos : Vector2 = Vector2(bmin.x - 1.0 * floor(bmin.x / 1.0), bmin.y - 1.0 * floor(bmin.y / 1.0))
|
||||
|
||||
var tiled_brick_pos_x : float = bmin.x - 1.0 * floor(bmin.x / 1.0)
|
||||
var tiled_brick_pos_y : float = bmin.y - 1.0 * floor(bmin.y / 1.0)
|
||||
|
||||
#vec2 tiled_brick_pos = mod(bmin, vec2(1.0, 1.0));
|
||||
|
||||
return Color(color, center.x, center.y, tiled_brick_pos_x + 7.0 * tiled_brick_pos_y)
|
||||
|
||||
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
|
||||
var max_size : float = max(size.x, size.y)
|
||||
|
||||
var x : float = 0.5+ (uv.x - center.x) / max_size
|
||||
var y : float = 0.5+ (uv.y - center.y) /max_size
|
||||
|
||||
return Vector3(x, y, Commons.rand(Commons.fractv2(center) + Vector2(pseed, pseed)))
|
||||
|
||||
static func bricks_rb(uv : Vector2, count : Vector2, repeat : float, offset : float) -> Color:
|
||||
count *= repeat
|
||||
|
||||
var x_offset : float = offset * Commons.step(0.5, Commons.fractf(uv.y * count.y * 0.5))
|
||||
|
||||
var bmin : Vector2
|
||||
bmin.x = floor(uv.x * count.x - x_offset)
|
||||
bmin.y = floor(uv.y * count.y)
|
||||
|
||||
bmin.x += x_offset;
|
||||
bmin /= count
|
||||
var bmc : Vector2 = bmin + Vector2(1.0, 1.0) / count
|
||||
|
||||
return Color(bmin.x, bmin.y, bmc.x, bmc.y)
|
||||
|
||||
static func bricks_rb2(uv : Vector2, count : Vector2, repeat : float, offset : float) -> Color:
|
||||
count *= repeat
|
||||
|
||||
var x_offset : float = offset * Commons.step(0.5, Commons.fractf(uv.y * count.y * 0.5))
|
||||
count.x = count.x * (1.0+Commons.step(0.5, Commons.fractf(uv.y * count.y * 0.5)))
|
||||
var bmin : Vector2 = Vector2()
|
||||
|
||||
bmin.x = floor(uv.x * count.x - x_offset)
|
||||
bmin.y = floor(uv.y * count.y)
|
||||
|
||||
bmin.x += x_offset
|
||||
bmin /= count
|
||||
|
||||
var b : Vector2 = bmin + Vector2(1, 1) / count
|
||||
|
||||
return Color(bmin.x, bmin.y, b.x, b.y)
|
||||
|
||||
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
|
||||
|
||||
var corner : Vector2 = Vector2(floor(uv.x * c), floor(uv.y * c))
|
||||
var cdiff : float = Commons.modf(corner.x - corner.y, pc)
|
||||
|
||||
if (cdiff < count.x):
|
||||
var col : Color = Color()
|
||||
|
||||
col.r = (corner.x - cdiff) / c
|
||||
col.g = corner.y / c
|
||||
|
||||
col.b = (corner.x - cdiff + count.x) / c
|
||||
col.a = (corner.y + 1.0) / c
|
||||
|
||||
return col
|
||||
else:
|
||||
var col : Color = Color()
|
||||
|
||||
col.r = corner.x / c
|
||||
col.g = (corner.y - (pc - cdiff - 1.0)) / c
|
||||
|
||||
col.b = (corner.x + 1.0) / c
|
||||
col.a = (corner.y - (pc - cdiff - 1.0) + count.y) / c
|
||||
|
||||
return col
|
||||
|
||||
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)
|
||||
var corner1 : Vector2 = Vector2(floor(uv.x * c.x), floor(uv.y * c.y))
|
||||
var corner2 : Vector2 = Vector2(count.x * floor(repeat* 2.0 * uv.x), count.y * floor(repeat * 2.0 * uv.y))
|
||||
|
||||
var tmp : Vector2 = Vector2(floor(repeat * 2.0 * uv.x), floor(repeat * 2.0 * uv.y))
|
||||
var cdiff : float = Commons.modf(tmp.dot(Vector2(1, 1)), 2.0)
|
||||
|
||||
var corner : Vector2
|
||||
var size : Vector2
|
||||
|
||||
if cdiff == 0:
|
||||
corner = Vector2(corner1.x, corner2.y)
|
||||
size = Vector2(1.0, count.y)
|
||||
else:
|
||||
corner = Vector2(corner2.x, corner1.y)
|
||||
size = Vector2(count.x, 1.0)
|
||||
|
||||
return Color(corner.x / c.x, corner.y / c.y, (corner.x + size.x) / c.x, (corner.y + size.y) / c.y)
|
||||
|
||||
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)
|
||||
var corner1 : Vector2 = Vector2(floor(uv.x * c.x), floor(uv.y * c.y))
|
||||
var corner2 : Vector2 = (count + Vector2(1, 1)) * Vector2(floor(repeat * uv.x), floor(repeat * uv.y))
|
||||
var rcorner : Vector2 = corner1 - corner2
|
||||
|
||||
var corner : Vector2
|
||||
var size : Vector2
|
||||
|
||||
if (rcorner.x == 0.0 && rcorner.y < count.y):
|
||||
corner = corner2
|
||||
size = Vector2(1.0, count.y)
|
||||
elif (rcorner.y == 0.0):
|
||||
corner = corner2 + Vector2(1.0, 0.0)
|
||||
size = Vector2(count.x, 1.0)
|
||||
elif (rcorner.x == count.x):
|
||||
corner = corner2 + Vector2(count.x, 1.0)
|
||||
size = Vector2(1.0, count.y)
|
||||
elif (rcorner.y == count.y):
|
||||
corner = corner2 + Vector2(0.0, count.y)
|
||||
size = Vector2(count.x, 1.0)
|
||||
else:
|
||||
corner = corner2 + Vector2(1, 1)
|
||||
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;\n\tcorner *= 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;\n\tbmin /= 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,7 +1,7 @@
|
||||
tool
|
||||
extends TextureRect
|
||||
|
||||
var Commons = preload("res://addons/mat_maker_gd/nodes/common/commons.gd")
|
||||
var Patterns = preload("res://addons/mat_maker_gd/nodes/common/patterns.gd")
|
||||
|
||||
var image : Image
|
||||
var tex : ImageTexture
|
||||
@ -83,11 +83,11 @@ func gen() -> void:
|
||||
# var brect : Color = bricks_bw(v, Vector2(p_o39644_columns, p_o39644_rows), p_o39644_repeat, p_o39644_row_offset);
|
||||
|
||||
#SpanishBond
|
||||
var brect : Color = Commons.bricks_sb(v, Vector2(p_o39644_columns, p_o39644_rows), p_o39644_repeat, p_o39644_row_offset);
|
||||
var brect : Color = Patterns.bricks_sb(v, Vector2(p_o39644_columns, p_o39644_rows), p_o39644_repeat, p_o39644_row_offset);
|
||||
|
||||
|
||||
# 1, 2
|
||||
var fcolor : Color = Commons.brick(v, Vector2(brect.r, brect.g), Vector2(brect.b, brect.a), p_o39644_mortar*1.0, p_o39644_round*1.0, max(0.001, p_o39644_bevel*1.0));
|
||||
var fcolor : Color = Patterns.brick(v, Vector2(brect.r, brect.g), Vector2(brect.b, brect.a), p_o39644_mortar*1.0, p_o39644_round*1.0, max(0.001, p_o39644_bevel*1.0));
|
||||
|
||||
# image.set_pixel(x, y, brect)
|
||||
# image.set_pixel(x, y, fcolor)
|
||||
|
@ -1,7 +1,7 @@
|
||||
tool
|
||||
extends TextureRect
|
||||
|
||||
var Commons = preload("res://addons/mat_maker_gd/nodes/common/commons.gd")
|
||||
var Patterns = preload("res://addons/mat_maker_gd/nodes/common/patterns.gd")
|
||||
|
||||
var image : Image
|
||||
var tex : ImageTexture
|
||||
@ -56,11 +56,8 @@ var seed_o9164 = 6039;
|
||||
var p_o9164_size = 4.000000000;
|
||||
|
||||
func trunchet(uv : Vector2) -> Color:
|
||||
# var f : float = truchet1(uv * p_o9164_size, Vector2(float(seed_o9164), float(seed_o9164)));
|
||||
var f : float = Commons.truchet2(uv * p_o9164_size, Vector2(float(seed_o9164), float(seed_o9164)));
|
||||
var col : Color = Color(f, f, f, 1);
|
||||
|
||||
return col
|
||||
return Patterns.truchet1c(uv * p_o9164_size, Vector2(float(seed_o9164), float(seed_o9164)));
|
||||
# return Patterns.truchet2c(uv * p_o9164_size, Vector2(float(seed_o9164), float(seed_o9164)));
|
||||
|
||||
func reffg():
|
||||
return false
|
||||
|
@ -1,7 +1,7 @@
|
||||
tool
|
||||
extends TextureRect
|
||||
|
||||
var Commons = preload("res://addons/mat_maker_gd/nodes/common/commons.gd")
|
||||
var Patterns = preload("res://addons/mat_maker_gd/nodes/common/patterns.gd")
|
||||
|
||||
var image : Image
|
||||
var tex : ImageTexture
|
||||
@ -56,9 +56,7 @@ var p_o46354_rows = 4.000000000;
|
||||
var p_o46354_width = 1.000000000;
|
||||
|
||||
func weavecol(uv : Vector2) -> Color:
|
||||
var f : float = Commons.weave(uv, Vector2(p_o46354_columns, p_o46354_rows), p_o46354_width*1.0);
|
||||
|
||||
return Color(f, f, f, 1)
|
||||
return Patterns.weavec(uv, Vector2(p_o46354_columns, p_o46354_rows), p_o46354_width*1.0);
|
||||
|
||||
func reffg():
|
||||
return false
|
||||
|
Loading…
Reference in New Issue
Block a user