mirror of
https://git.triforceproject.com/triforce/source
synced 2026-11-19 16:20:01 -04:00
49 lines
2.9 KiB
Plaintext
49 lines
2.9 KiB
Plaintext
#version 450
|
|
// (hookshot) AMD FSR 3.1's inputs for OoT's gameplay upscale (vk_fsr3_inputs.cpp), at the render size, in one pass. The
|
|
// same inputs, from the same math, as NVIDIA DLSS's (dlss_prep.comp, #841), so the two upscalers see one picture:
|
|
// - colour: the network's input as it samples it (the square root of the scene's tonemapped colour, its perceptual
|
|
// encoding), clamped to 0..1; a NaN is 0, as one would stay in FSR's history for good. vk_fsr3.cpp's output pass squares
|
|
// FSR's picture back, as the network's own output does
|
|
// - depth: the scene's depth, reversed when the game's is not (pc.flags bit 1), which is the depth the vendored passes were
|
|
// compiled for (FFX_FSR3UPSCALER_OPTION_INVERTED_DEPTH, FFX_FRAMEINTERPOLATION_OPTION_INVERTED_DEPTH)
|
|
// - motion: where each pixel was in the frame before, in render pixels (x right, y down), the jitter taken off: the depth
|
|
// taken back to clip space and through pc.reproject (this frame's jittered clip space to the frame before's without its
|
|
// jitter: dlss_math.h). The camera's motion only, as #841's before its actor motion: what moves by itself gets the motion
|
|
// of what is behind it. pc.flags bit 0: motion (none on the first frame of a history)
|
|
// The game's clip space: depth from -1 to 1 (NVN's default), y up, the picture's rows top down.
|
|
layout(local_size_x = 8, local_size_y = 8) in;
|
|
layout(binding = 0) uniform sampler2D scene;
|
|
layout(binding = 1) uniform sampler2D scene_depth;
|
|
layout(binding = 2, rgba16f) uniform writeonly image2D color;
|
|
layout(binding = 3, r32f) uniform writeonly image2D depth;
|
|
layout(binding = 4, rg16f) uniform writeonly image2D motion;
|
|
layout(push_constant, row_major) uniform P {
|
|
mat4 reproject; // (this frame's jittered clip space to the frame before's without its jitter)
|
|
vec2 jitter; // (this frame's jitter in clip space: taken off, so the motion has none)
|
|
ivec2 size;
|
|
int flags;
|
|
} pc;
|
|
void main() {
|
|
const ivec2 g = ivec2(gl_GlobalInvocationID.xy);
|
|
if (any(greaterThanEqual(g, pc.size))) return;
|
|
const vec2 size = vec2(pc.size);
|
|
const vec2 uv = (vec2(g) + 0.5) / size;
|
|
vec3 c = textureLod(scene, uv, 0.0).rgb;
|
|
c = mix(c, vec3(0.0), isnan(c));
|
|
imageStore(color, g, vec4(clamp(c, 0.0, 1.0), 1.0));
|
|
const float d = textureLod(scene_depth, uv, 0.0).r;
|
|
imageStore(depth, g, vec4((pc.flags & 2) != 0 ? 1.0 - d : d));
|
|
vec2 mv = vec2(0.0);
|
|
if ((pc.flags & 1) != 0 && d >= 0.0 && d <= 1.0) {
|
|
const vec4 clip = vec4(uv.x * 2.0 - 1.0, 1.0 - uv.y * 2.0, d * 2.0 - 1.0, 1.0);
|
|
const vec4 before = pc.reproject * clip;
|
|
if (before.w > 1e-6) {
|
|
const vec2 then = before.xy / before.w;
|
|
const vec2 now = clip.xy - pc.jitter;
|
|
const vec2 px = vec2(then.x - now.x, now.y - then.y) * 0.5 * size;
|
|
if (all(lessThan(abs(px), vec2(16384.0)))) mv = px;
|
|
}
|
|
}
|
|
imageStore(motion, g, vec4(mv, 0.0, 0.0));
|
|
}
|