Fix Z-fighting issues in Debug Draw when using TAA

This commit is contained in:
Wojtek Figat
2024-03-19 17:53:14 +01:00
parent 388b64a46d
commit 71dad84908
3 changed files with 8 additions and 4 deletions

View File

@@ -127,7 +127,8 @@ PACK_STRUCT(struct Vertex {
PACK_STRUCT(struct Data {
Matrix ViewProjection;
Float3 Padding;
Float2 Padding;
float ClipPosZBias;
bool EnableDepthTest;
});
@@ -785,6 +786,7 @@ void DebugDraw::Draw(RenderContext& renderContext, GPUTextureView* target, GPUTe
Matrix vp;
Matrix::Multiply(view.View, view.Projection, vp);
Matrix::Transpose(vp, data.ViewProjection);
data.ClipPosZBias = -0.2f; // Reduce Z-fighting artifacts (eg. editor grid)
data.EnableDepthTest = enableDepthTest;
context->UpdateCB(cb, &data);
context->BindCB(0, cb);

View File

@@ -4,7 +4,8 @@
META_CB_BEGIN(0, Data)
float4x4 ViewProjection;
float3 Padding;
float2 Padding;
float ClipPosZBias;
bool EnableDepthTest;
META_CB_END
@@ -23,6 +24,7 @@ VS2PS VS(float3 Position : POSITION, float4 Color : COLOR)
{
VS2PS output;
output.Position = mul(float4(Position, 1), ViewProjection);
output.Position.z += ClipPosZBias;
output.Color = Color;
return output;
}