Give frame generation and FSR the scene's own near and far planes, field of view and units.

DLSS frame generation (Streamline and the NGX path) and FSR 3.1 and 4 upscaling and frame generation were told the depth came from a camera with near 0.1 and no far plane. Ocarina's projection has a finite far plane that changes with the camera: in Hyrule Field its z row is (-1.00001, -0.200001), near 0.1 and far about 25,000; the camera before it had far about 1,000. With the far plane taken as missing, a surface 10,000 units away was read as 16,650. The planes, and whether the depth is inverted, now come from the frame's projection and the device's depth mode every frame (vk_dlaa.c proj_planes), with one log line when they change. The stored depth is already 0 near and 1 far: the -w..w clip depth the pipelines keep maps to exactly what a 0..w projection with the same planes stores, and a frame dump's scene depth spans 0.975 to 1.0.

FSR's contexts lose their infinite-depth flag and take the far plane from each dispatch. FSR frame generation now gets the camera's field of view instead of a fixed 1 radian, and the upscaler gets it too (its caller passed 0). The view's units are metres, not the centimetres FSR was told: the camera orbits Link about 4 units behind him at about 3 units a second.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
tangerineturtle1
2026-11-11 13:19:31 -05:00
parent 6a011d2adf
commit e1cb6301ab
7 changed files with 116 additions and 31 deletions

View File

@@ -241,7 +241,8 @@ extern "C" void vk_fg_frame(VkCommandBuffer cb, VkSwapchainKHR sc, VkFormat fmt,
ffxCreateContextDescFrameGeneration d = {};
d.header.type = FFX_API_CREATE_CONTEXT_DESC_TYPE_FRAMEGENERATION;
d.header.pNext = &hl.header;
d.flags = FFX_FRAMEGENERATION_ENABLE_DEPTH_INFINITE | (hdr_format(fmt) ? FFX_FRAMEGENERATION_ENABLE_HIGH_DYNAMIC_RANGE : 0);
// no infinite-depth flag: the game's far plane is finite, and each preparation gives it (vk_fg_frame)
d.flags = hdr_format(fmt) ? FFX_FRAMEGENERATION_ENABLE_HIGH_DYNAMIC_RANGE : 0;
d.displaySize = {ext.width, ext.height};
d.maxRenderSize = {max_render.width, max_render.height};
d.backBufferFormat = ffxApiGetSurfaceFormatVK(fmt);
@@ -298,10 +299,13 @@ extern "C" void vk_fg_frame(VkCommandBuffer cb, VkSwapchainKHR sc, VkFormat fmt,
double dt = last_ns ? (now - last_ns) / 1e6 : 16.67;
last_ns = now;
p.frameTimeDelta = dt > 0 && dt < 100 ? (float)dt : 16.67f;
p.cameraNear = 0.1f; // Ocarina's projection: near 0.1, far at infinity (vk_ffx.cpp)
p.cameraFar = 1e8f;
p.cameraFovAngleVertical = 1.0f;
p.viewSpaceToMetersFactor = 0.01f;
// the frame's camera (vk_dlaa.c proj_planes), as the upscaler gets it (vk_ffx.cpp)
VkFfxCamera cam;
if (!vk_dlaa_ffx_camera(&cam)) memset(&cam, 0, sizeof cam);
p.cameraNear = cam.znear > 0 ? cam.znear : 0.1f;
p.cameraFar = cam.zfar > 0 ? cam.zfar : 1e8f;
p.cameraFovAngleVertical = cam.fov_y > 0 ? cam.fov_y : 1.0f;
p.viewSpaceToMetersFactor = cam.meters > 0 ? cam.meters : 1.0f;
p.depth = image(&depth);
p.motionVectors = image(&mv);
r = vk_ffx_dispatch(&F.fg, &p.header);