From 1488ec62b7242342f05c736ff9e45bfef33e87a8 Mon Sep 17 00:00:00 2001 From: Erik Date: Sun, 10 May 2026 08:27:03 +0200 Subject: [PATCH] test(A.5 T21): lock in depth-write attribution per translucency kind MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Per Phase A.5 spec §4.9.3 audit: opaque + ClipMap pass uses DepthMask(true); AlphaBlend / Additive / InvAlpha pass uses DepthMask(false), restored after. Audit confirmed correct in WbDrawDispatcher.Draw. IsOpaquePublic shim already present. Add WbDispatcherDepthMaskTests: 5-case Theory that pins the partition so future regressions surface immediately. Co-Authored-By: Claude Opus 4.7 (1M context) --- .../Wb/WbDispatcherDepthMaskTests.cs | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 tests/AcDream.Core.Tests/Rendering/Wb/WbDispatcherDepthMaskTests.cs diff --git a/tests/AcDream.Core.Tests/Rendering/Wb/WbDispatcherDepthMaskTests.cs b/tests/AcDream.Core.Tests/Rendering/Wb/WbDispatcherDepthMaskTests.cs new file mode 100644 index 0000000..216a736 --- /dev/null +++ b/tests/AcDream.Core.Tests/Rendering/Wb/WbDispatcherDepthMaskTests.cs @@ -0,0 +1,39 @@ +using AcDream.App.Rendering.Wb; +using AcDream.Core.Meshing; +using Xunit; + +namespace AcDream.Core.Tests.Rendering.Wb; + +/// +/// A.5 T21: lock in the depth-write attribution per translucency kind. +/// +/// WbDrawDispatcher.Draw uses a two-pass structure: +/// +/// Opaque pass — DepthMask(true): writes depth so that +/// later transparent geometry sorts correctly against solid surfaces. +/// Transparent pass — DepthMask(false): reads depth but +/// does NOT write it, so alpha-blended surfaces don't occlude each +/// other by Z-fighting. +/// +/// The partition that decides which pass a batch enters is +/// : +/// Opaque and ClipMap go to the opaque pass (depth write); +/// AlphaBlend, Additive, InvAlpha go to the +/// transparent pass (no depth write). +/// +/// +public sealed class WbDispatcherDepthMaskTests +{ + [Theory] + [InlineData(TranslucencyKind.Opaque, true)] // opaque pass — depth write + [InlineData(TranslucencyKind.ClipMap, true)] // foliage — depth write (binary alpha / A2C) + [InlineData(TranslucencyKind.AlphaBlend, false)] // transparent — no depth write + [InlineData(TranslucencyKind.Additive, false)] + [InlineData(TranslucencyKind.InvAlpha, false)] + public void IsOpaquePartition_ImpliesDepthWriteAttribution( + TranslucencyKind kind, bool expectsDepthWrite) + { + bool isOpaque = WbDrawDispatcher.IsOpaquePublic(kind); + Assert.Equal(expectsDepthWrite, isOpaque); + } +}