mirror of
https://github.com/spoopyghosty0/frameport.git
synced 2026-10-23 08:02:38 +02:00
Opt-in game setting (Picture -> Draw fades over the picture). Batman: Arkham Shadow fades by dimming its projection layer with XR_KHR_composition_layer_color_scale_bias; with fade_quad=1 FrameBridge adds a black, alpha-blended quad right after the dimmed layer (VIEW space, 1 m ahead), opacity = 1 - scale in 16 steps. One 8x8 swapchain, refilled only when the step changes (Vulkan clear on the app's queue / GLES clear in its context); one swapchain per step hit XR_ERROR_LIMIT_REACHED. fade_quad=2 also removes the layer's own scale. Device (headless, Batman): swapchain created, level 16/16 on the first frame, no xrEndFrame errors, 72 fps.
17 lines
801 B
C
17 lines
801 B
C
// SPDX-License-Identifier: GPL-3.0-only
|
|
// fade_quad.c: how dark the fade quad is for a layer's colour scale (host-tested: tests/fixtures/src/fade_level_test.c).
|
|
#pragma once
|
|
|
|
#define FADE_LEVELS 16
|
|
|
|
// 0 = no fade (the picture is shown as it is), else 1..FADE_LEVELS = black at level / FADE_LEVELS opacity. The fade's
|
|
// opacity is 1 - the average of the red, green and blue scale (games fade all three alike); 0.99 and above count as
|
|
// "not dimmed", so a rounding scale never leaves a faint veil.
|
|
static inline int fade_level_of(float r, float g, float b) {
|
|
float scale = (r + g + b) / 3.0f;
|
|
if (!(scale < 0.99f)) return 0; // also NaN
|
|
if (scale < 0.0f) scale = 0.0f;
|
|
int level = (int)((1.0f - scale) * FADE_LEVELS + 0.5f);
|
|
return level > FADE_LEVELS ? FADE_LEVELS : level;
|
|
}
|