hud.gd 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. extends Control
  2. # The 3D viewport's shrink factor. For instance, 1 is full resolution,
  3. # 2 is half resolution and 4 is quarter resolution. Lower values look
  4. # sharper but are slower to render.
  5. var scale_factor = 1
  6. var filter_mode = Viewport.SCALING_3D_MODE_BILINEAR
  7. @onready var viewport = get_tree().root
  8. @onready var scale_label = $VBoxContainer/Scale
  9. @onready var filter_label = $VBoxContainer/Filter
  10. func _ready():
  11. viewport.scaling_3d_mode = Viewport.SCALING_3D_MODE_BILINEAR
  12. func _unhandled_input(event):
  13. if event.is_action_pressed("cycle_viewport_resolution"):
  14. scale_factor = wrapi(scale_factor + 1, 1, 5)
  15. viewport.scaling_3d_scale = 1.0 / scale_factor
  16. scale_label.text = "Scale: %3.0f%%" % (100.0 / scale_factor)
  17. if event.is_action_pressed("toggle_filtering"):
  18. filter_mode = wrapi(filter_mode + 1, Viewport.SCALING_3D_MODE_BILINEAR, Viewport.SCALING_3D_MODE_MAX) as Viewport.Scaling3DMode
  19. viewport.scaling_3d_mode = filter_mode
  20. filter_label.text = (
  21. ClassDB.class_get_enum_constants("Viewport", "Scaling3DMode")[filter_mode]
  22. .capitalize()
  23. .replace("3d", "3D")
  24. .replace("Mode", "Mode:")
  25. .replace("Fsr", "FSR")
  26. )