Fix Z-fighting issues in Debug Draw when using TAA
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user