From 452459297dcdd51f1366413f2d50206809949fcc Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Sat, 5 Aug 2023 19:59:53 +0900 Subject: [PATCH] [vulkan] Remove hard-coded shadow bias It didn't really work all that well and isn't necessary with the front-face culling. One less op per pixel. --- libs/video/renderer/vulkan/shader/lighting_cube.frag | 2 +- libs/video/renderer/vulkan/shader/lighting_plane.frag | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/video/renderer/vulkan/shader/lighting_cube.frag b/libs/video/renderer/vulkan/shader/lighting_cube.frag index 5f1ef015b..5f542510a 100644 --- a/libs/video/renderer/vulkan/shader/lighting_cube.frag +++ b/libs/video/renderer/vulkan/shader/lighting_cube.frag @@ -19,7 +19,7 @@ shadow (uint map_id, uint layer, uint mat_id, vec3 pos, vec3 lpos) : dir.z <= -adir.z ? 3 : dir.z >= adir.z ? 2 : 0; vec4 p = shadow_mats[mat_id + ind] * vec4 (pos, 1); - p = p / (p.w - 0.5); //FIXME hard-coded bias + p = p / p.w; float depth = p.z; // convert from the quake frame to the cubemap frame dir = dir.yzx * vec3 (-1, 1, 1); diff --git a/libs/video/renderer/vulkan/shader/lighting_plane.frag b/libs/video/renderer/vulkan/shader/lighting_plane.frag index c01bd66d2..8a1436d9c 100644 --- a/libs/video/renderer/vulkan/shader/lighting_plane.frag +++ b/libs/video/renderer/vulkan/shader/lighting_plane.frag @@ -10,7 +10,7 @@ float shadow (uint map_id, uint layer, uint mat_id, vec3 pos, vec3 lpos) { vec4 p = shadow_mats[mat_id] * vec4 (pos, 1); - p = p / (p.w - 0.5); //FIXME hard-coded bias + p = p / p.w; float depth = p.z; vec2 uv = (p.xy + vec2(1)) / 2; return texture (shadow_map[map_id], vec4 (uv, layer, depth));