Files
godot-demo-projects/2d/particles/pause.gd
Hugo Locurcio 6424e02ebf Add fallbacks and mention non-working features when using Compatibility or the Web platform (#1132)
- Make 3D lights with shadows darker when using Compatibility to better
  match the appearance of Forward+/Mobile, due to the use of sRGB blending
  for those lights.
- Silence some warnings when running projects with the Compatibility
  rendering method, such as the one about 2D MSAA not being supported.
- Rebake lightmaps in Global Illumination to improve quality and reduce
  light leaking with improvements from 4.3.
  - Increase probe density for dynamic objects, and mark the moving box
    as a dynamic object for GI purposes.

This is done to improve the experience with the web-based demos,
which always run with the Compatibility rendering method.
2025-10-02 10:31:42 -07:00

39 lines
1.7 KiB
GDScript
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
extends Label
var is_compatibility := false
func _ready() -> void:
if RenderingServer.get_current_rendering_method() == "gl_compatibility":
is_compatibility = true
text = "Space: Pause/Resume\nG: Toggle glow\n\n\n"
get_parent().get_node("UnsupportedLabel").visible = true
# Increase glow intensity to compensate for lower dynamic range.
get_node("../..").environment.glow_intensity = 4.0
func _input(event: InputEvent) -> void:
if event.is_action_pressed("toggle_pause"):
get_tree().paused = not get_tree().paused
if not is_compatibility and event.is_action_pressed("toggle_trails"):
# Particles disappear if trail type is changed while paused.
# Prevent changing particle type while paused to avoid confusion.
for particles in get_tree().get_nodes_in_group("trailable_particles"):
particles.trail_enabled = not particles.trail_enabled
if not is_compatibility and event.is_action_pressed("increase_trail_length"):
# Particles disappear if trail type is changed while paused.
# Prevent changing particle type while paused to avoid confusion.
for particles in get_tree().get_nodes_in_group("trailable_particles"):
particles.trail_lifetime = clampf(particles.trail_lifetime + 0.05, 0.1, 1.0)
if not is_compatibility and event.is_action_pressed("decrease_trail_length"):
# Particles disappear if trail type is changed while paused.
# Prevent changing particle type while paused to avoid confusion.
for particles in get_tree().get_nodes_in_group("trailable_particles"):
particles.trail_lifetime = clampf(particles.trail_lifetime - 0.05, 0.1, 1.0)
if event.is_action_pressed("toggle_glow"):
get_node("../..").environment.glow_enabled = not get_node("../..").environment.glow_enabled