diff --git a/Content/Shaders/DebugDraw.flax b/Content/Shaders/DebugDraw.flax index 284c55f64..455cf8c20 100644 --- a/Content/Shaders/DebugDraw.flax +++ b/Content/Shaders/DebugDraw.flax @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:10fefac1db81c41041c95970dc13694a17dfbca09819d6f7344b5d45f5e8c0df -size 2060 +oid sha256:7f8833a76cdda54b6c1de3b98f7993b835d17a5ac60b0bf11a9ee9faa42cc177 +size 2108 diff --git a/Source/Engine/Debug/DebugDraw.cpp b/Source/Engine/Debug/DebugDraw.cpp index fe6424565..ea8cdb196 100644 --- a/Source/Engine/Debug/DebugDraw.cpp +++ b/Source/Engine/Debug/DebugDraw.cpp @@ -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); diff --git a/Source/Shaders/DebugDraw.shader b/Source/Shaders/DebugDraw.shader index 6495cb1a3..d10dbbf06 100644 --- a/Source/Shaders/DebugDraw.shader +++ b/Source/Shaders/DebugDraw.shader @@ -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; }