mirror of
https://github.com/Relintai/broken_seals.git
synced 2025-01-18 14:07:17 +01:00
Lots of work on gradient_type_4. It doesn't work properly yet, however the current implementation produces a cyberpunk-ish neon like effect, so I also saved it as gradient_type_5 for the time being.
This commit is contained in:
parent
56aa47ccc3
commit
01bb81675e
@ -1,4 +1,4 @@
|
||||
[gd_resource type="Resource" load_steps=22 format=2]
|
||||
[gd_resource type="Resource" load_steps=25 format=2]
|
||||
|
||||
[ext_resource path="res://addons/mat_maker_gd/nodes/mm_material.gd" type="Script" id=1]
|
||||
[ext_resource path="res://addons/mat_maker_gd/nodes/noise/perlin.gd" type="Script" id=2]
|
||||
@ -7,6 +7,7 @@
|
||||
[ext_resource path="res://addons/mat_maker_gd/nodes/mm_node_universal_property.gd" type="Script" id=5]
|
||||
[ext_resource path="res://addons/mat_maker_gd/nodes/other/output_image.gd" type="Script" id=6]
|
||||
[ext_resource path="res://addons/mat_maker_gd/nodes/gradient/gradient.gd" type="Script" id=7]
|
||||
[ext_resource path="res://addons/mat_maker_gd/nodes/gradient/radial_gradient.gd" type="Script" id=8]
|
||||
|
||||
[sub_resource type="Resource" id=1]
|
||||
script = ExtResource( 2 )
|
||||
@ -17,7 +18,7 @@ persistence = 0.5
|
||||
|
||||
[sub_resource type="Resource" id=2]
|
||||
script = ExtResource( 3 )
|
||||
graph_position = Vector2( 140, 0 )
|
||||
graph_position = Vector2( 440, 20 )
|
||||
bmin = Vector2( 0.1, 0.1 )
|
||||
bmax = Vector2( 1, 1 )
|
||||
refresh = false
|
||||
@ -68,7 +69,7 @@ sides = 11
|
||||
radius = SubResource( 4 )
|
||||
edge = SubResource( 3 )
|
||||
|
||||
[sub_resource type="Resource" id=13]
|
||||
[sub_resource type="Resource" id=16]
|
||||
script = ExtResource( 5 )
|
||||
default_type = 5
|
||||
default_int = 0
|
||||
@ -80,7 +81,7 @@ default_color = Color( 0, 0, 0, 1 )
|
||||
[sub_resource type="Resource" id=6]
|
||||
script = ExtResource( 6 )
|
||||
graph_position = Vector2( -20, -320 )
|
||||
image = SubResource( 13 )
|
||||
image = SubResource( 16 )
|
||||
postfix = "-test"
|
||||
|
||||
[sub_resource type="Resource" id=9]
|
||||
@ -122,13 +123,30 @@ default_color = Color( 0, 0, 0, 1 )
|
||||
[sub_resource type="Resource" id=15]
|
||||
script = ExtResource( 7 )
|
||||
graph_position = Vector2( -300, 120 )
|
||||
interpolation_type = 2
|
||||
points = PoolRealArray( 0, 0.376471, 0.239216, 0.713726, 1, 0.254237, 0.484375, 0.198669, 0.198669, 1, 0.762712, 1, 1, 1, 1, 1, 0.263715, 0.585938, 0.100708, 1 )
|
||||
image = SubResource( 14 )
|
||||
repeat = 1.0
|
||||
rotate = 0.0
|
||||
interpolation_type = 1
|
||||
points = PoolRealArray( 0, 0.376471, 0.239216, 0.713726, 1, 0.330508, 0.484375, 0.198669, 0.198669, 1, 0.644068, 1, 1, 1, 1, 1, 0.263715, 0.585938, 0.100708, 1 )
|
||||
|
||||
[sub_resource type="Resource" id=17]
|
||||
script = ExtResource( 5 )
|
||||
default_type = 5
|
||||
default_int = 0
|
||||
default_float = 0.0
|
||||
default_vector2 = Vector2( 0, 0 )
|
||||
default_vector3 = Vector3( 0, 0, 0 )
|
||||
default_color = Color( 0, 0, 0, 1 )
|
||||
|
||||
[sub_resource type="Resource" id=18]
|
||||
script = ExtResource( 8 )
|
||||
graph_position = Vector2( 0, 120 )
|
||||
interpolation_type = 3
|
||||
points = PoolRealArray( 0, 0.121124, 0.574219, 0.19192, 1, 0.262712, 0.976562, 0, 0, 1, 0.661017, 0.172241, 0, 0.648438, 1, 1, 0.195312, 0.0389099, 0.159878, 1 )
|
||||
image = SubResource( 17 )
|
||||
repeat = 1.0
|
||||
|
||||
[resource]
|
||||
script = ExtResource( 1 )
|
||||
image_size = Vector2( 128, 128 )
|
||||
nodes = [ SubResource( 1 ), SubResource( 2 ), SubResource( 5 ), SubResource( 6 ), SubResource( 12 ), SubResource( 15 ) ]
|
||||
nodes = [ SubResource( 1 ), SubResource( 2 ), SubResource( 5 ), SubResource( 6 ), SubResource( 12 ), SubResource( 15 ), SubResource( 18 ) ]
|
||||
|
@ -119,90 +119,107 @@ static func gradient_type_3(x : float, data : PoolRealArray) -> Color:
|
||||
var ds = data.size() - 5
|
||||
return Color(data[ds + 1], data[ds + 2], data[ds + 3], data[ds + 4])
|
||||
|
||||
#todo, logic is not yet finished
|
||||
static func get_data_color(index : int, data : PoolRealArray) -> Color:
|
||||
var i : int = index * 5
|
||||
|
||||
return Color(data[i + 1], data[i + 2],data[i + 3], data[i + 4])
|
||||
|
||||
static func get_data_pos(index : int, data : PoolRealArray) -> float:
|
||||
return data[index * 5]
|
||||
|
||||
static func gradient_type_4(x : float, data : PoolRealArray) -> Color:
|
||||
if data.size() % 5 != 0 || data.size() == 0:
|
||||
return Color()
|
||||
|
||||
for i in range(0, data.size(), 5):
|
||||
if x < data[i]:
|
||||
var ds : int = data.size() / 5
|
||||
var s : int = ds - 1
|
||||
|
||||
for i in range(0, s):
|
||||
if x < get_data_pos(i, data):
|
||||
if i == 0:
|
||||
return Color(data[i + 1], data[i + 2], data[i + 3], data[i + 4])
|
||||
return get_data_color(i, data)
|
||||
|
||||
var cprev : Color = Color(data[i - 4], data[i - 3], data[i - 2], data[i - 1])
|
||||
var ccurr : Color = Color(data[i + 1], data[i + 2], data[i + 3], data[i + 4])
|
||||
return lerp(cprev, ccurr, 0.5 - 0.5 * cos(3.14159265359 * ((x - data[i - 5]) / (data[i] - data[i - 5]))))
|
||||
# var dx : String = "(x-%s)/(%s-%s)" % [ pv(name, i), pv(name, i+1), pv(name, i) ]
|
||||
var dx : float = (x - get_data_pos(i, data))/(get_data_pos(i + 1, data) - get_data_pos(i, data))
|
||||
# var b : String = "mix(%s, %s, %s)" % [ pc(name, i), pc(name, i+1), dx ]
|
||||
var b : Color = lerp(get_data_color(i - 1, data), get_data_color(i - 1, data), dx)
|
||||
|
||||
var ds = data.size() - 5
|
||||
return Color(data[ds + 1], data[ds + 2], data[ds + 3], data[ds + 4])
|
||||
if i == 1:
|
||||
# var c : String = "mix(%s, %s, (x-%s)/(%s-%s))" % [ pc(name, i+1), pc(name, i+2), pv(name, i+1), pv(name, i+2), pv(name, i+1) ]
|
||||
var c : Color = lerp(get_data_color(i + 1, data), get_data_color(i + 2, data), (x - get_data_pos(i + 1, data))/(get_data_pos(i + 2, data) - get_data_pos(i + 1, data)))
|
||||
# shader += " return mix("+c+", "+b+", 1.0-0.5*"+dx+");\n"
|
||||
return lerp(c, b, 1.0 - 0.5 * dx)
|
||||
|
||||
# var a : String = "mix(%s, %s, (x-%s)/(%s-%s))" % [ pc(name, i-1), pc(name, i), pv(name, i-1), pv(name, i), pv(name, i-1) ]
|
||||
var a : Color = lerp(get_data_color(i - 1, data), get_data_color(i, data), (x - get_data_pos(i - 1, data)) / (get_data_pos(i, data) - get_data_pos(i - 1, data)))
|
||||
|
||||
# if (x < gradient_0_pos):
|
||||
# return Color(gradient_0_r,gradient_0_g,gradient_0_b,gradient_0_a);
|
||||
# elif (x < gradient_1_pos):
|
||||
# return lerp(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)), 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)), 1.0-0.5*(x-gradient_0_pos)/(gradient_1_pos-gradient_0_pos));
|
||||
# elif (x < gradient_2_pos):
|
||||
# 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);
|
||||
# if i < s-1:
|
||||
if i < s - 1:
|
||||
# var c : String = "mix(%s, %s, (x-%s)/(%s-%s))" % [ pc(name, i+1), pc(name, i+2), pv(name, i+1), pv(name, i+2), pv(name, i+1) ]
|
||||
var c : Color = lerp(get_data_color(i + 1, data), get_data_color(i + 2, data), (x - get_data_pos(i + 1, data)) / (get_data_pos(i + 2, data) - get_data_pos(i + 1, data)))
|
||||
# var ac : String = "mix("+a+", "+c+", 0.5-0.5*cos(3.14159265359*"+dx+"))"
|
||||
var ac : Color = lerp(a, c, 0.5-0.5*cos(3.14159265359 * dx))
|
||||
# shader += " return 0.5*("+b+" + "+ac+");\n"
|
||||
var dt : Color = b + ac
|
||||
|
||||
dt.r *= 0.5
|
||||
dt.g *= 0.5
|
||||
dt.b *= 0.5
|
||||
dt.a = clamp(0, 1, dt.a)
|
||||
|
||||
return dt
|
||||
# else
|
||||
else:
|
||||
# shader += " return mix("+a+", "+b+", 0.5+0.5*"+dx+");\n"
|
||||
return lerp(a, b, 0.5 + 0.5 * dx)
|
||||
|
||||
var p_o95415_repeat = 1.000000000;
|
||||
return get_data_color(ds - 1, data)
|
||||
|
||||
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;
|
||||
#todo make it selectable
|
||||
static func gradient_type_5(x : float, data : PoolRealArray) -> Color:
|
||||
if data.size() % 5 != 0 || data.size() == 0:
|
||||
return Color()
|
||||
|
||||
var ds : int = data.size() / 5
|
||||
var s : int = ds - 1
|
||||
|
||||
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);
|
||||
for i in range(0, s):
|
||||
if x < get_data_pos(i, data):
|
||||
if i == 0:
|
||||
return get_data_color(i, data)
|
||||
|
||||
return Color(p_o95415_gradient_2_r,p_o95415_gradient_2_g,p_o95415_gradient_2_b,p_o95415_gradient_2_a);
|
||||
# var dx : String = "(x-%s)/(%s-%s)" % [ pv(name, i), pv(name, i+1), pv(name, i) ]
|
||||
var dx : float = (x - get_data_pos(i, data))/(get_data_pos(i + 1, data) - get_data_pos(i, data))
|
||||
# var b : String = "mix(%s, %s, %s)" % [ pc(name, i), pc(name, i+1), dx ]
|
||||
var b : Color = lerp(get_data_color(i - 1, data), get_data_color(i - 1, data), dx)
|
||||
|
||||
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)));
|
||||
if i == 1:
|
||||
# var c : String = "mix(%s, %s, (x-%s)/(%s-%s))" % [ pc(name, i+1), pc(name, i+2), pv(name, i+1), pv(name, i+2), pv(name, i+1) ]
|
||||
var c : Color = lerp(get_data_color(i + 1, data), get_data_color(i + 2, data), (x - get_data_pos(i + 1, data))/(get_data_pos(i + 2, data) - get_data_pos(i + 1, data)))
|
||||
# shader += " return mix("+c+", "+b+", 1.0-0.5*"+dx+");\n"
|
||||
return lerp(c, b, 1.0 - 0.5 * dx)
|
||||
|
||||
return Color(p_o95415_gradient_2_r,p_o95415_gradient_2_g,p_o95415_gradient_2_b,p_o95415_gradient_2_a);
|
||||
# var a : String = "mix(%s, %s, (x-%s)/(%s-%s))" % [ pc(name, i-1), pc(name, i), pv(name, i-1), pv(name, i), pv(name, i-1) ]
|
||||
var a : Color = lerp(get_data_color(i - 1, data), get_data_color(i, data), (x - get_data_pos(i - 1, data)) / (get_data_pos(i, data) - get_data_pos(i - 1, data)))
|
||||
|
||||
# if i < s-1:
|
||||
if i < s - 1:
|
||||
# var c : String = "mix(%s, %s, (x-%s)/(%s-%s))" % [ pc(name, i+1), pc(name, i+2), pv(name, i+1), pv(name, i+2), pv(name, i+1) ]
|
||||
var c : Color = lerp(get_data_color(i+1, data), get_data_color(i+2, data), (x - get_data_pos(i + 1, data)) / (get_data_pos(i + 2, data) - get_data_pos(i + 1, data)))
|
||||
# var ac : String = "mix("+a+", "+c+", 0.5-0.5*cos(3.14159265359*"+dx+"))"
|
||||
var ac : Color = lerp(a, c, 0.5-0.5*cos(3.14159265359 * dx))
|
||||
# shader += " return 0.5*("+b+" + "+ac+");\n"
|
||||
var dt : Color = b + ac
|
||||
|
||||
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)));
|
||||
dt.r *= 0.5
|
||||
dt.g *= 0.5
|
||||
dt.b *= 0.5
|
||||
dt.a = clamp(0, 1, dt.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_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);
|
||||
return dt
|
||||
# else
|
||||
else:
|
||||
# shader += " return mix("+a+", "+b+", 0.5+0.5*"+dx+");\n"
|
||||
return lerp(a, b, 0.5 + 0.5 * dx)
|
||||
|
||||
return get_data_color(ds - 1, data)
|
||||
|
Loading…
Reference in New Issue
Block a user