-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathimage_test_scene.tscn
165 lines (148 loc) · 4.71 KB
/
image_test_scene.tscn
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
[gd_scene load_steps=10 format=2]
[ext_resource path="res://assets/recolor shader.shader" type="Shader" id=1]
[ext_resource path="res://assets/RecolorShaderMasks.tres" type="Material" id=2]
[ext_resource path="res://assets/images/iconsgear/item_leather_chest_adv.png" type="Texture" id=3]
[ext_resource path="res://assets/images/iconsgear/ArmorBasicCloth.png" type="Texture" id=4]
[ext_resource path="res://assets/images/sprites/Erlen.png" type="Texture" id=5]
[ext_resource path="res://assets/book_shader.tres" type="Material" id=6]
[sub_resource type="Shader" id=1]
code = "shader_type canvas_item;
render_mode blend_mix;
uniform vec4 target1color : hint_color;
uniform vec4 target2color : hint_color;
uniform vec4 target3color : hint_color;
uniform float dist = 0.1;
uniform float lmod = 0.6;
vec3 rgb2hsl(vec3 c )
{
float epsilon = 0.00000001;
float cmin = min( c.r, min( c.g, c.b ) );
float cmax = max( c.r, max( c.g, c.b ) );
float cd = cmax - cmin;
vec3 hsl = vec3(0.0);
hsl.z = (cmax + cmin) / 2.0;
hsl.y = mix(cd / (cmax + cmin + epsilon), cd / (epsilon + 2.0 - (cmax + cmin)), step(0.5, hsl.z));
vec3 a = vec3(1.0 - step(epsilon, abs(cmax - c)));
a = mix(vec3(a.x, 0.0, a.z), a, step(0.5, 2.0 - a.x - a.y));
a = mix(vec3(a.x, a.y, 0.0), a, step(0.5, 2.0 - a.x - a.z));
a = mix(vec3(a.x, a.y, 0.0), a, step(0.5, 2.0 - a.y - a.z));
hsl.x = dot( vec3(0.0, 2.0, 4.0) + ((c.gbr - c.brg) / (epsilon + cd)), a );
hsl.x = (hsl.x + (1.0 - step(0.0, hsl.x) ) * 6.0 ) / 6.0;
hsl.y = clamp (hsl.y, 0.0, 1.0);
return hsl;
}
vec3 hsl2rgb(vec3 HSL)
{
float R = abs(HSL.x * 6.0 - 3.0) - 1.0;
float G = 2.0 - abs(HSL.x * 6.0 - 2.0);
float B = 2.0 - abs(HSL.x * 6.0 - 4.0);
vec3 RGB = clamp(vec3(R,G,B), 0.0, 1.0);
float C = (1.0 - abs(2.0 * HSL.z - 1.0)) * HSL.y;
return (RGB - 0.5) * C + HSL.z;
}
void fragment(){
vec4 color = texture(TEXTURE, UV);
float a = color.a;
vec3 t1 = rgb2hsl(target1color.rgb);
vec3 t2 = rgb2hsl(target2color.rgb);
vec3 t3 = rgb2hsl(target3color.rgb);
vec3 k = rgb2hsl(color.rgb);
k = pow (k, vec3(1.0, 1.0, lmod));
if (abs(k.x - t1.x) < dist){
vec3 dcolor = t1;
float rot = dcolor.x - t1.x;
k.x = k.x + rot;
k.x = (k.x > 0.5) ? k.x - 0.5 : k.x + 0.5;
k.y = dcolor.y * 0.2;
k.z *= dcolor.z;
k = hsl2rgb(k);
color = vec4(k.xyz, a);
}
else if (abs(k.x - t2.x) < dist){
vec3 dcolor = t2;
float rot = dcolor.x - t2.x;
k.x = k.x + rot;
k.x = (k.x > 0.5) ? k.x - 0.5 : k.x + 0.5;
k.y = dcolor.y * 0.2;
k.z *= dcolor.z;
k = hsl2rgb(k);
color = vec4(k.xyz, a);
}
else if (abs(k.x - t3.x) < dist){
vec3 dcolor = t3;
float rot = dcolor.x - t3.x;
k.x = k.x + rot;
k.x = (k.x > 0.5) ? k.x - 0.5 : k.x + 0.5;
k.y = dcolor.y * 0.2;
k.z *= dcolor.z;
k = hsl2rgb(k);
color = vec4(k.xyz, a);
}
else {
k.x = (k.x > 0.5) ? k.x - 0.5 : k.x + 0.5;
k.y = 1.0;
//k.z = 0.4 + k.z * 0.6;
k = hsl2rgb(k);
color = vec4(k.xyz, a);
}
COLOR = color;
}"
[sub_resource type="ShaderMaterial" id=2]
shader = SubResource( 1 )
shader_param/target1color = Color( 0.980392, 0, 1, 1 )
shader_param/target2color = Color( 0.498039, 1, 0, 1 )
shader_param/target3color = Color( 0, 1, 0.6, 1 )
shader_param/dist = 0.1
shader_param/lmod = 0.6
[sub_resource type="ShaderMaterial" id=3]
shader = ExtResource( 1 )
shader_param/target1color = Color( 0.980392, 0, 1, 1 )
shader_param/target2color = Color( 0.498039, 1, 0, 1 )
shader_param/target3color = Color( 0, 1, 0.6, 1 )
shader_param/part1color = Color( 0.376471, 0.698039, 0.301961, 1 )
shader_param/part2color = Color( 0.435294, 0.266667, 0.027451, 1 )
shader_param/part3color = Color( 0.427451, 0.290196, 0.290196, 1 )
shader_param/dist = 0.1
shader_param/lmod = 0.6
[node name="Panel" type="Panel"]
margin_right = 782.0
margin_bottom = 443.0
[node name="main_artefact_detector" type="TextureRect" parent="."]
material = SubResource( 2 )
margin_left = 12.0
margin_top = 15.0
margin_right = 250.0
margin_bottom = 234.0
texture = ExtResource( 3 )
expand = true
__meta__ = {
"_edit_use_anchors_": false
}
[node name="color_shift_detector" type="TextureRect" parent="."]
material = SubResource( 3 )
margin_left = 340.371
margin_top = 15.004
margin_right = 572.371
margin_bottom = 246.004
texture = ExtResource( 3 )
expand = true
__meta__ = {
"_edit_use_anchors_": false
}
[node name="masked_recolor_test" type="TextureRect" parent="."]
material = ExtResource( 2 )
margin_left = 236.0
margin_top = 250.0
margin_right = 440.0
margin_bottom = 431.0
texture = ExtResource( 4 )
expand = true
[node name="sprite_book_shader" type="TextureRect" parent="."]
material = ExtResource( 6 )
margin_left = 458.813
margin_top = 26.727
margin_right = 802.813
margin_bottom = 431.727
texture = ExtResource( 5 )
expand = true
stretch_mode = 6