Skip to content

Commit 906472b

Browse files
committed
Add SMAA option to the 3D antialiasing demo
- Rename various labels for readability. - Use infinity symbol when FPS limit is set to 0. - Use lossless compression for ship textures since they are low-resolution, and applied to a large object (making VRAM compression look bad).
1 parent 245cbfc commit 906472b

12 files changed

Lines changed: 85 additions & 91 deletions

3d/antialiasing/README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
# 3D Anti-Aliasing
22

3-
This project showcases the various 3D antialiasing techniques supported by Godot.
3+
This project showcases the various [3D antialiasing](https://docs.godotengine.org/en/latest/tutorials/3d/3d_antialiasing.html)
4+
techniques supported by Godot.
45

56
- **Multisample antialiasing (MSAA):** High quality, high performance cost.
67
Does not blur the image.
78
- Does not affect shader-induced aliasing (such as specular aliasing) or alpha
89
scissor materials, so these will remain aliased.
9-
- **Fast approximate antialiasing (FXAA):** Medium quality, low performance cost.
10+
- **Fast approximate antialiasing (FXAA):** Low quality, low performance cost.
1011
Slightly blurs the image.
12+
- **Subpixel morphological antialiasing (SMAA):** Medium quality, moderate performance
13+
cost. Slightly blurs the image, but not as much as FXAA. Godot only supports
14+
the spatial version of SMAA, also called SMAA 1x.
1115
- **Temporal antialiasing (TAA):** High-quality, low performance cost. Slightly
1216
blurs the image (but less so than FXAA).
1317
- Antialiasing quality is worse on fast-moving objects than other methods,

3d/antialiasing/anti_aliasing.gd

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ func _ready() -> void:
2323
if RenderingServer.get_current_rendering_method() == "gl_compatibility":
2424
is_compatibility = true
2525
# Hide unsupported features.
26-
$Antialiasing/FXAAContainer.visible = false
27-
$Antialiasing/TAAContainer.visible = false
26+
$Antialiasing/ScreenSpaceAAContainer.visible = false
27+
$Antialiasing/TemporalAAContainer.visible = false
2828

2929
# Darken the light's energy to compensate for sRGB blending (without affecting sky rendering).
3030
$DirectionalLight3D.sky_mode = DirectionalLight3D.SKY_MODE_SKY_ONLY
@@ -78,8 +78,6 @@ func _process(delta: float) -> void:
7878
fps_label.modulate = fps_label.get_meta(&"gradient").sample(remap(Engine.get_frames_per_second(), 0, 180, 0.0, 1.0))
7979

8080

81-
82-
8381
func _on_previous_pressed() -> void:
8482
tester_index = max(0, tester_index - 1)
8583
update_gui()
@@ -102,11 +100,11 @@ func _on_msaa_item_selected(index: int) -> void:
102100
get_viewport().msaa_3d = index as Viewport.MSAA
103101

104102

105-
func _on_limit_fps_scale_value_changed(value: float) -> void:
103+
func _on_fps_limit_scale_value_changed(value: float) -> void:
106104
# The rendering FPS affects the appearance of TAA, as higher framerates allow it to converge faster.
107105
# On high refresh rate monitors, TAA ghosting issues may appear less noticeable as a result
108106
# (if the GPU can keep up).
109-
$Antialiasing/LimitFPSContainer/Value.text = str(value)
107+
$Antialiasing/FPSLimitContainer/Value.text = str(roundi(value)) if not is_zero_approx(value) else "∞"
110108
Engine.max_fps = roundi(value)
111109

112110

@@ -151,18 +149,19 @@ func _on_viewport_size_changed() -> void:
151149

152150

153151
func _on_v_sync_item_selected(index: int) -> void:
154-
# Vsync is enabled by default.
152+
# V-Sync is enabled by default.
155153
# Vertical synchronization locks framerate and makes screen tearing not visible at the cost of
156154
# higher input latency and stuttering when the framerate target is not met.
157155
# Adaptive V-Sync automatically disables V-Sync when the framerate target is not met, and enables
158156
# V-Sync otherwise. This prevents suttering and reduces input latency when the framerate target
159157
# is not met, at the cost of visible tearing.
160-
if index == 0: # Disabled (default)
161-
DisplayServer.window_set_vsync_mode(DisplayServer.VSYNC_DISABLED)
162-
elif index == 1: # Adaptive
163-
DisplayServer.window_set_vsync_mode(DisplayServer.VSYNC_ADAPTIVE)
164-
elif index == 2: # Enabled
165-
DisplayServer.window_set_vsync_mode(DisplayServer.VSYNC_ENABLED)
158+
match index:
159+
0: # Disabled (default)
160+
DisplayServer.window_set_vsync_mode(DisplayServer.VSYNC_DISABLED)
161+
1: # Adaptive
162+
DisplayServer.window_set_vsync_mode(DisplayServer.VSYNC_ADAPTIVE)
163+
2: # Enabled
164+
DisplayServer.window_set_vsync_mode(DisplayServer.VSYNC_ENABLED)
166165

167166

168167
func _on_taa_item_selected(index: int) -> void:
@@ -171,7 +170,8 @@ func _on_taa_item_selected(index: int) -> void:
171170
get_viewport().use_taa = index == 1
172171

173172

174-
func _on_fxaa_item_selected(index: int) -> void:
175-
# Fast approximate anti-aliasing. Much faster than MSAA (and works on alpha scissor edges),
173+
func _on_screen_space_aa_item_selected(index: int) -> void:
174+
# Screen-space antialiasing. Much faster than MSAA (and works on alpha scissor edges),
176175
# but blurs the whole scene rendering slightly.
177-
get_viewport().screen_space_aa = int(index == 1) as Viewport.ScreenSpaceAA
176+
# SMAA looks sharper than FXAA and has better edge coverage, but is slower.
177+
get_viewport().screen_space_aa = int(index) as Viewport.ScreenSpaceAA

3d/antialiasing/anti_aliasing.tscn

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -813,7 +813,7 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -68)
813813
mesh = SubResource("SphereMesh_v4x6x")
814814

815815
[node name="Decal" type="Decal" parent="Testers/MovingDecal"]
816-
transform = Transform3D(-0.70710397, -1.0132787e-06, -0.7071092, 0.18301255, 0.96592563, -0.1830126, 0.68301517, -0.25881886, -0.68300986, 1, 1, 1)
816+
transform = Transform3D(-0.70710397, -1.0132787e-06, -0.7071092, 0.18301255, 0.9659256, -0.1830126, 0.68301517, -0.25881886, -0.68300986, 1, 1, 1)
817817
texture_albedo = ExtResource("3_2nulf")
818818
texture_normal = ExtResource("4_fdfpv")
819819

@@ -886,20 +886,19 @@ offset_right = 394.0
886886
offset_bottom = 340.0
887887
theme_override_constants/separation = 10
888888

889-
[node name="MSAAContainer" type="HBoxContainer" parent="Antialiasing"]
889+
[node name="MultisampleAAContainer" type="HBoxContainer" parent="Antialiasing"]
890890
layout_mode = 2
891891

892-
[node name="Label" type="Label" parent="Antialiasing/MSAAContainer"]
892+
[node name="Label" type="Label" parent="Antialiasing/MultisampleAAContainer"]
893893
custom_minimum_size = Vector2(120, 2.08165e-12)
894894
layout_mode = 2
895895
size_flags_horizontal = 3
896896
theme_override_colors/font_outline_color = Color(0, 0, 0, 1)
897897
theme_override_constants/outline_size = 4
898-
text = "MSAA
899-
"
898+
text = "Multisample AA"
900899
vertical_alignment = 1
901900

902-
[node name="MSAA" type="OptionButton" parent="Antialiasing/MSAAContainer"]
901+
[node name="MultisampleAA" type="OptionButton" parent="Antialiasing/MultisampleAAContainer"]
903902
custom_minimum_size = Vector2(235, 2.08165e-12)
904903
layout_mode = 2
905904
selected = 0
@@ -913,43 +912,43 @@ popup/item_2/id = 2
913912
popup/item_3/text = "8× (Slower)"
914913
popup/item_3/id = 3
915914

916-
[node name="FXAAContainer" type="HBoxContainer" parent="Antialiasing"]
915+
[node name="ScreenSpaceAAContainer" type="HBoxContainer" parent="Antialiasing"]
917916
layout_mode = 2
918917

919-
[node name="Label" type="Label" parent="Antialiasing/FXAAContainer"]
918+
[node name="Label" type="Label" parent="Antialiasing/ScreenSpaceAAContainer"]
920919
custom_minimum_size = Vector2(120, 2.08165e-12)
921920
layout_mode = 2
922921
size_flags_horizontal = 3
923922
theme_override_colors/font_outline_color = Color(0, 0, 0, 1)
924923
theme_override_constants/outline_size = 4
925-
text = "FXAA
926-
"
924+
text = "Screen-Space AA"
927925
vertical_alignment = 1
928926

929-
[node name="FXAA" type="OptionButton" parent="Antialiasing/FXAAContainer"]
927+
[node name="ScreenSpaceAA" type="OptionButton" parent="Antialiasing/ScreenSpaceAAContainer"]
930928
custom_minimum_size = Vector2(235, 2.08165e-12)
931929
layout_mode = 2
932930
selected = 0
933-
item_count = 2
931+
item_count = 3
934932
popup/item_0/text = "Disabled (Fastest)"
935933
popup/item_0/id = 0
936-
popup/item_1/text = "Enabled (Fast)"
934+
popup/item_1/text = "FXAA (Fast)"
937935
popup/item_1/id = 1
936+
popup/item_2/text = "SMAA (Average)"
937+
popup/item_2/id = 2
938938

939-
[node name="TAAContainer" type="HBoxContainer" parent="Antialiasing"]
939+
[node name="TemporalAAContainer" type="HBoxContainer" parent="Antialiasing"]
940940
layout_mode = 2
941941

942-
[node name="Label" type="Label" parent="Antialiasing/TAAContainer"]
942+
[node name="Label" type="Label" parent="Antialiasing/TemporalAAContainer"]
943943
custom_minimum_size = Vector2(120, 2.08165e-12)
944944
layout_mode = 2
945945
size_flags_horizontal = 3
946946
theme_override_colors/font_outline_color = Color(0, 0, 0, 1)
947947
theme_override_constants/outline_size = 4
948-
text = "TAA
949-
"
948+
text = "Temporal AA"
950949
vertical_alignment = 1
951950

952-
[node name="TAA" type="OptionButton" parent="Antialiasing/TAAContainer"]
951+
[node name="TemporalAA" type="OptionButton" parent="Antialiasing/TemporalAAContainer"]
953952
custom_minimum_size = Vector2(235, 2.08165e-12)
954953
layout_mode = 2
955954
selected = 0
@@ -983,33 +982,33 @@ popup/item_1/id = 1
983982
popup/item_2/text = "Enabled"
984983
popup/item_2/id = 2
985984

986-
[node name="LimitFPSContainer" type="HBoxContainer" parent="Antialiasing"]
985+
[node name="FPSLimitContainer" type="HBoxContainer" parent="Antialiasing"]
987986
layout_mode = 2
988987
theme_override_constants/separation = 15
989988

990-
[node name="Label" type="Label" parent="Antialiasing/LimitFPSContainer"]
989+
[node name="Label" type="Label" parent="Antialiasing/FPSLimitContainer"]
991990
custom_minimum_size = Vector2(120, 2.08165e-12)
992991
layout_mode = 2
993992
size_flags_horizontal = 3
994993
theme_override_colors/font_outline_color = Color(0, 0, 0, 1)
995994
theme_override_constants/outline_size = 4
996-
text = "Limit FPS"
995+
text = "FPS Limit"
997996
vertical_alignment = 1
998997

999-
[node name="LimitFPSScale" type="HSlider" parent="Antialiasing/LimitFPSContainer"]
998+
[node name="FPSLimitScale" type="HSlider" parent="Antialiasing/FPSLimitContainer"]
1000999
layout_mode = 2
10011000
size_flags_horizontal = 3
10021001
size_flags_vertical = 4
10031002
size_flags_stretch_ratio = 3.0
10041003
max_value = 300.0
10051004
step = 10.0
10061005

1007-
[node name="Value" type="Label" parent="Antialiasing/LimitFPSContainer"]
1006+
[node name="Value" type="Label" parent="Antialiasing/FPSLimitContainer"]
10081007
layout_mode = 2
10091008
size_flags_horizontal = 3
10101009
theme_override_colors/font_outline_color = Color(0, 0, 0, 1)
10111010
theme_override_constants/outline_size = 4
1012-
text = "0"
1011+
text = ""
10131012
horizontal_alignment = 1
10141013
vertical_alignment = 1
10151014

@@ -1099,11 +1098,11 @@ metadata/gradient = SubResource("Gradient_ehij4")
10991098

11001099
[connection signal="pressed" from="Previous" to="." method="_on_previous_pressed"]
11011100
[connection signal="pressed" from="Next" to="." method="_on_next_pressed"]
1102-
[connection signal="item_selected" from="Antialiasing/MSAAContainer/MSAA" to="." method="_on_msaa_item_selected"]
1103-
[connection signal="item_selected" from="Antialiasing/FXAAContainer/FXAA" to="." method="_on_fxaa_item_selected"]
1104-
[connection signal="item_selected" from="Antialiasing/TAAContainer/TAA" to="." method="_on_taa_item_selected"]
1101+
[connection signal="item_selected" from="Antialiasing/MultisampleAAContainer/MultisampleAA" to="." method="_on_msaa_item_selected"]
1102+
[connection signal="item_selected" from="Antialiasing/ScreenSpaceAAContainer/ScreenSpaceAA" to="." method="_on_screen_space_aa_item_selected"]
1103+
[connection signal="item_selected" from="Antialiasing/TemporalAAContainer/TemporalAA" to="." method="_on_taa_item_selected"]
11051104
[connection signal="item_selected" from="Antialiasing/VSyncContainer/VSync" to="." method="_on_v_sync_item_selected"]
1106-
[connection signal="value_changed" from="Antialiasing/LimitFPSContainer/LimitFPSScale" to="." method="_on_limit_fps_scale_value_changed"]
1105+
[connection signal="value_changed" from="Antialiasing/FPSLimitContainer/FPSLimitScale" to="." method="_on_fps_limit_scale_value_changed"]
11071106
[connection signal="value_changed" from="Antialiasing/RenderScaleContainer/RenderScale" to="." method="_on_render_scale_value_changed"]
11081107
[connection signal="toggled" from="Antialiasing/FidelityFXFSR" to="." method="_on_amd_fidelityfx_fsr1_toggled"]
11091108
[connection signal="item_selected" from="Antialiasing/FSRSharpness" to="." method="_on_fsr_sharpness_item_selected"]

3d/antialiasing/polyhaven/textures/dutch_ship_medium_hull_arm_1k.jpg.import

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,19 @@
33
importer="texture"
44
type="CompressedTexture2D"
55
uid="uid://y1d8bbofs2j1"
6-
path.s3tc="res://.godot/imported/dutch_ship_medium_hull_arm_1k.jpg-1bcb2be1a58190217bafabbba5a96cb5.s3tc.ctex"
6+
path="res://.godot/imported/dutch_ship_medium_hull_arm_1k.jpg-1bcb2be1a58190217bafabbba5a96cb5.ctex"
77
metadata={
8-
"imported_formats": ["s3tc_bptc"],
9-
"vram_texture": true
8+
"vram_texture": false
109
}
1110

1211
[deps]
1312

1413
source_file="res://polyhaven/textures/dutch_ship_medium_hull_arm_1k.jpg"
15-
dest_files=["res://.godot/imported/dutch_ship_medium_hull_arm_1k.jpg-1bcb2be1a58190217bafabbba5a96cb5.s3tc.ctex"]
14+
dest_files=["res://.godot/imported/dutch_ship_medium_hull_arm_1k.jpg-1bcb2be1a58190217bafabbba5a96cb5.ctex"]
1615

1716
[params]
1817

19-
compress/mode=2
18+
compress/mode=0
2019
compress/high_quality=false
2120
compress/lossy_quality=0.7
2221
compress/uastc_level=0

3d/antialiasing/polyhaven/textures/dutch_ship_medium_hull_diff_1k.jpg.import

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,19 @@
33
importer="texture"
44
type="CompressedTexture2D"
55
uid="uid://cpqm052kluinu"
6-
path.s3tc="res://.godot/imported/dutch_ship_medium_hull_diff_1k.jpg-d22f57383d3437ac6151a5dc155d1b44.s3tc.ctex"
6+
path="res://.godot/imported/dutch_ship_medium_hull_diff_1k.jpg-d22f57383d3437ac6151a5dc155d1b44.ctex"
77
metadata={
8-
"imported_formats": ["s3tc_bptc"],
9-
"vram_texture": true
8+
"vram_texture": false
109
}
1110

1211
[deps]
1312

1413
source_file="res://polyhaven/textures/dutch_ship_medium_hull_diff_1k.jpg"
15-
dest_files=["res://.godot/imported/dutch_ship_medium_hull_diff_1k.jpg-d22f57383d3437ac6151a5dc155d1b44.s3tc.ctex"]
14+
dest_files=["res://.godot/imported/dutch_ship_medium_hull_diff_1k.jpg-d22f57383d3437ac6151a5dc155d1b44.ctex"]
1615

1716
[params]
1817

19-
compress/mode=2
18+
compress/mode=0
2019
compress/high_quality=false
2120
compress/lossy_quality=0.7
2221
compress/uastc_level=0

3d/antialiasing/polyhaven/textures/dutch_ship_medium_hull_nor_gl_1k.jpg.import

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,19 @@
33
importer="texture"
44
type="CompressedTexture2D"
55
uid="uid://dx4v7lwh3dlk2"
6-
path.s3tc="res://.godot/imported/dutch_ship_medium_hull_nor_gl_1k.jpg-f0fc1f178ac5ff99bdf2aae06e0701f1.s3tc.ctex"
6+
path="res://.godot/imported/dutch_ship_medium_hull_nor_gl_1k.jpg-f0fc1f178ac5ff99bdf2aae06e0701f1.ctex"
77
metadata={
8-
"imported_formats": ["s3tc_bptc"],
9-
"vram_texture": true
8+
"vram_texture": false
109
}
1110

1211
[deps]
1312

1413
source_file="res://polyhaven/textures/dutch_ship_medium_hull_nor_gl_1k.jpg"
15-
dest_files=["res://.godot/imported/dutch_ship_medium_hull_nor_gl_1k.jpg-f0fc1f178ac5ff99bdf2aae06e0701f1.s3tc.ctex"]
14+
dest_files=["res://.godot/imported/dutch_ship_medium_hull_nor_gl_1k.jpg-f0fc1f178ac5ff99bdf2aae06e0701f1.ctex"]
1615

1716
[params]
1817

19-
compress/mode=2
18+
compress/mode=0
2019
compress/high_quality=false
2120
compress/lossy_quality=0.7
2221
compress/uastc_level=0

3d/antialiasing/polyhaven/textures/dutch_ship_medium_rigging_arm_1k.jpg.import

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,19 @@
33
importer="texture"
44
type="CompressedTexture2D"
55
uid="uid://cprmlobj741yv"
6-
path.s3tc="res://.godot/imported/dutch_ship_medium_rigging_arm_1k.jpg-6de8e054b6e80b00009332eaf9eafbeb.s3tc.ctex"
6+
path="res://.godot/imported/dutch_ship_medium_rigging_arm_1k.jpg-6de8e054b6e80b00009332eaf9eafbeb.ctex"
77
metadata={
8-
"imported_formats": ["s3tc_bptc"],
9-
"vram_texture": true
8+
"vram_texture": false
109
}
1110

1211
[deps]
1312

1413
source_file="res://polyhaven/textures/dutch_ship_medium_rigging_arm_1k.jpg"
15-
dest_files=["res://.godot/imported/dutch_ship_medium_rigging_arm_1k.jpg-6de8e054b6e80b00009332eaf9eafbeb.s3tc.ctex"]
14+
dest_files=["res://.godot/imported/dutch_ship_medium_rigging_arm_1k.jpg-6de8e054b6e80b00009332eaf9eafbeb.ctex"]
1615

1716
[params]
1817

19-
compress/mode=2
18+
compress/mode=0
2019
compress/high_quality=false
2120
compress/lossy_quality=0.7
2221
compress/uastc_level=0

3d/antialiasing/polyhaven/textures/dutch_ship_medium_rigging_diff_1k.jpg.import

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,19 @@
33
importer="texture"
44
type="CompressedTexture2D"
55
uid="uid://d0r11ltathrwx"
6-
path.s3tc="res://.godot/imported/dutch_ship_medium_rigging_diff_1k.jpg-b381c8dba5fcad22696086becdc354b0.s3tc.ctex"
6+
path="res://.godot/imported/dutch_ship_medium_rigging_diff_1k.jpg-b381c8dba5fcad22696086becdc354b0.ctex"
77
metadata={
8-
"imported_formats": ["s3tc_bptc"],
9-
"vram_texture": true
8+
"vram_texture": false
109
}
1110

1211
[deps]
1312

1413
source_file="res://polyhaven/textures/dutch_ship_medium_rigging_diff_1k.jpg"
15-
dest_files=["res://.godot/imported/dutch_ship_medium_rigging_diff_1k.jpg-b381c8dba5fcad22696086becdc354b0.s3tc.ctex"]
14+
dest_files=["res://.godot/imported/dutch_ship_medium_rigging_diff_1k.jpg-b381c8dba5fcad22696086becdc354b0.ctex"]
1615

1716
[params]
1817

19-
compress/mode=2
18+
compress/mode=0
2019
compress/high_quality=false
2120
compress/lossy_quality=0.7
2221
compress/uastc_level=0

3d/antialiasing/polyhaven/textures/dutch_ship_medium_rigging_nor_gl_1k.jpg.import

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,19 @@
33
importer="texture"
44
type="CompressedTexture2D"
55
uid="uid://bws456aqy70dc"
6-
path.s3tc="res://.godot/imported/dutch_ship_medium_rigging_nor_gl_1k.jpg-26a255f6574d49990ad4162b06c015da.s3tc.ctex"
6+
path="res://.godot/imported/dutch_ship_medium_rigging_nor_gl_1k.jpg-26a255f6574d49990ad4162b06c015da.ctex"
77
metadata={
8-
"imported_formats": ["s3tc_bptc"],
9-
"vram_texture": true
8+
"vram_texture": false
109
}
1110

1211
[deps]
1312

1413
source_file="res://polyhaven/textures/dutch_ship_medium_rigging_nor_gl_1k.jpg"
15-
dest_files=["res://.godot/imported/dutch_ship_medium_rigging_nor_gl_1k.jpg-26a255f6574d49990ad4162b06c015da.s3tc.ctex"]
14+
dest_files=["res://.godot/imported/dutch_ship_medium_rigging_nor_gl_1k.jpg-26a255f6574d49990ad4162b06c015da.ctex"]
1615

1716
[params]
1817

19-
compress/mode=2
18+
compress/mode=0
2019
compress/high_quality=false
2120
compress/lossy_quality=0.7
2221
compress/uastc_level=0

0 commit comments

Comments
 (0)