fix: increase shadow bias — slope-dependent + larger depth bias
- Fragment shader: bias = 0.3 + 0.5 * (1 - NdotL) — slope-dependent Grazing angles get larger bias to prevent acne on cube faces - vkCmdSetDepthBias: 2.5/0/3.5 (was 1.25/0/1.75) — more aggressive polygon offset for shadow map rendering - Early exit tolerance reduced from 4x to 3x bias
This commit is contained in:
@@ -103,12 +103,12 @@ float calcShadow(vec3 worldPos, vec3 lightPos, vec3 N, vec3 L)
|
||||
// Base shadow check (center sample)
|
||||
float closestDepth = texture(shadowCube, dirNorm).r;
|
||||
float mappedDepth = closestDepth * FAR_PLANE;
|
||||
float bias = 0.15;
|
||||
float bias = 0.3 + 0.5 * (1.0 - max(dot(N, L), 0.0));
|
||||
float baseResult = dist - bias < mappedDepth ? 1.0 : 0.0;
|
||||
|
||||
// If clearly lit or clearly shadowed, skip PCF
|
||||
if (dist - bias * 4.0 < mappedDepth) return 1.0;
|
||||
if (dist + bias * 4.0 > mappedDepth && baseResult > 0.5) return 1.0;
|
||||
if (dist - bias * 3.0 < mappedDepth) return 1.0;
|
||||
if (dist + bias * 3.0 > mappedDepth && baseResult > 0.5) return 1.0;
|
||||
|
||||
// Poisson disk PCF — 16 samples
|
||||
float shadow = 0.0;
|
||||
|
||||
Binary file not shown.
@@ -255,7 +255,7 @@ internal sealed unsafe class VulkanRenderer : IRenderer, Engine.Graphics.IScreen
|
||||
};
|
||||
Vk.vkCmdSetScissor(cmd, 0, 1, &shadowScissor);
|
||||
|
||||
Vk.vkCmdSetDepthBias(cmd, 1.25f, 0.0f, 1.75f);
|
||||
Vk.vkCmdSetDepthBias(cmd, 2.5f, 0.0f, 3.5f);
|
||||
|
||||
foreach (var dc in drawCalls)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user