0 votes

The line is too long. How can I shorten it?

VisualServer.viewport_set_msaa(get_tree().get_root().get_viewport_rid(),VisualServer.VIEWPORT_MSAA_8X)

For disabling;

VisualServer.viewport_set_msaa(get_tree().get_root().get_viewport_rid(),VisualServer.VIEWPORT_MSAA_DISABLED)

in Engine by (154 points)
edited by

2 Answers

+2 votes
Best answer

This works for me, as seen in the Sponza demo:

get_viewport().msaa = Viewport.MSAA_4X
by (10,467 points)
selected by

The exact answer I'm looking for. thank you so much.

0 votes

Maybe by referencing your viewport rid and msaa setting as a variable?

onready var viewport_rid = get_tree().get_root().get_viewport_rid()
onready var msaa_default = VisualServer.VIEWPORT_MSAA_8X
onready var msaa_off = VisualServer.VIEWPORT_MSAA_DISABLED

func toggle_msaa(active):
  if active:
    VisualServer.viewport_set_msaa(viewport_rid , msaa_default)
  else:
    VisualServer.viewport_set_msaa(viewport_rid , msaa_off)
by (1,024 points)

thank you for your answer but I thought without reference. it seems impossible without reference. I'll write a singleton graphic_settings class for more legible code.

As stated in the docs these Viewport constants are representations of integers. Also getting the root-node can be abbreviated. So you could also write it like this:

func toggle_msaa(active):
  if active:
    VisualServer.viewport_set_msaa(get_node("/root").get_viewport_rid() , 3)
  else:
    VisualServer.viewport_set_msaa(get_node("/root").get_viewport_rid() , 0)

As far as I know there is no way of getting it even shorter without the use of referencing the viewport-rid.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.