Skip to content

Commit 87f42b7

Browse files
committed
Update 2D shader and SDF demos
1 parent b0e1cc0 commit 87f42b7

18 files changed

+59
-70
lines changed
Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,23 @@
11
extends Control
22

3-
43
func _ready():
5-
for c in $pictures.get_children():
6-
$picture.add_item("PIC: " + c.get_name())
7-
for c in get_node("effects").get_children():
8-
$effect.add_item("FX: " + c.get_name())
4+
for c in $Pictures.get_children():
5+
$Picture.add_item("PIC: " + c.get_name())
6+
for c in $Effects.get_children():
7+
$Effect.add_item("FX: " + c.get_name())
98

109

1110
func _on_picture_item_selected(ID):
12-
for c in range($pictures.get_child_count()):
11+
for c in range($Pictures.get_child_count()):
1312
if ID == c:
14-
$pictures.get_child(c).show()
13+
$Pictures.get_child(c).show()
1514
else:
16-
$pictures.get_child(c).hide()
15+
$Pictures.get_child(c).hide()
1716

1817

1918
func _on_effect_item_selected(ID):
20-
for c in range($effects.get_child_count()):
19+
for c in range($Effects.get_child_count()):
2120
if ID == c:
22-
$effects.get_child(c).show()
21+
$Effects.get_child(c).show()
2322
else:
24-
$effects.get_child(c).hide()
23+
$Effects.get_child(c).hide()

2d/screen_space_shaders/screen_shaders.tscn

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -71,64 +71,64 @@ shader_param/flashing = 0.01
7171
shader_param/grain = ExtResource( 19 )
7272
shader_param/vignette = ExtResource( 7 )
7373

74-
[node name="Control" type="Control"]
74+
[node name="ScreenShaders" type="Control"]
7575
anchor_right = 1.0
7676
anchor_bottom = 1.0
7777
size_flags_horizontal = 2
7878
size_flags_vertical = 2
7979
script = ExtResource( 1 )
8080

81-
[node name="pictures" type="Control" parent="."]
81+
[node name="Pictures" type="Control" parent="."]
8282
anchor_right = 1.0
8383
anchor_bottom = 1.0
8484
size_flags_horizontal = 2
8585
size_flags_vertical = 2
8686

87-
[node name="burano" type="TextureRect" parent="pictures"]
87+
[node name="Burano" type="TextureRect" parent="Pictures"]
8888
margin_right = 40.0
8989
margin_bottom = 40.0
9090
size_flags_horizontal = 2
9191
size_flags_vertical = 2
9292
texture = ExtResource( 2 )
9393

94-
[node name="roby" type="TextureRect" parent="pictures"]
94+
[node name="Roby" type="TextureRect" parent="Pictures"]
9595
visible = false
9696
margin_right = 40.0
9797
margin_bottom = 40.0
9898
size_flags_horizontal = 2
9999
size_flags_vertical = 2
100100
texture = ExtResource( 3 )
101101

102-
[node name="mountains" type="TextureRect" parent="pictures"]
102+
[node name="Mountains" type="TextureRect" parent="Pictures"]
103103
visible = false
104104
margin_right = 40.0
105105
margin_bottom = 40.0
106106
size_flags_horizontal = 2
107107
size_flags_vertical = 2
108108
texture = ExtResource( 4 )
109109

110-
[node name="forest" type="TextureRect" parent="pictures"]
110+
[node name="Forest" type="TextureRect" parent="Pictures"]
111111
visible = false
112112
margin_right = 40.0
113113
margin_bottom = 40.0
114114
size_flags_horizontal = 2
115115
size_flags_vertical = 2
116116
texture = ExtResource( 5 )
117117

118-
[node name="effects" type="Control" parent="."]
118+
[node name="Effects" type="Control" parent="."]
119119
anchor_right = 1.0
120120
anchor_bottom = 1.0
121121
size_flags_horizontal = 2
122122
size_flags_vertical = 2
123123

124-
[node name="disabled" type="Control" parent="effects"]
124+
[node name="Disabled" type="Control" parent="Effects"]
125125
visible = false
126126
margin_right = 40.0
127127
margin_bottom = 40.0
128128
size_flags_horizontal = 2
129129
size_flags_vertical = 2
130130

131-
[node name="vignette" type="TextureRect" parent="effects"]
131+
[node name="Vignette" type="TextureRect" parent="Effects"]
132132
visible = false
133133
material = SubResource( 1 )
134134
anchor_right = 1.0
@@ -138,7 +138,7 @@ size_flags_vertical = 2
138138
texture = ExtResource( 8 )
139139
expand = true
140140

141-
[node name="blur" type="TextureRect" parent="effects"]
141+
[node name="Blur" type="TextureRect" parent="Effects"]
142142
visible = false
143143
material = SubResource( 2 )
144144
anchor_right = 1.0
@@ -148,7 +148,7 @@ size_flags_vertical = 2
148148
texture = ExtResource( 8 )
149149
expand = true
150150

151-
[node name="pixelize" type="TextureRect" parent="effects"]
151+
[node name="Pixelize" type="TextureRect" parent="Effects"]
152152
visible = false
153153
material = SubResource( 3 )
154154
anchor_right = 1.0
@@ -158,7 +158,7 @@ size_flags_vertical = 2
158158
texture = ExtResource( 8 )
159159
expand = true
160160

161-
[node name="whirl" type="TextureRect" parent="effects"]
161+
[node name="Whirl" type="TextureRect" parent="Effects"]
162162
visible = false
163163
material = SubResource( 4 )
164164
anchor_right = 1.0
@@ -168,7 +168,7 @@ size_flags_vertical = 2
168168
texture = ExtResource( 8 )
169169
expand = true
170170

171-
[node name="sepia" type="TextureRect" parent="effects"]
171+
[node name="Sepia" type="TextureRect" parent="Effects"]
172172
visible = false
173173
material = SubResource( 5 )
174174
anchor_right = 1.0
@@ -180,7 +180,7 @@ size_flags_vertical = 2
180180
texture = ExtResource( 8 )
181181
expand = true
182182

183-
[node name="negative" type="TextureRect" parent="effects"]
183+
[node name="Negative" type="TextureRect" parent="Effects"]
184184
visible = false
185185
material = SubResource( 6 )
186186
anchor_right = 1.0
@@ -190,7 +190,7 @@ size_flags_vertical = 2
190190
texture = ExtResource( 8 )
191191
expand = true
192192

193-
[node name="contrasted" type="TextureRect" parent="effects"]
193+
[node name="Contrasted" type="TextureRect" parent="Effects"]
194194
visible = false
195195
material = SubResource( 7 )
196196
anchor_right = 1.0
@@ -200,7 +200,7 @@ size_flags_vertical = 2
200200
texture = ExtResource( 8 )
201201
expand = true
202202

203-
[node name="normalized" type="TextureRect" parent="effects"]
203+
[node name="Normalized" type="TextureRect" parent="Effects"]
204204
visible = false
205205
material = SubResource( 8 )
206206
anchor_right = 1.0
@@ -210,7 +210,7 @@ size_flags_vertical = 2
210210
texture = ExtResource( 8 )
211211
expand = true
212212

213-
[node name="BCS" type="TextureRect" parent="effects"]
213+
[node name="BCS" type="TextureRect" parent="Effects"]
214214
visible = false
215215
material = SubResource( 9 )
216216
anchor_right = 1.0
@@ -222,7 +222,7 @@ size_flags_vertical = 2
222222
texture = ExtResource( 8 )
223223
expand = true
224224

225-
[node name="mirage" type="TextureRect" parent="effects"]
225+
[node name="Mirage" type="TextureRect" parent="Effects"]
226226
visible = false
227227
material = SubResource( 10 )
228228
anchor_right = 1.0
@@ -232,7 +232,7 @@ size_flags_vertical = 2
232232
texture = ExtResource( 8 )
233233
expand = true
234234

235-
[node name="old_film" type="TextureRect" parent="effects"]
235+
[node name="OldFilm" type="TextureRect" parent="Effects"]
236236
visible = false
237237
material = SubResource( 11 )
238238
anchor_right = 1.0
@@ -244,20 +244,20 @@ size_flags_vertical = 2
244244
texture = ExtResource( 8 )
245245
expand = true
246246

247-
[node name="picture" type="OptionButton" parent="."]
247+
[node name="Picture" type="OptionButton" parent="."]
248248
margin_left = 8.0
249249
margin_top = 7.0
250250
margin_right = 131.0
251251
margin_bottom = 28.0
252252
size_flags_horizontal = 2
253253
size_flags_vertical = 2
254254

255-
[node name="effect" type="OptionButton" parent="."]
255+
[node name="Effect" type="OptionButton" parent="."]
256256
margin_left = 137.0
257257
margin_top = 7.0
258258
margin_right = 260.0
259259
margin_bottom = 28.0
260260
size_flags_horizontal = 2
261261
size_flags_vertical = 2
262-
[connection signal="item_selected" from="picture" to="." method="_on_picture_item_selected"]
263-
[connection signal="item_selected" from="effect" to="." method="_on_effect_item_selected"]
262+
[connection signal="item_selected" from="Picture" to="." method="_on_picture_item_selected"]
263+
[connection signal="item_selected" from="Effect" to="." method="_on_effect_item_selected"]

2d/screen_space_shaders/shaders/BCS.shader

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ uniform float contrast = 1.5;
55
uniform float saturation = 1.8;
66

77
void fragment() {
8-
98
vec3 c = textureLod(SCREEN_TEXTURE, SCREEN_UV, 0.0).rgb;
109

1110
c.rgb = mix(vec3(0.0), c.rgb, brightness);
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
shader_type canvas_item;
22

3-
uniform float amount : hint_range(0.0, 5.0);
3+
uniform float amount: hint_range(0.0, 5.0);
44

55
void fragment() {
6-
76
COLOR.rgb = textureLod(SCREEN_TEXTURE, SCREEN_UV, amount).rgb;
87
}

2d/screen_space_shaders/shaders/contrasted.shader

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
shader_type canvas_item;
22

33
void fragment() {
4-
54
vec3 c = textureLod(SCREEN_TEXTURE, SCREEN_UV, 0.0).rgb;
65
c = mod(c + vec3(0.5), vec3(1.0));
76
COLOR.rgb = c;

2d/screen_space_shaders/shaders/mirage.shader

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ uniform float frequency = 60;
44
uniform float depth = 0.005;
55

66
void fragment() {
7-
87
vec2 uv = SCREEN_UV;
98
uv.x += sin(uv.y * frequency + TIME) * depth;
109
uv.x = clamp(uv.x, 0.0, 1.0);

2d/screen_space_shaders/shaders/negative.shader

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
shader_type canvas_item;
22

33
void fragment() {
4-
54
vec3 c = textureLod(SCREEN_TEXTURE, SCREEN_UV, 0.0).rgb;
65
c = vec3(1.0) - c;
76
COLOR.rgb = c;

2d/screen_space_shaders/shaders/old_film.shader

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
shader_type canvas_item;
22

3-
uniform vec4 base : hint_color;
3+
uniform vec4 base: hint_color;
44
uniform sampler2D grain;
55
uniform float grain_strength = 0.3;
66
uniform sampler2D vignette;
@@ -9,7 +9,6 @@ uniform float stretch = 0.5;
99
uniform float flashing = 0.01;
1010

1111
float make_grain(float time, vec2 uv) {
12-
1312
vec2 ofs = vec2(sin(41.0 * time * sin(time * 123.0)), sin(27.0 * time * sin(time * 312.0)));
1413
return texture(grain, (uv + mod(ofs, vec2(1.0, 1.0))) * stretch).r;
1514
}

2d/screen_space_shaders/shaders/sepia.shader

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,7 @@ uniform vec4 base : hint_color;
44

55
void fragment() {
66
vec3 c = textureLod(SCREEN_TEXTURE, SCREEN_UV, 0.0).rgb;
7-
8-
//float v = max(c.r, max(c.g, c.b));
97
float v = dot(c, vec3(0.33333, 0.33333, 0.33333));
108
v = sqrt(v);
11-
//v *= v;
129
COLOR.rgb = base.rgb * v;
13-
1410
}

2d/screen_space_shaders/shaders/vignette.shader

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ uniform sampler2D vignette;
44

55
void fragment() {
66
vec3 vignette_color = texture(vignette, UV).rgb;
7-
// Screen texture stores gaussian blurred copies on mipmaps
7+
// Screen texture stores gaussian blurred copies on mipmaps.
88
COLOR.rgb = textureLod(SCREEN_TEXTURE, SCREEN_UV, (1.0 - vignette_color.r) * 4.0).rgb;
99
COLOR.rgb *= texture(vignette, UV).rgb;
1010
}

0 commit comments

Comments
 (0)