Video options FXAA and MSAA Godot 4
Asked Answered
C

2

0

Help me with the code please, Godot 4, MSAA simply doesn't give an error, but on the other hand it has no effect. This is a slide button:

func _on_msaa_value_changed(value):
	match value:
		0:
			RenderingServer.viewport_set_msaa_2d(Viewport, RenderingServer.VIEWPORT_MSAA_DISABLED)
		1:
			RenderingServer.viewport_set_msaa_2d(Viewport, RenderingServer.VIEWPORT_MSAA_2X)
		2:
			RenderingServer.viewport_set_msaa_2d(Viewport, RenderingServer.VIEWPORT_MSAA_4X)
		3:
			RenderingServer.viewport_set_msaa_2d(Viewport, RenderingServer.VIEWPORT_MSAA_8X)
		4:
			RenderingServer.viewport_set_msaa_2d(Viewport, RenderingServer.VIEWPORT_MSAA_MAX)

Checkbox for FXAA:

func _on_fxaa_toggled(toggled_on):
	if toggled_on:
		get_viewport().SCREEN_SPACE_AA_FXAA
	else:
		RenderingServer.VIEWPORT_SCREEN_SPACE_AA_FXAA

Please help me, I'm a beginner at Godot

Crankpin answered 11/12, 2023 at 21:25 Comment(0)
F
1

Crankpin

First you need to get the viewport rid from the scene tree:

var viewport_rid : RID

func _ready() -> void:
	viewport_rid = get_tree().root.get_viewport_rid()

func _on_msaa_value_changed(value):
	match value:
		0:
			RenderingServer.viewport_set_msaa_2d(viewport_rid,RenderingServer.VIEWPORT_MSAA_2X)

FXAA:

func _on_fxaa_toggled(toggled_on):
	if toggled_on:
		RenderingServer.viewport_set_screen_space_aa(viewport_rid,RenderingServer.VIEWPORT_SCREEN_SPACE_AA_FXAA)
	else:
		RenderingServer.viewport_set_screen_space_aa(viewport_rid,RenderingServer.VIEWPORT_SCREEN_SPACE_AA_DISABLED)
Fishbein answered 11/12, 2023 at 22:42 Comment(0)
C
0

Fishbein Thank you very much my friend for your help, you helped me a lot. Thank you very much.

Crankpin answered 12/12, 2023 at 21:20 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.