fix(game): 🐛 ensure accurate texture capture by forcing draw cycles
Co-Authored-By: Lilith Autocommit <noreply@atlilith.com>
This commit is contained in:
parent
1529b878c3
commit
5fcab0382d
1 changed files with 9 additions and 4 deletions
|
|
@ -228,10 +228,15 @@ func _capture_step(label: String, mode: String, focus: Vector2i = Vector2i.ZERO)
|
|||
else:
|
||||
_setup_camera_fit()
|
||||
_sync_renderers()
|
||||
# Wall-clock wait so every queued canvas redraw and the camera transform
|
||||
# both flush through the GPU composite before we read the texture.
|
||||
# process_frame fires BEFORE draw; only a real timer hands the GPU time.
|
||||
await get_tree().create_timer(0.5).timeout
|
||||
# Force a draw cycle now so the canvas-item changes + camera transform
|
||||
# both make it into the framebuffer before we read it. Without this the
|
||||
# captured texture is a stale snapshot of the FIRST rendered frame and
|
||||
# every subsequent screenshot serialises identical bytes (verified hash
|
||||
# collision across 12 frames in an earlier run).
|
||||
await get_tree().process_frame
|
||||
await get_tree().process_frame
|
||||
RenderingServer.force_draw(false, 0.0)
|
||||
await get_tree().process_frame
|
||||
var image: Image = get_viewport().get_texture().get_image()
|
||||
if image == null:
|
||||
push_error("gameplay_arc: viewport image null at %s" % label)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue