Skip to content

Commit

Permalink
Allow falling back to GLES2
Browse files Browse the repository at this point in the history
This allows running the TPS demo on a greater range of devices
and platforms, while also allowing its use for GLES2 renderer testing.

Several automatic adjustments are made to ensure it looks as good
as possible (within the limitations of GLES2 and the lack of baked
lightmaps).
  • Loading branch information
Calinou committed Jan 10, 2022
1 parent 4a9d4f3 commit 2f97cf7
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 4 deletions.
10 changes: 9 additions & 1 deletion level/geometry/environment.tres
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
[gd_resource type="Environment" format=2]
[gd_resource type="Environment" load_steps=2 format=2]

[sub_resource type="ProceduralSky" id=1]
sky_top_color = Color( 0.65098, 0.498039, 0.356863, 1 )
sky_horizon_color = Color( 0.101961, 0.0784314, 0.054902, 1 )
ground_bottom_color = Color( 0.101961, 0.0784314, 0.054902, 1 )
ground_horizon_color = Color( 0.101961, 0.0784314, 0.054902, 1 )
sun_energy = 0.0

[resource]
background_mode = 1
background_sky = SubResource( 1 )
ambient_light_color = Color( 0.258824, 0.203922, 0.152941, 1 )
ambient_light_sky_contribution = 0.0
fog_enabled = true
Expand Down
18 changes: 15 additions & 3 deletions level/level.gd
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,25 @@ signal replace_main_scene # Useless, but needed as there is no clean way to chec
onready var world_environment = $WorldEnvironment

func _ready():
if Settings.gi_quality == Settings.GIQuality.HIGH:
if OS.get_current_video_driver() == OS.VIDEO_DRIVER_GLES3 and Settings.gi_quality == Settings.GIQuality.HIGH:
ProjectSettings["rendering/quality/voxel_cone_tracing/high_quality"] = true
elif Settings.gi_quality == Settings.GIQuality.LOW:
elif OS.get_current_video_driver() == OS.VIDEO_DRIVER_GLES3 and Settings.gi_quality == Settings.GIQuality.LOW:
ProjectSettings["rendering/quality/voxel_cone_tracing/high_quality"] = false
else:
# GLES2 fallback only supports ReflectionProbe, not GIProbe.
# However, ReflectionProbes don't blend well with environment lighting in GLES2,
# so it looks better (and performs better) when ReflectionProbes are also hidden.
$GIProbe.hide()
$ReflectionProbes.show()
if OS.get_current_video_driver() == OS.VIDEO_DRIVER_GLES3:
$ReflectionProbes.show()
else:
$ReflectionProbes.hide()
# Brighten level if falling back to GLES2, as it looks very dark otherwise.
# A procedural sky is used to provide ambient and reflected lighting as a fallback.
world_environment.environment.background_mode = Environment.BG_SKY
world_environment.environment.ambient_light_sky_contribution = 1.0
# Adjust glow strength for GLES2 (since there is no HDR).
world_environment.environment.glow_strength = 1.5

if Settings.aa_quality == Settings.AAQuality.AA_8X:
get_viewport().msaa = Viewport.MSAA_8X
Expand Down
7 changes: 7 additions & 0 deletions menu/menu.gd
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ signal replace_main_scene
signal quit # Useless, but needed as there is no clean way to check if a node exposes a signal

onready var ui = $UI
onready var gles2_fallback = ui.get_node(@"GLES2Fallback")
onready var main = ui.get_node(@"Main")
onready var play_button = main.get_node(@"Play")
onready var settings_button = main.get_node(@"Settings")
Expand Down Expand Up @@ -54,6 +55,12 @@ onready var loading_progress = loading.get_node(@"Progress")
onready var loading_done_timer = loading.get_node(@"DoneTimer")

func _ready():
if OS.get_current_video_driver() == OS.VIDEO_DRIVER_GLES2:
gles2_fallback.visible = true
# GI and SSAO are not supported in GLES2.
gi_menu.visible = false
ssao_menu.visible = false

get_tree().set_screen_stretch(SceneTree.STRETCH_MODE_2D, SceneTree.STRETCH_ASPECT_KEEP, Vector2(1920, 1080))
play_button.grab_focus()
var sound_effects = $BackgroundCache/RedRobot/SoundEffects
Expand Down
12 changes: 12 additions & 0 deletions menu/menu.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,18 @@ __meta__ = {
"_edit_use_anchors_": false
}

[node name="GLES2Fallback" type="Label" parent="UI"]
visible = false
margin_left = 97.9495
margin_top = 200.0
margin_right = 837.949
margin_bottom = 253.0
custom_colors/font_color = Color( 1, 0.870588, 0.356863, 1 )
text = "GLES2 fallback (degraded graphics quality)"
__meta__ = {
"_edit_use_anchors_": false
}

[node name="Main" type="Control" parent="UI"]
anchor_left = -0.000673103
anchor_top = -0.00189865
Expand Down
1 change: 1 addition & 0 deletions project.godot
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ toggle_debug={

[rendering]

quality/driver/fallback_to_gles2=true
vram_compression/import_etc2=false
quality/shadow_atlas/size=2048
quality/filters/msaa=2
Expand Down

0 comments on commit 2f97cf7

Please sign in to comment.