mirror of
https://github.com/Relintai/broken_seals.git
synced 2025-01-15 02:01:09 +01:00
Moved the rest of the gradient related code to gradients.gd.
This commit is contained in:
parent
0fc71e0f2c
commit
55f85a9b2d
@ -4,6 +4,38 @@ const Commons = preload("res://addons/mat_maker_gd/nodes/common/commons.gd")
|
||||
|
||||
#note: data : PoolRealArray -> pos, r, g, b, a, pos, r, g, b, a ....
|
||||
|
||||
static func radial_gradient_type_1(uv : Vector2, repeat : float, data : PoolRealArray) -> Color:
|
||||
return gradient_type_1(Commons.fractf(repeat * 1.41421356237* (Commons.fractv2(uv) - Vector2(0.5, 0.5)).length()), data)
|
||||
|
||||
static func radial_gradient_type_2(uv : Vector2, repeat : float, data : PoolRealArray) -> Color:
|
||||
return gradient_type_2(Commons.fractf(repeat * 1.41421356237* (Commons.fractv2(uv) - Vector2(0.5, 0.5)).length()), data)
|
||||
|
||||
static func radial_gradient_type_3(uv : Vector2, repeat : float, data : PoolRealArray) -> Color:
|
||||
return gradient_type_3(Commons.fractf(repeat * 1.41421356237* (Commons.fractv2(uv) - Vector2(0.5, 0.5)).length()), data)
|
||||
|
||||
static func radial_gradient_type_4(uv : Vector2, repeat : float, data : PoolRealArray) -> Color:
|
||||
return gradient_type_4(Commons.fractf(repeat * 1.41421356237* (Commons.fractv2(uv) - Vector2(0.5, 0.5)).length()), data)
|
||||
|
||||
|
||||
|
||||
static func normal_gradient_type_1(uv : Vector2, repeat : float, rotate : float, data : PoolRealArray) -> Color:
|
||||
var rr : float = 0.5+(cos(rotate*0.01745329251)*(uv.x-0.5)+sin(rotate*0.01745329251)*(uv.y-0.5))/(cos(abs(Commons.modf(rotate, 90.0)-45.0)*0.01745329251)*1.41421356237);
|
||||
return gradient_type_1(Commons.fractf(rr * repeat), data)
|
||||
|
||||
static func normal_gradient_type_2(uv : Vector2, repeat : float, rotate : float, data : PoolRealArray) -> Color:
|
||||
var rr : float = 0.5+(cos(rotate*0.01745329251)*(uv.x-0.5)+sin(rotate*0.01745329251)*(uv.y-0.5))/(cos(abs(Commons.modf(rotate, 90.0)-45.0)*0.01745329251)*1.41421356237);
|
||||
return gradient_type_2(Commons.fractf(rr * repeat), data)
|
||||
|
||||
static func normal_gradient_type_3(uv : Vector2, repeat : float, rotate : float, data : PoolRealArray) -> Color:
|
||||
var rr : float = 0.5+(cos(rotate*0.01745329251)*(uv.x-0.5)+sin(rotate*0.01745329251)*(uv.y-0.5))/(cos(abs(Commons.modf(rotate, 90.0)-45.0)*0.01745329251)*1.41421356237);
|
||||
return gradient_type_3(Commons.fractf(rr * repeat), data)
|
||||
|
||||
static func normal_gradient_type_4(uv : Vector2, repeat : float, rotate : float, data : PoolRealArray) -> Color:
|
||||
var rr : float = 0.5+(cos(rotate*0.01745329251)*(uv.x-0.5)+sin(rotate*0.01745329251)*(uv.y-0.5))/(cos(abs(Commons.modf(rotate, 90.0)-45.0)*0.01745329251)*1.41421356237);
|
||||
return gradient_type_4(Commons.fractf(rr * repeat), data)
|
||||
|
||||
|
||||
|
||||
static func circular_gradient_type_1(uv : Vector2, repeat : float, data : PoolRealArray) -> Color:
|
||||
return gradient_type_1(Commons.fractf(repeat * 0.15915494309 * atan((uv.x - 0.5) / uv.y - 0.5)), data)
|
||||
|
||||
@ -16,6 +48,8 @@ static func circular_gradient_type_3(uv : Vector2, repeat : float, data : PoolRe
|
||||
static func circular_gradient_type_4(uv : Vector2, repeat : float, data : PoolRealArray) -> Color:
|
||||
return gradient_type_4(Commons.fractf(repeat * 0.15915494309 * atan((uv.x - 0.5) / uv.y - 0.5)), data)
|
||||
|
||||
|
||||
|
||||
static func gradient_type_1(x : float, data : PoolRealArray) -> Color:
|
||||
if data.size() % 5 != 0 || data.size() == 0:
|
||||
return Color()
|
||||
@ -85,3 +119,64 @@ static func gradient_type_4(x : float, data : PoolRealArray) -> Color:
|
||||
# return lerp(lerp(Color(gradient_0_r,gradient_0_g,gradient_0_b,gradient_0_a), Color(gradient_1_r,gradient_1_g,gradient_1_b,gradient_1_a), (x-gradient_0_pos)/(gradient_1_pos-gradient_0_pos)), lerp(Color(gradient_1_r,gradient_1_g,gradient_1_b,gradient_1_a), Color(gradient_2_r,gradient_2_g,gradient_2_b,gradient_2_a), (x-gradient_1_pos)/(gradient_2_pos-gradient_1_pos)), 0.5+0.5*(x-gradient_1_pos)/(gradient_2_pos-gradient_1_pos));
|
||||
#
|
||||
# return Color(gradient_2_r,gradient_2_g,gradient_2_b,gradient_2_a);
|
||||
|
||||
|
||||
|
||||
var p_o95415_repeat = 1.000000000;
|
||||
|
||||
var p_o95415_gradient_0_pos = 0.000000000;
|
||||
var p_o95415_gradient_0_r = 0.000000000;
|
||||
var p_o95415_gradient_0_g = 0.000000000;
|
||||
var p_o95415_gradient_0_b = 0.000000000;
|
||||
var p_o95415_gradient_0_a = 1.000000000;
|
||||
var p_o95415_gradient_1_pos = 0.490909091;
|
||||
var p_o95415_gradient_1_r = 1.000000000;
|
||||
var p_o95415_gradient_1_g = 0.000000000;
|
||||
var p_o95415_gradient_1_b = 0.000000000;
|
||||
var p_o95415_gradient_1_a = 1.000000000;
|
||||
var p_o95415_gradient_2_pos = 1.000000000;
|
||||
var p_o95415_gradient_2_r = 1.000000000;
|
||||
var p_o95415_gradient_2_g = 1.000000000;
|
||||
var p_o95415_gradient_2_b = 1.000000000;
|
||||
var p_o95415_gradient_2_a = 1.000000000;
|
||||
|
||||
|
||||
func gradient_type_1_orig(x : float) -> Color:
|
||||
if (x < 0.5*(p_o95415_gradient_0_pos+p_o95415_gradient_1_pos)):
|
||||
return Color(p_o95415_gradient_0_r,p_o95415_gradient_0_g,p_o95415_gradient_0_b,p_o95415_gradient_0_a);
|
||||
elif (x < 0.5*(p_o95415_gradient_1_pos+p_o95415_gradient_2_pos)):
|
||||
return Color(p_o95415_gradient_1_r,p_o95415_gradient_1_g,p_o95415_gradient_1_b,p_o95415_gradient_1_a);
|
||||
|
||||
return Color(p_o95415_gradient_2_r,p_o95415_gradient_2_g,p_o95415_gradient_2_b,p_o95415_gradient_2_a);
|
||||
|
||||
func gradient_type_2_orig(x : float) -> Color:
|
||||
if (x < p_o95415_gradient_0_pos):
|
||||
return Color(p_o95415_gradient_0_r,p_o95415_gradient_0_g,p_o95415_gradient_0_b,p_o95415_gradient_0_a);
|
||||
elif (x < p_o95415_gradient_1_pos):
|
||||
return lerp(Color(p_o95415_gradient_0_r,p_o95415_gradient_0_g,p_o95415_gradient_0_b,p_o95415_gradient_0_a), Color(p_o95415_gradient_1_r,p_o95415_gradient_1_g,p_o95415_gradient_1_b,p_o95415_gradient_1_a), ((x-p_o95415_gradient_0_pos)/(p_o95415_gradient_1_pos-p_o95415_gradient_0_pos)));
|
||||
elif (x < p_o95415_gradient_2_pos):
|
||||
return lerp(Color(p_o95415_gradient_1_r,p_o95415_gradient_1_g,p_o95415_gradient_1_b,p_o95415_gradient_1_a), Color(p_o95415_gradient_2_r,p_o95415_gradient_2_g,p_o95415_gradient_2_b,p_o95415_gradient_2_a), ((x-p_o95415_gradient_1_pos)/(p_o95415_gradient_2_pos-p_o95415_gradient_1_pos)));
|
||||
|
||||
return Color(p_o95415_gradient_2_r,p_o95415_gradient_2_g,p_o95415_gradient_2_b,p_o95415_gradient_2_a);
|
||||
|
||||
|
||||
func gradient_type_3_orig(x : float) -> Color:
|
||||
if (x < p_o95415_gradient_0_pos):
|
||||
return Color(p_o95415_gradient_0_r,p_o95415_gradient_0_g,p_o95415_gradient_0_b,p_o95415_gradient_0_a);
|
||||
elif (x < p_o95415_gradient_1_pos):
|
||||
return lerp(Color(p_o95415_gradient_0_r,p_o95415_gradient_0_g,p_o95415_gradient_0_b,p_o95415_gradient_0_a), Color(p_o95415_gradient_1_r,p_o95415_gradient_1_g,p_o95415_gradient_1_b,p_o95415_gradient_1_a), 0.5-0.5*cos(3.14159265359*(x-p_o95415_gradient_0_pos)/(p_o95415_gradient_1_pos-p_o95415_gradient_0_pos)));
|
||||
if (x < p_o95415_gradient_2_pos):
|
||||
return lerp(Color(p_o95415_gradient_1_r,p_o95415_gradient_1_g,p_o95415_gradient_1_b,p_o95415_gradient_1_a), Color(p_o95415_gradient_2_r,p_o95415_gradient_2_g,p_o95415_gradient_2_b,p_o95415_gradient_2_a), 0.5-0.5*cos(3.14159265359*(x-p_o95415_gradient_1_pos)/(p_o95415_gradient_2_pos-p_o95415_gradient_1_pos)));
|
||||
|
||||
return Color(p_o95415_gradient_2_r,p_o95415_gradient_2_g,p_o95415_gradient_2_b,p_o95415_gradient_2_a);
|
||||
|
||||
func gradient_type_4_orig(x : float) -> Color:
|
||||
if (x < p_o95415_gradient_0_pos):
|
||||
return Color(p_o95415_gradient_0_r,p_o95415_gradient_0_g,p_o95415_gradient_0_b,p_o95415_gradient_0_a);
|
||||
elif (x < p_o95415_gradient_1_pos):
|
||||
return lerp(lerp(Color(p_o95415_gradient_1_r,p_o95415_gradient_1_g,p_o95415_gradient_1_b,p_o95415_gradient_1_a), Color(p_o95415_gradient_2_r,p_o95415_gradient_2_g,p_o95415_gradient_2_b,p_o95415_gradient_2_a), (x-p_o95415_gradient_1_pos)/(p_o95415_gradient_2_pos-p_o95415_gradient_1_pos)), lerp(Color(p_o95415_gradient_0_r,p_o95415_gradient_0_g,p_o95415_gradient_0_b,p_o95415_gradient_0_a), Color(p_o95415_gradient_1_r,p_o95415_gradient_1_g,p_o95415_gradient_1_b,p_o95415_gradient_1_a), (x-p_o95415_gradient_0_pos)/(p_o95415_gradient_1_pos-p_o95415_gradient_0_pos)), 1.0-0.5*(x-p_o95415_gradient_0_pos)/(p_o95415_gradient_1_pos-p_o95415_gradient_0_pos));
|
||||
elif (x < p_o95415_gradient_2_pos):
|
||||
return lerp(lerp(Color(p_o95415_gradient_0_r,p_o95415_gradient_0_g,p_o95415_gradient_0_b,p_o95415_gradient_0_a), Color(p_o95415_gradient_1_r,p_o95415_gradient_1_g,p_o95415_gradient_1_b,p_o95415_gradient_1_a), (x-p_o95415_gradient_0_pos)/(p_o95415_gradient_1_pos-p_o95415_gradient_0_pos)), lerp(Color(p_o95415_gradient_1_r,p_o95415_gradient_1_g,p_o95415_gradient_1_b,p_o95415_gradient_1_a), Color(p_o95415_gradient_2_r,p_o95415_gradient_2_g,p_o95415_gradient_2_b,p_o95415_gradient_2_a), (x-p_o95415_gradient_1_pos)/(p_o95415_gradient_2_pos-p_o95415_gradient_1_pos)), 0.5+0.5*(x-p_o95415_gradient_1_pos)/(p_o95415_gradient_2_pos-p_o95415_gradient_1_pos));
|
||||
|
||||
return Color(p_o95415_gradient_2_r,p_o95415_gradient_2_g,p_o95415_gradient_2_b,p_o95415_gradient_2_a);
|
||||
|
||||
|
@ -84,10 +84,10 @@ func gen() -> void:
|
||||
#branchless fix for division by zero
|
||||
uv.y += 0.000001
|
||||
|
||||
# var col : Color = gradient_type_1(Commons.fractf(p_o95415_repeat * 0.15915494309 * atan((uv.x - 0.5) / (uv.y - 0.5))));
|
||||
# var col : Color = gradient_type_2(Commons.fractf(p_o95415_repeat * 0.15915494309 * atan((uv.x - 0.5) / (uv.y - 0.5))));
|
||||
# var col : Color = gradient_type_3(Commons.fractf(p_o95415_repeat * 0.15915494309 * atan((uv.x - 0.5) / (uv.y - 0.5))));
|
||||
# var col : Color = gradient_type_4(Commons.fractf(p_o95415_repeat * 0.15915494309 * atan((uv.x - 0.5) / uv.y - 0.5)));
|
||||
# var col : Color = Gradients.gradient_type_1_orig(Commons.fractf(p_o95415_repeat * 0.15915494309 * atan((uv.x - 0.5) / (uv.y - 0.5))));
|
||||
# var col : Color = Gradients.gradient_type_2_orig(Commons.fractf(p_o95415_repeat * 0.15915494309 * atan((uv.x - 0.5) / (uv.y - 0.5))));
|
||||
# var col : Color = Gradients.gradient_type_3_orig(Commons.fractf(p_o95415_repeat * 0.15915494309 * atan((uv.x - 0.5) / (uv.y - 0.5))));
|
||||
# var col : Color = Gradients.gradient_type_4_orig(Commons.fractf(p_o95415_repeat * 0.15915494309 * atan((uv.x - 0.5) / uv.y - 0.5)));
|
||||
var col : Color = Gradients.circular_gradient_type_1(uv, p_o95415_repeat, data);
|
||||
|
||||
image.set_pixel(x, y, col)
|
||||
@ -97,47 +97,6 @@ func gen() -> void:
|
||||
tex.create_from_image(image)
|
||||
texture = tex
|
||||
|
||||
|
||||
func gradient_type_1(x : float) -> Color:
|
||||
if (x < 0.5*(p_o95415_gradient_0_pos+p_o95415_gradient_1_pos)):
|
||||
return Color(p_o95415_gradient_0_r,p_o95415_gradient_0_g,p_o95415_gradient_0_b,p_o95415_gradient_0_a);
|
||||
elif (x < 0.5*(p_o95415_gradient_1_pos+p_o95415_gradient_2_pos)):
|
||||
return Color(p_o95415_gradient_1_r,p_o95415_gradient_1_g,p_o95415_gradient_1_b,p_o95415_gradient_1_a);
|
||||
|
||||
return Color(p_o95415_gradient_2_r,p_o95415_gradient_2_g,p_o95415_gradient_2_b,p_o95415_gradient_2_a);
|
||||
|
||||
func gradient_type_2(x : float) -> Color:
|
||||
if (x < p_o95415_gradient_0_pos):
|
||||
return Color(p_o95415_gradient_0_r,p_o95415_gradient_0_g,p_o95415_gradient_0_b,p_o95415_gradient_0_a);
|
||||
elif (x < p_o95415_gradient_1_pos):
|
||||
return lerp(Color(p_o95415_gradient_0_r,p_o95415_gradient_0_g,p_o95415_gradient_0_b,p_o95415_gradient_0_a), Color(p_o95415_gradient_1_r,p_o95415_gradient_1_g,p_o95415_gradient_1_b,p_o95415_gradient_1_a), ((x-p_o95415_gradient_0_pos)/(p_o95415_gradient_1_pos-p_o95415_gradient_0_pos)));
|
||||
elif (x < p_o95415_gradient_2_pos):
|
||||
return lerp(Color(p_o95415_gradient_1_r,p_o95415_gradient_1_g,p_o95415_gradient_1_b,p_o95415_gradient_1_a), Color(p_o95415_gradient_2_r,p_o95415_gradient_2_g,p_o95415_gradient_2_b,p_o95415_gradient_2_a), ((x-p_o95415_gradient_1_pos)/(p_o95415_gradient_2_pos-p_o95415_gradient_1_pos)));
|
||||
|
||||
return Color(p_o95415_gradient_2_r,p_o95415_gradient_2_g,p_o95415_gradient_2_b,p_o95415_gradient_2_a);
|
||||
|
||||
|
||||
func gradient_type_3(x : float) -> Color:
|
||||
if (x < p_o95415_gradient_0_pos):
|
||||
return Color(p_o95415_gradient_0_r,p_o95415_gradient_0_g,p_o95415_gradient_0_b,p_o95415_gradient_0_a);
|
||||
elif (x < p_o95415_gradient_1_pos):
|
||||
return lerp(Color(p_o95415_gradient_0_r,p_o95415_gradient_0_g,p_o95415_gradient_0_b,p_o95415_gradient_0_a), Color(p_o95415_gradient_1_r,p_o95415_gradient_1_g,p_o95415_gradient_1_b,p_o95415_gradient_1_a), 0.5-0.5*cos(3.14159265359*(x-p_o95415_gradient_0_pos)/(p_o95415_gradient_1_pos-p_o95415_gradient_0_pos)));
|
||||
if (x < p_o95415_gradient_2_pos):
|
||||
return lerp(Color(p_o95415_gradient_1_r,p_o95415_gradient_1_g,p_o95415_gradient_1_b,p_o95415_gradient_1_a), Color(p_o95415_gradient_2_r,p_o95415_gradient_2_g,p_o95415_gradient_2_b,p_o95415_gradient_2_a), 0.5-0.5*cos(3.14159265359*(x-p_o95415_gradient_1_pos)/(p_o95415_gradient_2_pos-p_o95415_gradient_1_pos)));
|
||||
|
||||
return Color(p_o95415_gradient_2_r,p_o95415_gradient_2_g,p_o95415_gradient_2_b,p_o95415_gradient_2_a);
|
||||
|
||||
func gradient_type_4(x : float) -> Color:
|
||||
if (x < p_o95415_gradient_0_pos):
|
||||
return Color(p_o95415_gradient_0_r,p_o95415_gradient_0_g,p_o95415_gradient_0_b,p_o95415_gradient_0_a);
|
||||
elif (x < p_o95415_gradient_1_pos):
|
||||
return lerp(lerp(Color(p_o95415_gradient_1_r,p_o95415_gradient_1_g,p_o95415_gradient_1_b,p_o95415_gradient_1_a), Color(p_o95415_gradient_2_r,p_o95415_gradient_2_g,p_o95415_gradient_2_b,p_o95415_gradient_2_a), (x-p_o95415_gradient_1_pos)/(p_o95415_gradient_2_pos-p_o95415_gradient_1_pos)), lerp(Color(p_o95415_gradient_0_r,p_o95415_gradient_0_g,p_o95415_gradient_0_b,p_o95415_gradient_0_a), Color(p_o95415_gradient_1_r,p_o95415_gradient_1_g,p_o95415_gradient_1_b,p_o95415_gradient_1_a), (x-p_o95415_gradient_0_pos)/(p_o95415_gradient_1_pos-p_o95415_gradient_0_pos)), 1.0-0.5*(x-p_o95415_gradient_0_pos)/(p_o95415_gradient_1_pos-p_o95415_gradient_0_pos));
|
||||
elif (x < p_o95415_gradient_2_pos):
|
||||
return lerp(lerp(Color(p_o95415_gradient_0_r,p_o95415_gradient_0_g,p_o95415_gradient_0_b,p_o95415_gradient_0_a), Color(p_o95415_gradient_1_r,p_o95415_gradient_1_g,p_o95415_gradient_1_b,p_o95415_gradient_1_a), (x-p_o95415_gradient_0_pos)/(p_o95415_gradient_1_pos-p_o95415_gradient_0_pos)), lerp(Color(p_o95415_gradient_1_r,p_o95415_gradient_1_g,p_o95415_gradient_1_b,p_o95415_gradient_1_a), Color(p_o95415_gradient_2_r,p_o95415_gradient_2_g,p_o95415_gradient_2_b,p_o95415_gradient_2_a), (x-p_o95415_gradient_1_pos)/(p_o95415_gradient_2_pos-p_o95415_gradient_1_pos)), 0.5+0.5*(x-p_o95415_gradient_1_pos)/(p_o95415_gradient_2_pos-p_o95415_gradient_1_pos));
|
||||
|
||||
return Color(p_o95415_gradient_2_r,p_o95415_gradient_2_g,p_o95415_gradient_2_b,p_o95415_gradient_2_a);
|
||||
|
||||
|
||||
func reffg():
|
||||
return false
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
tool
|
||||
extends TextureRect
|
||||
|
||||
var Gradients = preload("res://addons/mat_maker_gd/nodes/common/gradients.gd")
|
||||
var Commons = preload("res://addons/mat_maker_gd/nodes/common/commons.gd")
|
||||
|
||||
var image : Image
|
||||
@ -51,6 +52,27 @@ func gen() -> void:
|
||||
# var bmin : Vector2 = Vector2(0.1, 0.1)
|
||||
# var bmax : Vector2 = Vector2(1, 1)
|
||||
|
||||
var data : PoolRealArray = PoolRealArray()
|
||||
data.resize(15)
|
||||
var i : int = 0
|
||||
data[i + 0] = p_o71406_gradient_0_pos
|
||||
data[i + 1] = p_o71406_gradient_0_r
|
||||
data[i + 2] = p_o71406_gradient_0_g
|
||||
data[i + 3] = p_o71406_gradient_0_b
|
||||
data[i + 4] = p_o71406_gradient_0_a
|
||||
i += 5
|
||||
data[i + 0] = p_o71406_gradient_1_pos
|
||||
data[i + 1] = p_o71406_gradient_1_r
|
||||
data[i + 2] = p_o71406_gradient_1_g
|
||||
data[i + 3] = p_o71406_gradient_1_b
|
||||
data[i + 4] = p_o71406_gradient_1_a
|
||||
i += 5
|
||||
data[i + 0] = p_o71406_gradient_2_pos
|
||||
data[i + 1] = p_o71406_gradient_2_r
|
||||
data[i + 2] = p_o71406_gradient_2_g
|
||||
data[i + 3] = p_o71406_gradient_2_b
|
||||
data[i + 4] = p_o71406_gradient_2_a
|
||||
|
||||
image.lock()
|
||||
|
||||
var w : float = image.get_width()
|
||||
@ -60,7 +82,7 @@ func gen() -> void:
|
||||
|
||||
for x in range(image.get_width()):
|
||||
for y in range(image.get_height()):
|
||||
var v : Vector2 = Vector2(x / w, y / h)
|
||||
var uv : Vector2 = Vector2(x / w, y / h)
|
||||
|
||||
# var rr : float = 0.5+(cos(p_o71406_rotate*0.01745329251)*(v.x-0.5)+sin(p_o71406_rotate*0.01745329251)*(v.y-0.5))/(cos(abs(modf(p_o71406_rotate, 90.0)-45.0)*0.01745329251)*1.41421356237);
|
||||
# var col : Color = gradient_type_1(fractf(rr * p_o71406_repeat));
|
||||
@ -71,8 +93,10 @@ func gen() -> void:
|
||||
# var rr : float = 0.5+(cos(p_o71406_rotate*0.01745329251)*(v.x-0.5)+sin(p_o71406_rotate*0.01745329251)*(v.y-0.5))/(cos(abs(modf(p_o71406_rotate, 90.0)-45.0)*0.01745329251)*1.41421356237);
|
||||
# var col : Color = gradient_type_3(fractf(rr * p_o71406_repeat))
|
||||
|
||||
var rr : float = 0.5+(cos(p_o71406_rotate*0.01745329251)*(v.x-0.5)+sin(p_o71406_rotate*0.01745329251)*(v.y-0.5))/(cos(abs(Commons.modf(p_o71406_rotate, 90.0)-45.0)*0.01745329251)*1.41421356237);
|
||||
var col : Color = gradient_type_4(Commons.fractf(rr * p_o71406_repeat));
|
||||
# var rr : float = 0.5+(cos(p_o71406_rotate*0.01745329251)*(v.x-0.5)+sin(p_o71406_rotate*0.01745329251)*(v.y-0.5))/(cos(abs(Commons.modf(p_o71406_rotate, 90.0)-45.0)*0.01745329251)*1.41421356237);
|
||||
# var col : Color = gradient_type_4(Commons.fractf(rr * p_o71406_repeat));
|
||||
|
||||
var col : Color = Gradients.normal_gradient_type_1(uv, p_o28405_repeat, p_o28405_rotate, data);
|
||||
|
||||
image.set_pixel(x, y, col)
|
||||
|
||||
@ -81,45 +105,6 @@ func gen() -> void:
|
||||
tex.create_from_image(image)
|
||||
texture = tex
|
||||
|
||||
func gradient_type_1(x : float) -> Color:
|
||||
if (x < 0.5*(p_o71406_gradient_0_pos+p_o71406_gradient_1_pos)):
|
||||
return Color(p_o71406_gradient_0_r,p_o71406_gradient_0_g,p_o71406_gradient_0_b,p_o71406_gradient_0_a);
|
||||
elif (x < 0.5*(p_o71406_gradient_1_pos+p_o71406_gradient_2_pos)):
|
||||
return Color(p_o71406_gradient_1_r,p_o71406_gradient_1_g,p_o71406_gradient_1_b,p_o71406_gradient_1_a);
|
||||
|
||||
return Color(p_o71406_gradient_2_r,p_o71406_gradient_2_g,p_o71406_gradient_2_b,p_o71406_gradient_2_a);
|
||||
|
||||
func gradient_type_2(x : float) -> Color:
|
||||
if (x < p_o71406_gradient_0_pos):
|
||||
return Color(p_o71406_gradient_0_r,p_o71406_gradient_0_g,p_o71406_gradient_0_b,p_o71406_gradient_0_a);
|
||||
elif (x < p_o71406_gradient_1_pos):
|
||||
return lerp(Color(p_o71406_gradient_0_r,p_o71406_gradient_0_g,p_o71406_gradient_0_b,p_o71406_gradient_0_a), Color(p_o71406_gradient_1_r,p_o71406_gradient_1_g,p_o71406_gradient_1_b,p_o71406_gradient_1_a), ((x-p_o71406_gradient_0_pos)/(p_o71406_gradient_1_pos-p_o71406_gradient_0_pos)));
|
||||
elif (x < p_o71406_gradient_2_pos):
|
||||
return lerp(Color(p_o71406_gradient_1_r,p_o71406_gradient_1_g,p_o71406_gradient_1_b,p_o71406_gradient_1_a), Color(p_o71406_gradient_2_r,p_o71406_gradient_2_g,p_o71406_gradient_2_b,p_o71406_gradient_2_a), ((x-p_o71406_gradient_1_pos)/(p_o71406_gradient_2_pos-p_o71406_gradient_1_pos)));
|
||||
|
||||
return Color(p_o71406_gradient_2_r,p_o71406_gradient_2_g,p_o71406_gradient_2_b,p_o71406_gradient_2_a);
|
||||
|
||||
func gradient_type_3(x : float) -> Color:
|
||||
if (x < p_o71406_gradient_0_pos):
|
||||
return Color(p_o71406_gradient_0_r,p_o71406_gradient_0_g,p_o71406_gradient_0_b,p_o71406_gradient_0_a);
|
||||
elif (x < p_o71406_gradient_1_pos):
|
||||
return lerp(Color(p_o71406_gradient_0_r,p_o71406_gradient_0_g,p_o71406_gradient_0_b,p_o71406_gradient_0_a), Color(p_o71406_gradient_1_r,p_o71406_gradient_1_g,p_o71406_gradient_1_b,p_o71406_gradient_1_a), 0.5-0.5*cos(3.14159265359*(x-p_o71406_gradient_0_pos)/(p_o71406_gradient_1_pos-p_o71406_gradient_0_pos)));
|
||||
elif (x < p_o71406_gradient_2_pos):
|
||||
return lerp(Color(p_o71406_gradient_1_r,p_o71406_gradient_1_g,p_o71406_gradient_1_b,p_o71406_gradient_1_a), Color(p_o71406_gradient_2_r,p_o71406_gradient_2_g,p_o71406_gradient_2_b,p_o71406_gradient_2_a), 0.5-0.5*cos(3.14159265359*(x-p_o71406_gradient_1_pos)/(p_o71406_gradient_2_pos-p_o71406_gradient_1_pos)));
|
||||
|
||||
return Color(p_o71406_gradient_2_r,p_o71406_gradient_2_g,p_o71406_gradient_2_b,p_o71406_gradient_2_a);
|
||||
|
||||
|
||||
func gradient_type_4(x : float) -> Color:
|
||||
if (x < p_o71406_gradient_0_pos):
|
||||
return Color(p_o71406_gradient_0_r,p_o71406_gradient_0_g,p_o71406_gradient_0_b,p_o71406_gradient_0_a);
|
||||
elif (x < p_o71406_gradient_1_pos):
|
||||
return lerp(lerp(Color(p_o71406_gradient_1_r,p_o71406_gradient_1_g,p_o71406_gradient_1_b,p_o71406_gradient_1_a), Color(p_o71406_gradient_2_r,p_o71406_gradient_2_g,p_o71406_gradient_2_b,p_o71406_gradient_2_a), (x-p_o71406_gradient_1_pos)/(p_o71406_gradient_2_pos-p_o71406_gradient_1_pos)), lerp(Color(p_o71406_gradient_0_r,p_o71406_gradient_0_g,p_o71406_gradient_0_b,p_o71406_gradient_0_a), Color(p_o71406_gradient_1_r,p_o71406_gradient_1_g,p_o71406_gradient_1_b,p_o71406_gradient_1_a), (x-p_o71406_gradient_0_pos)/(p_o71406_gradient_1_pos-p_o71406_gradient_0_pos)), 1.0-0.5*(x-p_o71406_gradient_0_pos)/(p_o71406_gradient_1_pos-p_o71406_gradient_0_pos));
|
||||
elif (x < p_o71406_gradient_2_pos):
|
||||
return lerp(lerp(Color(p_o71406_gradient_0_r,p_o71406_gradient_0_g,p_o71406_gradient_0_b,p_o71406_gradient_0_a), Color(p_o71406_gradient_1_r,p_o71406_gradient_1_g,p_o71406_gradient_1_b,p_o71406_gradient_1_a), (x-p_o71406_gradient_0_pos)/(p_o71406_gradient_1_pos-p_o71406_gradient_0_pos)), lerp(Color(p_o71406_gradient_1_r,p_o71406_gradient_1_g,p_o71406_gradient_1_b,p_o71406_gradient_1_a), Color(p_o71406_gradient_2_r,p_o71406_gradient_2_g,p_o71406_gradient_2_b,p_o71406_gradient_2_a), (x-p_o71406_gradient_1_pos)/(p_o71406_gradient_2_pos-p_o71406_gradient_1_pos)), 0.5+0.5*(x-p_o71406_gradient_1_pos)/(p_o71406_gradient_2_pos-p_o71406_gradient_1_pos));
|
||||
|
||||
return Color(p_o71406_gradient_2_r,p_o71406_gradient_2_g,p_o71406_gradient_2_b,p_o71406_gradient_2_a);
|
||||
|
||||
func reffg():
|
||||
return false
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
tool
|
||||
extends TextureRect
|
||||
|
||||
var Gradients = preload("res://addons/mat_maker_gd/nodes/common/gradients.gd")
|
||||
var Commons = preload("res://addons/mat_maker_gd/nodes/common/commons.gd")
|
||||
|
||||
var image : Image
|
||||
@ -22,7 +23,6 @@ var p_o28405_repeat : float = 1.000000000;
|
||||
var p_o28405_rotate : float = 0.000000000;
|
||||
|
||||
|
||||
|
||||
var p_o24141_gradient_0_pos = 0.000000000;
|
||||
var p_o24141_gradient_0_r = 0.000000000;
|
||||
var p_o24141_gradient_0_g = 0.000000000;
|
||||
@ -39,8 +39,6 @@ var p_o24141_gradient_2_g = 1.000000000;
|
||||
var p_o24141_gradient_2_b = 1.000000000;
|
||||
var p_o24141_gradient_2_a = 1.000000000;
|
||||
|
||||
|
||||
|
||||
func gen() -> void:
|
||||
if !image:
|
||||
image = Image.new()
|
||||
@ -52,6 +50,27 @@ func gen() -> void:
|
||||
# var bmin : Vector2 = Vector2(0.1, 0.1)
|
||||
# var bmax : Vector2 = Vector2(1, 1)
|
||||
|
||||
var data : PoolRealArray = PoolRealArray()
|
||||
data.resize(15)
|
||||
var i : int = 0
|
||||
data[i + 0] = p_o24141_gradient_0_pos
|
||||
data[i + 1] = p_o24141_gradient_0_r
|
||||
data[i + 2] = p_o24141_gradient_0_g
|
||||
data[i + 3] = p_o24141_gradient_0_b
|
||||
data[i + 4] = p_o24141_gradient_0_a
|
||||
i += 5
|
||||
data[i + 0] = p_o24141_gradient_1_pos
|
||||
data[i + 1] = p_o24141_gradient_1_r
|
||||
data[i + 2] = p_o24141_gradient_1_g
|
||||
data[i + 3] = p_o24141_gradient_1_b
|
||||
data[i + 4] = p_o24141_gradient_1_a
|
||||
i += 5
|
||||
data[i + 0] = p_o24141_gradient_2_pos
|
||||
data[i + 1] = p_o24141_gradient_2_r
|
||||
data[i + 2] = p_o24141_gradient_2_g
|
||||
data[i + 3] = p_o24141_gradient_2_b
|
||||
data[i + 4] = p_o24141_gradient_2_a
|
||||
|
||||
image.lock()
|
||||
|
||||
var w : float = image.get_width()
|
||||
@ -61,16 +80,17 @@ func gen() -> void:
|
||||
|
||||
for x in range(image.get_width()):
|
||||
for y in range(image.get_height()):
|
||||
var v : Vector2 = Vector2(x / w, y / h)
|
||||
var uv : Vector2 = Vector2(x / w, y / h)
|
||||
|
||||
# vec4 o24141_0_1_rgba = o24141_gradient_gradient_fct(fract(p_o24141_repeat*1.41421356237*length(fract(((uv)))-vec2(0.5, 0.5))));
|
||||
# vec3 o3335_0_1_rgb = ((o24141_0_1_rgba).rgb);
|
||||
#
|
||||
|
||||
# var col : Color = radial_gradient_type_1(fractf(p_o28405_repeat*1.41421356237* (fract(v)- Vector2(0.5, 0.5)).length()))
|
||||
# var col : Color = radial_gradient_type_2(fractf(p_o28405_repeat*1.41421356237* (fract(v)- Vector2(0.5, 0.5)).length()))
|
||||
# var col : Color = radial_gradient_type_3(fractf(p_o28405_repeat*1.41421356237* (fract(v)- Vector2(0.5, 0.5)).length()))
|
||||
var col : Color = radial_gradient_type_4(Commons.fractf(p_o28405_repeat*1.41421356237* (Commons.fract(v)- Vector2(0.5, 0.5)).length()))
|
||||
# var col : Color = radial_gradient_type_1(fractf(p_o28405_repeat*1.41421356237* (fract(uv)- Vector2(0.5, 0.5)).length()))
|
||||
# var col : Color = radial_gradient_type_2(fractf(p_o28405_repeat*1.41421356237* (fract(uv)- Vector2(0.5, 0.5)).length()))
|
||||
# var col : Color = radial_gradient_type_3(fractf(p_o28405_repeat*1.41421356237* (fract(uv)- Vector2(0.5, 0.5)).length()))
|
||||
# var col : Color = radial_gradient_type_4(Commons.fractf(p_o28405_repeat*1.41421356237* (Commons.fract(uv)- Vector2(0.5, 0.5)).length()))
|
||||
var col : Color = Gradients.radial_gradient_type_1(uv, p_o28405_repeat, data);
|
||||
|
||||
image.set_pixel(x, y, col)
|
||||
|
||||
@ -79,46 +99,6 @@ func gen() -> void:
|
||||
tex.create_from_image(image)
|
||||
texture = tex
|
||||
|
||||
func radial_gradient_type_1(x : float) -> Color:
|
||||
if (x < 0.5*(p_o24141_gradient_0_pos+p_o24141_gradient_1_pos)):
|
||||
return Color(p_o24141_gradient_0_r,p_o24141_gradient_0_g,p_o24141_gradient_0_b,p_o24141_gradient_0_a);
|
||||
elif (x < 0.5*(p_o24141_gradient_1_pos+p_o24141_gradient_2_pos)):
|
||||
return Color(p_o24141_gradient_1_r,p_o24141_gradient_1_g,p_o24141_gradient_1_b,p_o24141_gradient_1_a);
|
||||
|
||||
return Color(p_o24141_gradient_2_r,p_o24141_gradient_2_g,p_o24141_gradient_2_b,p_o24141_gradient_2_a);
|
||||
|
||||
|
||||
func radial_gradient_type_2(x : float) -> Color:
|
||||
if (x < p_o24141_gradient_0_pos):
|
||||
return Color(p_o24141_gradient_0_r,p_o24141_gradient_0_g,p_o24141_gradient_0_b,p_o24141_gradient_0_a);
|
||||
elif (x < p_o24141_gradient_1_pos):
|
||||
return lerp(Color(p_o24141_gradient_0_r,p_o24141_gradient_0_g,p_o24141_gradient_0_b,p_o24141_gradient_0_a), Color(p_o24141_gradient_1_r,p_o24141_gradient_1_g,p_o24141_gradient_1_b,p_o24141_gradient_1_a), ((x-p_o24141_gradient_0_pos)/(p_o24141_gradient_1_pos-p_o24141_gradient_0_pos)));
|
||||
elif (x < p_o24141_gradient_2_pos):
|
||||
return lerp(Color(p_o24141_gradient_1_r,p_o24141_gradient_1_g,p_o24141_gradient_1_b,p_o24141_gradient_1_a), Color(p_o24141_gradient_2_r,p_o24141_gradient_2_g,p_o24141_gradient_2_b,p_o24141_gradient_2_a), ((x-p_o24141_gradient_1_pos)/(p_o24141_gradient_2_pos-p_o24141_gradient_1_pos)));
|
||||
|
||||
return Color(p_o24141_gradient_2_r,p_o24141_gradient_2_g,p_o24141_gradient_2_b,p_o24141_gradient_2_a);
|
||||
|
||||
func radial_gradient_type_3(x : float) -> Color:
|
||||
if (x < p_o24141_gradient_0_pos):
|
||||
return Color(p_o24141_gradient_0_r,p_o24141_gradient_0_g,p_o24141_gradient_0_b,p_o24141_gradient_0_a);
|
||||
elif (x < p_o24141_gradient_1_pos):
|
||||
return lerp(Color(p_o24141_gradient_0_r,p_o24141_gradient_0_g,p_o24141_gradient_0_b,p_o24141_gradient_0_a), Color(p_o24141_gradient_1_r,p_o24141_gradient_1_g,p_o24141_gradient_1_b,p_o24141_gradient_1_a), 0.5-0.5*cos(3.14159265359*(x-p_o24141_gradient_0_pos)/(p_o24141_gradient_1_pos-p_o24141_gradient_0_pos)));
|
||||
elif (x < p_o24141_gradient_2_pos):
|
||||
return lerp(Color(p_o24141_gradient_1_r,p_o24141_gradient_1_g,p_o24141_gradient_1_b,p_o24141_gradient_1_a), Color(p_o24141_gradient_2_r,p_o24141_gradient_2_g,p_o24141_gradient_2_b,p_o24141_gradient_2_a), 0.5-0.5*cos(3.14159265359*(x-p_o24141_gradient_1_pos)/(p_o24141_gradient_2_pos-p_o24141_gradient_1_pos)));
|
||||
|
||||
return Color(p_o24141_gradient_2_r,p_o24141_gradient_2_g,p_o24141_gradient_2_b,p_o24141_gradient_2_a);
|
||||
|
||||
func radial_gradient_type_4(x : float) -> Color:
|
||||
if (x < p_o24141_gradient_0_pos):
|
||||
return Color(p_o24141_gradient_0_r,p_o24141_gradient_0_g,p_o24141_gradient_0_b,p_o24141_gradient_0_a);
|
||||
elif (x < p_o24141_gradient_1_pos):
|
||||
return lerp(lerp(Color(p_o24141_gradient_1_r,p_o24141_gradient_1_g,p_o24141_gradient_1_b,p_o24141_gradient_1_a), Color(p_o24141_gradient_2_r,p_o24141_gradient_2_g,p_o24141_gradient_2_b,p_o24141_gradient_2_a), (x-p_o24141_gradient_1_pos)/(p_o24141_gradient_2_pos-p_o24141_gradient_1_pos)), lerp(Color(p_o24141_gradient_0_r,p_o24141_gradient_0_g,p_o24141_gradient_0_b,p_o24141_gradient_0_a), Color(p_o24141_gradient_1_r,p_o24141_gradient_1_g,p_o24141_gradient_1_b,p_o24141_gradient_1_a), (x-p_o24141_gradient_0_pos)/(p_o24141_gradient_1_pos-p_o24141_gradient_0_pos)), 1.0-0.5*(x-p_o24141_gradient_0_pos)/(p_o24141_gradient_1_pos-p_o24141_gradient_0_pos));
|
||||
elif (x < p_o24141_gradient_2_pos):
|
||||
return lerp(lerp(Color(p_o24141_gradient_0_r,p_o24141_gradient_0_g,p_o24141_gradient_0_b,p_o24141_gradient_0_a), Color(p_o24141_gradient_1_r,p_o24141_gradient_1_g,p_o24141_gradient_1_b,p_o24141_gradient_1_a), (x-p_o24141_gradient_0_pos)/(p_o24141_gradient_1_pos-p_o24141_gradient_0_pos)), lerp(Color(p_o24141_gradient_1_r,p_o24141_gradient_1_g,p_o24141_gradient_1_b,p_o24141_gradient_1_a), Color(p_o24141_gradient_2_r,p_o24141_gradient_2_g,p_o24141_gradient_2_b,p_o24141_gradient_2_a), (x-p_o24141_gradient_1_pos)/(p_o24141_gradient_2_pos-p_o24141_gradient_1_pos)), 0.5+0.5*(x-p_o24141_gradient_1_pos)/(p_o24141_gradient_2_pos-p_o24141_gradient_1_pos));
|
||||
|
||||
return Color(p_o24141_gradient_2_r,p_o24141_gradient_2_g,p_o24141_gradient_2_b,p_o24141_gradient_2_a);
|
||||
|
||||
|
||||
func reffg():
|
||||
return false
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user