[SOLVED] Is there a way to get shorter access to MSAA?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By razah

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


For disabling;


:bust_in_silhouette: Reply From: rolfpancake

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)
    VisualServer.viewport_set_msaa(viewport_rid , msaa_off)

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.

razah | 2018-02-06 21:49

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)
    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.

rolfpancake | 2018-02-06 22:44

:bust_in_silhouette: Reply From: Calinou

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

get_viewport().msaa = Viewport.MSAA_4X

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

razah | 2018-02-07 12:48