-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Force shaders for blaster to be precompiled
Resolves #3.
- Loading branch information
1 parent
aa3f268
commit 6d40ae3
Showing
3 changed files
with
60 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
[gd_resource type="Environment" load_steps=3 format=3 uid="uid://b7t3opwr35xen"] | ||
|
||
[sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_i3osh"] | ||
sky_top_color = Color(1, 1, 1, 1) | ||
sky_horizon_color = Color(0.75, 0.75, 0.75, 1) | ||
ground_bottom_color = Color(0, 0, 0, 1) | ||
ground_horizon_color = Color(0.75, 0.75, 0.75, 1) | ||
|
||
[sub_resource type="Sky" id="Sky_qvksn"] | ||
sky_material = SubResource("ProceduralSkyMaterial_i3osh") | ||
|
||
[resource] | ||
background_mode = 1 | ||
sky = SubResource("Sky_qvksn") | ||
ambient_light_source = 2 | ||
ambient_light_color = Color(1, 1, 1, 1) | ||
ambient_light_energy = 0.25 | ||
reflected_light_source = 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
extends SubViewport | ||
|
||
## Hacky way to precompile shaders and avoid hiccups when instantiating objects later. | ||
## | ||
## The listed scenes are prerendered to an offscreen texture, forcing shaders to be | ||
## compiled and everything loaded into memory. For some reason, this still doesn't | ||
## cut out _all_ of the hiccup later, but at least reduces it meaningfully. | ||
|
||
@export var precompile: Array[PackedScene] = [] | ||
|
||
func _ready() -> void: | ||
self.get_texture() | ||
|
||
for scene in self.precompile: | ||
var node := scene.instantiate() | ||
self.add_child(node) | ||
|
||
await RenderingServer.frame_post_draw | ||
self.queue_free() |