From bf0ea60018c799e3d57b5dbb3c614a772235d516 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sat, 9 May 2026 19:46:36 +0100 Subject: [PATCH] Intersect D3D12 Grid as transparent event --- docs/d3d12-migration.md | 43 ++-- docs/hlsl-renderer.md | 34 +-- src/Aquarium.Engine/Render/D3D12Renderer.cs | 28 +- .../Render/Shaders/D3D12Medium.hlsl | 176 ------------- .../Render/Shaders/D3D12Scene.hlsl | 243 ++++++++++++++++-- state/evidence.jsonl | 1 + state/memory.json | 2 +- state/scratch.md | 25 +- 8 files changed, 279 insertions(+), 273 deletions(-) diff --git a/docs/d3d12-migration.md b/docs/d3d12-migration.md index 0b3762e..95132e8 100644 --- a/docs/d3d12-migration.md +++ b/docs/d3d12-migration.md @@ -27,23 +27,29 @@ temporary visual reference until the old backend is deleted. and transport render targets from the field instance buffer. Render debug mode `11` now displays D3D12 froxel density, matching the future renderer path rather than the temporary Grid-height bring-up view. -- The D3D12 scene pass now renders Self, planets, and medium transport through - the D3D12 frame graph. Grid line transparency is injected as a thin medium - contribution in the froxel atlas instead of being drawn as an alpha surface or - used as a scene-depth terminator. +- The D3D12 scene pass now renders Self, planets, medium transport, and the + first transparent candidate event through the D3D12 frame graph. Grid line + transparency is no longer baked into the medium froxel atlas; the scene + traversal intersects the binned Grid height sheet, samples the height texture + at the hit position, evaluates cartesian lines, height isolines, and + gradient-angle field lines there, then composites that event without + terminating the ray. - The D3D12 scene pass now uses one bounded interval traversal for solids, medium, and transparent events. Each camera ray walks the medium slice - intervals, samples medium/event transport for that interval, looks up binned - solid candidates from the froxel primitive table at conservative interval - sample points, and stops at the nearest opaque hit after integrating transport - up to it. The current solid evaluator is still analytic spheres; the traversal - contract is ready for SDF surface evaluators and bracket/bisect refinements. + intervals, samples medium transport for that interval, looks up binned solid + and transparent candidates at conservative interval sample points, integrates + transport up to transparent events, composites those events without stopping, + and stops only on the nearest opaque hit after integrating transport up to it. + The current solid evaluator is still analytic spheres; the traversal contract + is ready for SDF surface evaluators, bracket/bisect refinements, and richer + particle event lists. - Transparent Grid contribution is now represented by a transparent-surface - table plus froxel-binned surface ids. The medium pass discovers it through the - froxel bin, so future particles and billboard-like surfaces can use the same - class of integration instead of gaining special alpha handling. The binned - Grid surface now carries cartesian gridlines, height isolines, and - gradient-angle field lines through that medium path. + table plus froxel-binned surface ids. The scene pass discovers transparent + candidates through the froxel bin, so future particles and billboard-like + surfaces can use the same event-intersection class instead of gaining special + alpha handling. The current Grid evaluator handles one ordered transparent + event per ray interval; the next expansion is a richer per-froxel event list + for many particles/quads. - D3D12 presentation is HDR-linear until the present pass. The scene renders to `R16G16B16A16_Float`, a three-level bloom pyramid performs firefly-safe downsample plus separable blur, and final presentation applies exposure, @@ -58,11 +64,10 @@ temporary visual reference until the old backend is deleted. hits. Debug mode `3` shows history age and mode `4` shows history weight. Medium-only pixels use a density-weighted ray centroid as their temporal anchor and a `FIELD_ID_MEDIUM` identity, with continuity weighted by medium - opacity and coverage rather than surface normals. The medium pass also writes - a generic transparent-event summary target for binned stochastic surfaces. - Scene identity can now use `FIELD_ID_TRANSPARENT_EVENT` with event support and - support-weighted travel, so Grid and future particles share temporal support - without becoming fake alpha surfaces or opaque depth hits. + opacity and coverage rather than surface normals. Transparent candidate + events write event support and support-weighted travel directly from the scene + traversal, so Grid and future particles can share temporal support without + becoming fake alpha surfaces or opaque depth hits. - D3D12 debug modes `9` and `10` are direct ray-step medium previews, not repainted atlas views. The resolve shader samples the field instance buffer for the requested `MediumDebugStep`, so density/transmittance diagnostics can diff --git a/docs/hlsl-renderer.md b/docs/hlsl-renderer.md index b93085b..892a899 100644 --- a/docs/hlsl-renderer.md +++ b/docs/hlsl-renderer.md @@ -88,13 +88,16 @@ renders a packed frustum froxel atlas into diagnostic and transport render targets from those field instances, and mode `11` displays the froxel density target. D3D12 final mode now renders Self, planets, medium transport, and transparent events through a bounded interval traversal. A camera ray walks the -medium depth intervals, integrates medium/event transport, looks up solid -candidates from the froxel primitive table at conservative interval sample -points, and stops at the nearest opaque hit after integrating transport up to -that travel. Grid transparency contributes to the froxel medium as a thin -binned transparent-surface layer, not as an alpha-blended surface or scene-depth -terminator. That binned Grid layer now carries cartesian gridlines, height -isolines, and gradient-angle field lines. D3D12 also owns an HDR scene target +medium depth intervals, integrates medium transport, looks up solid and +transparent candidates from froxel tables at conservative interval sample +points, composites transparent events without stopping, and stops only at the +nearest opaque hit after integrating transport up to that travel. Grid +transparency is a binned transparent candidate event, not an alpha-blended +surface, scene-depth terminator, or pre-averaged froxel medium sample. The +scene traversal intersects the Grid height sheet, samples the height texture at +the hit position, evaluates cartesian gridlines, height isolines, and +gradient-angle field lines there, then keeps marching. D3D12 also owns an HDR +scene target and bloom/present pass. Its scene pass now writes color/travel, field-id/normal metadata, and temporal-control targets, with debug modes `5` and `6` inspecting the current control and identity buffers. Its resolve pass @@ -102,10 +105,10 @@ now writes ping-pong history color, metadata, and control targets and validates opaque history with previous-camera reprojection plus field, travel, normal, neighborhood color, coverage, and medium-continuity checks. Debug modes `3` and `4` show history age and weight. Medium-only pixels use a density-weighted ray -centroid and `FIELD_ID_MEDIUM`; binned transparent surfaces emit a generic -transparent-event summary and `FIELD_ID_TRANSPARENT_EVENT`, so transparent Grid +centroid and `FIELD_ID_MEDIUM`; binned transparent events emit +`FIELD_ID_TRANSPARENT_EVENT` with support-weighted travel, so transparent Grid and future particles can accumulate through a distributed history path without -inventing a single alpha-surface hit. +pretending to be opaque. D3D12 debug modes `9` and `10` are direct ray-step density/transmittance previews from the field instance buffer, matching the D3D11 diagnostic contract rather than sampling the froxel atlas. Mode `11` remains the froxel density @@ -251,11 +254,12 @@ event-stream design in `docs/stochastic-transparent-surface-pipeline.md`, not to the scene first-hit surface path. A ray can encounter multiple transparent events; stochastic coverage may choose different events across frames; temporal validation compares distribution summaries instead of one canonical travel. In -D3D12 the medium pass writes a transparent-event summary target beside the -diagnostic and transport atlases. The scene pass uses event support plus -support-weighted travel to emit `FIELD_ID_TRANSPARENT_EVENT`, and the resolve -treats that identity as distributed medium-like history rather than a surface -normal/depth hit. +D3D12 the scene traversal discovers binned transparent candidates, intersects +them as ordered ray events, composites them front-to-back without terminating, +and emits `FIELD_ID_TRANSPARENT_EVENT` when event support is present. The +current Grid path handles one transparent event per interval; particles need the +same candidate/event pipe with a richer per-froxel event list and quad +intersection evaluator. The presentation path now applies an explicit exposure before display transformation and adds a low-gain pre-tonemap bloom/veil pyramid. The bloom diff --git a/src/Aquarium.Engine/Render/D3D12Renderer.cs b/src/Aquarium.Engine/Render/D3D12Renderer.cs index c63137b..80a71c4 100644 --- a/src/Aquarium.Engine/Render/D3D12Renderer.cs +++ b/src/Aquarium.Engine/Render/D3D12Renderer.cs @@ -95,7 +95,6 @@ public sealed class D3D12Renderer : IAquariumRenderer private D3D12RenderTarget gridHeightRenderTarget; private D3D12RenderTarget mediumVolumeRenderTarget; private D3D12RenderTarget mediumTransportRenderTarget; - private D3D12RenderTarget mediumEventRenderTarget; private D3D12RenderTarget sceneRenderTarget; private D3D12RenderTarget sceneMetadataRenderTarget; private D3D12RenderTarget sceneControlRenderTarget; @@ -184,7 +183,6 @@ public sealed class D3D12Renderer : IAquariumRenderer gridHeightRenderTarget = CreateGridHeightRenderTarget(); mediumVolumeRenderTarget = CreateMediumVolumeRenderTarget("medium-volume-target", "Aquarium D3D12 Medium Volume Target"); mediumTransportRenderTarget = CreateMediumVolumeRenderTarget("medium-transport-target", "Aquarium D3D12 Medium Transport Target"); - mediumEventRenderTarget = CreateMediumVolumeRenderTarget("medium-event-target", "Aquarium D3D12 Medium Transparent Event Target"); sceneRenderTarget = CreateSceneRenderTarget(); sceneMetadataRenderTarget = CreateSceneAuxiliaryRenderTarget("scene-metadata-target", "Aquarium D3D12 Scene Metadata Target"); sceneControlRenderTarget = CreateSceneAuxiliaryRenderTarget("scene-control-target", "Aquarium D3D12 Scene Control Target"); @@ -348,8 +346,6 @@ public sealed class D3D12Renderer : IAquariumRenderer mediumVolumeRenderTarget.CreateShaderResourceView(device, frameResources.MediumTargetsDescriptor); frameResources.MediumTransportDescriptor = frameResources.TransientShaderDescriptors.Allocate(); mediumTransportRenderTarget.CreateShaderResourceView(device, frameResources.MediumTransportDescriptor); - frameResources.MediumEventDescriptor = frameResources.TransientShaderDescriptors.Allocate(); - mediumEventRenderTarget.CreateShaderResourceView(device, frameResources.MediumEventDescriptor); frameResources.TransparentSurfaceIndexDescriptor = frameResources.TransientShaderDescriptors.Allocate(); transparentSurfaceIndexBuffer.CreateShaderResourceView(device, frameResources.TransparentSurfaceIndexDescriptor); frameResources.TransparentSurfaceDescriptor = frameResources.TransientShaderDescriptors.Allocate(); @@ -458,7 +454,6 @@ public sealed class D3D12Renderer : IAquariumRenderer sceneMetadataRenderTarget.Dispose(); sceneControlRenderTarget.Dispose(); mediumTransportRenderTarget.Dispose(); - mediumEventRenderTarget.Dispose(); mediumVolumeRenderTarget.Dispose(); gridHeightRenderTarget.Dispose(); for (var index = 0; index < frames.Length; index++) @@ -584,7 +579,6 @@ public sealed class D3D12Renderer : IAquariumRenderer sceneMetadataRenderTarget.Dispose(); sceneControlRenderTarget.Dispose(); mediumTransportRenderTarget.Dispose(); - mediumEventRenderTarget.Dispose(); mediumVolumeRenderTarget.Dispose(); gridHeightRenderTarget.Dispose(); for (var index = 0; index < frames.Length; index++) @@ -608,7 +602,6 @@ public sealed class D3D12Renderer : IAquariumRenderer gridHeightRenderTarget = CreateGridHeightRenderTarget(); mediumVolumeRenderTarget = CreateMediumVolumeRenderTarget("medium-volume-target", "Aquarium D3D12 Medium Volume Target"); mediumTransportRenderTarget = CreateMediumVolumeRenderTarget("medium-transport-target", "Aquarium D3D12 Medium Transport Target"); - mediumEventRenderTarget = CreateMediumVolumeRenderTarget("medium-event-target", "Aquarium D3D12 Medium Transparent Event Target"); sceneRenderTarget = CreateSceneRenderTarget(); sceneMetadataRenderTarget = CreateSceneAuxiliaryRenderTarget("scene-metadata-target", "Aquarium D3D12 Scene Metadata Target"); sceneControlRenderTarget = CreateSceneAuxiliaryRenderTarget("scene-control-target", "Aquarium D3D12 Scene Control Target"); @@ -771,7 +764,6 @@ public sealed class D3D12Renderer : IAquariumRenderer gridHeightRenderTarget.Transition(context.CommandList, ResourceStates.PixelShaderResource); mediumVolumeRenderTarget.Transition(context.CommandList, ResourceStates.PixelShaderResource); mediumTransportRenderTarget.Transition(context.CommandList, ResourceStates.PixelShaderResource); - mediumEventRenderTarget.Transition(context.CommandList, ResourceStates.PixelShaderResource); sceneRenderTarget.Transition(context.CommandList, ResourceStates.RenderTarget); sceneMetadataRenderTarget.Transition(context.CommandList, ResourceStates.RenderTarget); sceneControlRenderTarget.Transition(context.CommandList, ResourceStates.RenderTarget); @@ -786,7 +778,7 @@ public sealed class D3D12Renderer : IAquariumRenderer context.CommandList.SetGraphicsRootDescriptorTable(3, frameResources.FroxelPrimitiveDescriptor.Gpu); context.CommandList.SetGraphicsRootDescriptorTable(4, frameResources.FieldInstanceDescriptor.Gpu); context.CommandList.SetGraphicsRootDescriptorTable(5, frameResources.MediumTargetsDescriptor.Gpu); - context.CommandList.SetGraphicsRootDescriptorTable(13, frameResources.MediumEventDescriptor.Gpu); + context.CommandList.SetGraphicsRootDescriptorTable(6, frameResources.TransparentSurfaceIndexDescriptor.Gpu); context.CommandList.RSSetViewports(viewport); context.CommandList.RSSetScissorRects(scissorRect); context.CommandList.OMSetRenderTargets( @@ -1001,24 +993,19 @@ public sealed class D3D12Renderer : IAquariumRenderer gridHeightRenderTarget.Transition(activeCommandList, ResourceStates.PixelShaderResource); mediumVolumeRenderTarget.Transition(activeCommandList, ResourceStates.RenderTarget); mediumTransportRenderTarget.Transition(activeCommandList, ResourceStates.RenderTarget); - mediumEventRenderTarget.Transition(activeCommandList, ResourceStates.RenderTarget); activeCommandList.ClearRenderTargetView(mediumVolumeRenderTarget.RenderTargetView.Cpu, new Color4(0.0f, 1.0f, 0.0f, 0.0f)); activeCommandList.ClearRenderTargetView(mediumTransportRenderTarget.RenderTargetView.Cpu, new Color4(0.0f, 0.0f, 0.0f, 1.0f)); - activeCommandList.ClearRenderTargetView(mediumEventRenderTarget.RenderTargetView.Cpu, new Color4(0.0f, 0.0f, 0.0f, 0.0f)); activeCommandList.SetDescriptorHeaps(frameResources.TransientShaderDescriptors.Heap); activeCommandList.SetPipelineState(mediumVolumePipelineState); activeCommandList.SetGraphicsRootSignature(fullscreenRootSignature); activeCommandList.SetGraphicsRootDescriptorTable(0, frameResources.FrameConstantsDescriptor.Gpu); - activeCommandList.SetGraphicsRootDescriptorTable(1, frameResources.GridHeightDescriptor.Gpu); activeCommandList.SetGraphicsRootDescriptorTable(4, frameResources.FieldInstanceDescriptor.Gpu); - activeCommandList.SetGraphicsRootDescriptorTable(6, frameResources.TransparentSurfaceIndexDescriptor.Gpu); activeCommandList.RSSetViewports(mediumViewport); activeCommandList.RSSetScissorRects(mediumScissorRect); activeCommandList.OMSetRenderTargets( [ mediumVolumeRenderTarget.RenderTargetView.Cpu, mediumTransportRenderTarget.RenderTargetView.Cpu, - mediumEventRenderTarget.RenderTargetView.Cpu, ], null); activeCommandList.IASetPrimitiveTopology(PrimitiveTopology.TriangleList); @@ -1037,10 +1024,8 @@ public sealed class D3D12Renderer : IAquariumRenderer { mediumVolumeRenderTarget.Transition(activeCommandList, ResourceStates.RenderTarget); mediumTransportRenderTarget.Transition(activeCommandList, ResourceStates.RenderTarget); - mediumEventRenderTarget.Transition(activeCommandList, ResourceStates.RenderTarget); activeCommandList.ClearRenderTargetView(mediumVolumeRenderTarget.RenderTargetView.Cpu, new Color4(0.0f, 1.0f, 0.0f, 0.0f)); activeCommandList.ClearRenderTargetView(mediumTransportRenderTarget.RenderTargetView.Cpu, new Color4(0.0f, 0.0f, 0.0f, 1.0f)); - activeCommandList.ClearRenderTargetView(mediumEventRenderTarget.RenderTargetView.Cpu, new Color4(0.0f, 0.0f, 0.0f, 0.0f)); } finally { @@ -1497,12 +1482,6 @@ public sealed class D3D12Renderer : IAquariumRenderer 8, 0, D3D12.DescriptorRangeOffsetAppend); - var mediumEventRange = new DescriptorRange( - DescriptorRangeType.ShaderResourceView, - 1, - 17, - 0, - D3D12.DescriptorRangeOffsetAppend); var rootParameters = new[] { new RootParameter(new RootDescriptorTable([constantBufferRange]), ShaderVisibility.All), @@ -1518,7 +1497,6 @@ public sealed class D3D12Renderer : IAquariumRenderer new RootParameter(new RootDescriptorTable([historyRange]), ShaderVisibility.Pixel), new RootParameter(new RootDescriptorTable([historyMetadataRange]), ShaderVisibility.Pixel), new RootParameter(new RootDescriptorTable([historyControlRange]), ShaderVisibility.Pixel), - new RootParameter(new RootDescriptorTable([mediumEventRange]), ShaderVisibility.Pixel), }; var staticSamplers = new[] { @@ -1557,7 +1535,7 @@ public sealed class D3D12Renderer : IAquariumRenderer path, "FullscreenTriangleVS", "MediumVolumePS", - [MediumVolumeFormat, MediumVolumeFormat, MediumVolumeFormat]); + [MediumVolumeFormat, MediumVolumeFormat]); } private ID3D12PipelineState CreateMediumDensityDebugPipelineState(string path) @@ -1881,8 +1859,6 @@ public sealed class D3D12Renderer : IAquariumRenderer public D3D12DescriptorSlot MediumTransportDescriptor { get; set; } - public D3D12DescriptorSlot MediumEventDescriptor { get; set; } - public D3D12DescriptorSlot TransparentSurfaceIndexDescriptor { get; set; } public D3D12DescriptorSlot TransparentSurfaceDescriptor { get; set; } diff --git a/src/Aquarium.Engine/Render/Shaders/D3D12Medium.hlsl b/src/Aquarium.Engine/Render/Shaders/D3D12Medium.hlsl index 94f419a..3c1d173 100644 --- a/src/Aquarium.Engine/Render/Shaders/D3D12Medium.hlsl +++ b/src/Aquarium.Engine/Render/Shaders/D3D12Medium.hlsl @@ -32,34 +32,13 @@ struct FieldInstance float4 mediumTerms; }; -struct TransparentSurface -{ - float4 centerRadius; - float4 kindDensity; - float4 lineParams; - float4 colorScatter; -}; - StructuredBuffer fieldInstances : register(t12); -StructuredBuffer transparentSurfaceIds : register(t15); -StructuredBuffer transparentSurfaces : register(t16); -Texture2D gridHeightTexture : register(t0); -SamplerState gridSampler : register(s0); static const int FIELD_INSTANCE_COUNT = 10; static const int FIELD_FLAG_CLOUD = 2; -static const float PI = 3.14159265359; -static const float GRID_HEIGHT_TEXEL_COUNT = 128.0; -static const int FROXEL_COUNT_X = 8; -static const int FROXEL_COUNT_Y = 8; -static const int FROXEL_COUNT_Z = 4; -static const int FROXEL_SLOT_COUNT = 2; -static const float FROXEL_MIN_Z = -2.0; -static const float FROXEL_MAX_Z = 6.0; static const int MEDIUM_FROXEL_ATLAS_COLUMNS = 8; static const int MEDIUM_FROXEL_ATLAS_ROWS = 4; static const int MEDIUM_FROXEL_SLICE_COUNT = MEDIUM_FROXEL_ATLAS_COLUMNS * MEDIUM_FROXEL_ATLAS_ROWS; -static const float TERRAIN_ISOLINE_SPACING = 0.12; struct VertexOut { @@ -71,7 +50,6 @@ struct MediumVolumeOut { float4 diagnostic : SV_Target0; float4 transport : SV_Target1; - float4 eventSummary : SV_Target2; }; VertexOut FullscreenTriangleVS(uint vertexId : SV_VertexID) @@ -213,154 +191,6 @@ float registeredMediumDensity(float3 p, out float3 scattering) return saturate(density); } -float2 gridLocal(float2 p) -{ - return (p - gridCenter) / max(gridRadius, 0.001); -} - -float2 gridUv(float2 p) -{ - return gridLocal(p) * 0.5 + 0.5; -} - -float terrainHeight(float2 p) -{ - float2 uv = saturate(gridUv(p)); - return gridHeightTexture.SampleLevel(gridSampler, uv, 0.0).r; -} - -float2 terrainGradient(float2 p) -{ - float2 uv = saturate(gridUv(p)); - float2 texel = 1.0 / GRID_HEIGHT_TEXEL_COUNT; - float texelWorld = max((gridRadius * 2.0) / GRID_HEIGHT_TEXEL_COUNT, 0.001); - - float hLeft = gridHeightTexture.SampleLevel(gridSampler, uv - float2(texel.x, 0.0), 0.0).r; - float hRight = gridHeightTexture.SampleLevel(gridSampler, uv + float2(texel.x, 0.0), 0.0).r; - float hDown = gridHeightTexture.SampleLevel(gridSampler, uv - float2(0.0, texel.y), 0.0).r; - float hUp = gridHeightTexture.SampleLevel(gridSampler, uv + float2(0.0, texel.y), 0.0).r; - - return float2(hRight - hLeft, hUp - hDown) / (texelWorld * 2.0); -} - -float lineDistance(float2 p, float cell) -{ - float2 centered = abs(frac(p / cell + 0.5) - 0.5) * cell; - return min(centered.x, centered.y); -} - -float lineMaskFromDistance(float distanceValue, float width, float fade) -{ - return 1.0 - smoothstep(width, max(width + fade, width + 0.0001), distanceValue); -} - -float isolineMask(float height, float width) -{ - float wrapped = abs(frac(height / TERRAIN_ISOLINE_SPACING + 0.5) - 0.5) * TERRAIN_ISOLINE_SPACING; - return lineMaskFromDistance(wrapped, width, width * 1.8); -} - -float fieldLineMask(float2 gradient, float width) -{ - float slope = length(gradient); - if (slope < 0.0001) - { - return 0.0; - } - - float angleDomain = (atan2(gradient.y, gradient.x) / PI + 1.0) * 6.0; - float wrapped = abs(frac(angleDomain + 0.5) - 0.5); - float angleLine = lineMaskFromDistance(wrapped, width, width * 1.6); - float slopeStrength = smoothstep(0.015, 0.16, slope); - return angleLine * slopeStrength; -} - -int clampCell(float normalized, int count) -{ - return clamp((int)floor(normalized * (float)count), 0, count - 1); -} - -int froxelIndexForPosition(float3 p) -{ - float2 local = gridLocal(p.xy); - float localZ = (p.z - FROXEL_MIN_Z) / (FROXEL_MAX_Z - FROXEL_MIN_Z); - if (abs(local.x) > 1.0 || abs(local.y) > 1.0 || localZ < 0.0 || localZ > 1.0) - { - return -1; - } - - int x = clampCell(local.x * 0.5 + 0.5, FROXEL_COUNT_X); - int y = clampCell(local.y * 0.5 + 0.5, FROXEL_COUNT_Y); - int z = clampCell(localZ, FROXEL_COUNT_Z); - return x + y * FROXEL_COUNT_X + z * FROXEL_COUNT_X * FROXEL_COUNT_Y; -} - -float transparentSurfaceDensity(float3 p, TransparentSurface surface, out float3 scattering, out float eventSupport) -{ - scattering = 0.0; - eventSupport = 0.0; - float radius = max(surface.centerRadius.w, 0.001); - float2 local = (p.xy - surface.centerRadius.xy) / radius; - float radiusMask = 1.0 - smoothstep(0.92, 1.0, length(local)); - if (radiusMask <= 0.0) - { - return 0.0; - } - - float height = terrainHeight(p.xy); - float2 gradient = terrainGradient(p.xy); - float sheet = 1.0 - smoothstep(0.018, max(surface.kindDensity.w, 0.02), abs(p.z - height)); - float minor = lineMaskFromDistance(lineDistance(p.xy, surface.lineParams.x), 0.016, max(surface.lineParams.z, 0.016)); - float major = lineMaskFromDistance(lineDistance(p.xy, surface.lineParams.y), 0.030, max(surface.lineParams.w, 0.030)); - float contour = isolineMask(height, 0.012) * smoothstep(0.025, 0.25, length(gradient)); - float fieldLine = fieldLineMask(gradient, 0.038); - float lineSupport = saturate(minor * 0.38 + major * 0.92 + contour * 0.28 + fieldLine * 0.18); - float density = sheet * radiusMask * lineSupport; - float3 gridColor = surface.colorScatter.rgb * (minor * 0.30 + major * 0.74); - gridColor += float3(0.98, 1.0, 0.78) * contour * 0.16; - gridColor += float3(0.36, 0.92, 1.0) * fieldLine * 0.12; - scattering = gridColor * density * surface.colorScatter.w; - eventSupport = saturate(density); - return density * surface.kindDensity.y; -} - -float registeredTransparentSurfaceDensity(float3 p, out float3 scattering, out float eventSupport) -{ - scattering = 0.0; - eventSupport = 0.0; - float density = 0.0; - int froxelIndex = froxelIndexForPosition(p); - if (froxelIndex < 0) - { - return 0.0; - } - - [unroll] - for (int slotGroup = 0; slotGroup < FROXEL_SLOT_COUNT; slotGroup++) - { - int4 ids = transparentSurfaceIds[froxelIndex * FROXEL_SLOT_COUNT + slotGroup]; - [unroll] - for (int lane = 0; lane < 4; lane++) - { - int id = lane == 0 ? ids.x : lane == 1 ? ids.y : lane == 2 ? ids.z : ids.w; - if (id < 0) - { - continue; - } - - float3 surfaceScattering; - float surfaceSupport; - float surfaceDensity = transparentSurfaceDensity(p, transparentSurfaces[id], surfaceScattering, surfaceSupport); - density += surfaceDensity; - scattering += surfaceScattering; - eventSupport += surfaceSupport; - } - } - - eventSupport = saturate(eventSupport); - return saturate(density); -} - float mediumSliceTravel(int sliceIndex) { float t = ((float)sliceIndex + 0.5) / (float)MEDIUM_FROXEL_SLICE_COUNT; @@ -385,11 +215,6 @@ MediumVolumeOut MediumVolumePS(VertexOut input) float mediumBlend = saturate(mediumCompositeIntensity); density *= mediumBlend; scattering *= mediumBlend; - float3 gridScattering; - float transparentEventSupport; - float gridDensity = registeredTransparentSurfaceDensity(p, gridScattering, transparentEventSupport); - density = saturate(density + gridDensity); - scattering += gridScattering; float extinction = density * 0.16; float transmittance = exp(-extinction * sliceLength); float3 inScattering = density > 0.001 @@ -400,6 +225,5 @@ MediumVolumeOut MediumVolumePS(VertexOut input) MediumVolumeOut output; output.diagnostic = float4(saturate(density), saturate(transmittance), sourceDebug, 1.0); output.transport = float4(inScattering, saturate(transmittance)); - output.eventSummary = float4(transparentEventSupport, gridDensity, saturate(dot(gridScattering, float3(0.2126, 0.7152, 0.0722))), 1.0); return output; } diff --git a/src/Aquarium.Engine/Render/Shaders/D3D12Scene.hlsl b/src/Aquarium.Engine/Render/Shaders/D3D12Scene.hlsl index 6ee6791..6ead81e 100644 --- a/src/Aquarium.Engine/Render/Shaders/D3D12Scene.hlsl +++ b/src/Aquarium.Engine/Render/Shaders/D3D12Scene.hlsl @@ -26,9 +26,19 @@ Texture2D gridHeightTexture : register(t0); StructuredBuffer froxelPrimitiveIds : register(t1); Texture2D mediumVolumeTexture : register(t13); Texture2D mediumTransportTexture : register(t14); -Texture2D mediumEventTexture : register(t17); SamplerState gridSampler : register(s0); +struct TransparentSurface +{ + float4 centerRadius; + float4 kindDensity; + float4 lineParams; + float4 colorScatter; +}; + +StructuredBuffer transparentSurfaceIds : register(t15); +StructuredBuffer transparentSurfaces : register(t16); + static const int PLANET_COUNT = 5; static const float SUN_RADIUS = 1.12; static const float FIELD_ID_GRID = 1.0; @@ -45,6 +55,9 @@ static const int FROXEL_COUNT_Z = 4; static const int FROXEL_SLOT_COUNT = 2; static const float FROXEL_MIN_Z = -2.0; static const float FROXEL_MAX_Z = 6.0; +static const float PI = 3.14159265359; +static const float GRID_HEIGHT_TEXEL_COUNT = 128.0; +static const float TERRAIN_ISOLINE_SPACING = 0.12; struct VertexOut { @@ -68,6 +81,15 @@ struct SolidHit int primitiveId; }; +struct TransparentEvent +{ + bool hit; + float travel; + float3 color; + float alpha; + float coverage; +}; + struct RayMarchResult { float3 color; @@ -144,6 +166,52 @@ float terrainHeight(float2 p) return gridHeightTexture.SampleLevel(gridSampler, saturate(gridUv(p)), 0.0).r; } +float2 terrainGradient(float2 p) +{ + float2 uv = saturate(gridUv(p)); + float2 texel = 1.0 / GRID_HEIGHT_TEXEL_COUNT; + float texelWorld = max((gridRadius * 2.0) / GRID_HEIGHT_TEXEL_COUNT, 0.001); + + float hLeft = gridHeightTexture.SampleLevel(gridSampler, uv - float2(texel.x, 0.0), 0.0).r; + float hRight = gridHeightTexture.SampleLevel(gridSampler, uv + float2(texel.x, 0.0), 0.0).r; + float hDown = gridHeightTexture.SampleLevel(gridSampler, uv - float2(0.0, texel.y), 0.0).r; + float hUp = gridHeightTexture.SampleLevel(gridSampler, uv + float2(0.0, texel.y), 0.0).r; + + return float2(hRight - hLeft, hUp - hDown) / (texelWorld * 2.0); +} + +float lineDistance(float2 p, float cell) +{ + float2 centered = abs(frac(p / cell + 0.5) - 0.5) * cell; + return min(centered.x, centered.y); +} + +float lineMaskFromDistance(float distanceValue, float width, float fade) +{ + return 1.0 - smoothstep(width, max(width + fade, width + 0.0001), distanceValue); +} + +float isolineMask(float height, float width) +{ + float wrapped = abs(frac(height / TERRAIN_ISOLINE_SPACING + 0.5) - 0.5) * TERRAIN_ISOLINE_SPACING; + return lineMaskFromDistance(wrapped, width, width * 1.8); +} + +float fieldLineMask(float2 gradient, float width) +{ + float slope = length(gradient); + if (slope < 0.0001) + { + return 0.0; + } + + float angleDomain = (atan2(gradient.y, gradient.x) / PI + 1.0) * 6.0; + float wrapped = abs(frac(angleDomain + 0.5) - 0.5); + float angleLine = lineMaskFromDistance(wrapped, width, width * 1.6); + float slopeStrength = smoothstep(0.015, 0.16, slope); + return angleLine * slopeStrength; +} + bool traceSphere(float3 origin, float3 direction, float3 center, float radius, out float travel) { float3 oc = origin - center; @@ -275,7 +343,7 @@ SolidHit nearestBinnedSolidHit(float3 origin, float3 direction, float intervalSt return nearest; } -bool traceGrid(float3 origin, float3 direction, out float travel) +bool traceGridSurface(float3 origin, float3 direction, float intervalStart, float intervalEnd, TransparentSurface surface, out float travel) { travel = farDistance + 1.0; if (abs(direction.z) < 0.0001) @@ -289,12 +357,21 @@ bool traceGrid(float3 origin, float3 direction, out float travel) return false; } + [unroll] + for (int i = 0; i < 4; i++) + { + float3 p = origin + direction * t; + float height = terrainHeight(p.xy); + float2 gradient = terrainGradient(p.xy); + float signedDistance = p.z - height; + float derivative = direction.z - dot(gradient, direction.xy); + t -= signedDistance / (abs(derivative) > 0.0001 ? derivative : direction.z); + } + float3 p = origin + direction * t; - float h = terrainHeight(p.xy); - float correction = (h - p.z) / direction.z; - t += correction; - p = origin + direction * t; - if (t <= 0.0 || t >= farDistance || length(gridLocal(p.xy)) > 1.0) + float radius = max(surface.centerRadius.w, 0.001); + float2 local = (p.xy - surface.centerRadius.xy) / radius; + if (t <= intervalStart || t >= intervalEnd || t >= farDistance || length(local) > 1.0) { return false; } @@ -303,6 +380,89 @@ bool traceGrid(float3 origin, float3 direction, out float travel) return true; } +float3 gridEventColor(float3 p, TransparentSurface surface, out float alpha) +{ + float height = terrainHeight(p.xy); + float2 gradient = terrainGradient(p.xy); + float2 footprint = max(abs(ddx(p.xy)), abs(ddy(p.xy))); + float pixelWidth = max(max(footprint.x, footprint.y), 0.006); + float minor = lineMaskFromDistance(lineDistance(p.xy, surface.lineParams.x), pixelWidth * 0.56, pixelWidth * 1.35); + float major = lineMaskFromDistance(lineDistance(p.xy, surface.lineParams.y), pixelWidth * 0.88, pixelWidth * 1.60); + float contour = isolineMask(height, max(pixelWidth * 0.52, 0.010)) * smoothstep(0.025, 0.25, length(gradient)); + float fieldLine = fieldLineMask(gradient, max(pixelWidth * 0.90, 0.016)); + float support = saturate(minor * 0.38 + major * 0.92 + contour * 0.28 + fieldLine * 0.18); + float3 color = surface.colorScatter.rgb * (minor * 0.30 + major * 0.74); + color += float3(0.98, 1.0, 0.78) * contour * 0.16; + color += float3(0.36, 0.92, 1.0) * fieldLine * 0.12; + alpha = saturate(support * surface.colorScatter.w); + return color; +} + +void considerTransparentSurfaceEvent(float3 origin, float3 direction, int surfaceId, float intervalStart, float intervalEnd, inout TransparentEvent nearest) +{ + if (surfaceId < 0) + { + return; + } + + TransparentSurface surface = transparentSurfaces[surfaceId]; + float travel; + if (!traceGridSurface(origin, direction, intervalStart, min(intervalEnd, nearest.travel), surface, travel)) + { + return; + } + + float3 p = origin + direction * travel; + float alpha; + float3 color = gridEventColor(p, surface, alpha); + if (alpha <= 0.001) + { + return; + } + + nearest.hit = true; + nearest.travel = travel; + nearest.color = color; + nearest.alpha = alpha; + nearest.coverage = alpha; +} + +void considerFroxelTransparentEvents(float3 origin, float3 direction, int froxelIndex, float intervalStart, float intervalEnd, inout TransparentEvent nearest) +{ + if (froxelIndex < 0) + { + return; + } + + [unroll] + for (int slotGroup = 0; slotGroup < FROXEL_SLOT_COUNT; slotGroup++) + { + int4 ids = transparentSurfaceIds[froxelIndex * FROXEL_SLOT_COUNT + slotGroup]; + considerTransparentSurfaceEvent(origin, direction, ids.x, intervalStart, intervalEnd, nearest); + considerTransparentSurfaceEvent(origin, direction, ids.y, intervalStart, intervalEnd, nearest); + considerTransparentSurfaceEvent(origin, direction, ids.z, intervalStart, intervalEnd, nearest); + considerTransparentSurfaceEvent(origin, direction, ids.w, intervalStart, intervalEnd, nearest); + } +} + +TransparentEvent nearestBinnedTransparentEvent(float3 origin, float3 direction, float intervalStart, float intervalEnd) +{ + TransparentEvent nearest; + nearest.hit = false; + nearest.travel = intervalEnd; + nearest.color = 0.0; + nearest.alpha = 0.0; + nearest.coverage = 0.0; + + float3 startPoint = origin + direction * intervalStart; + float3 midPoint = origin + direction * ((intervalStart + intervalEnd) * 0.5); + float3 endPoint = origin + direction * intervalEnd; + considerFroxelTransparentEvents(origin, direction, froxelIndexForPosition(startPoint), intervalStart, intervalEnd, nearest); + considerFroxelTransparentEvents(origin, direction, froxelIndexForPosition(midPoint), intervalStart, intervalEnd, nearest); + considerFroxelTransparentEvents(origin, direction, froxelIndexForPosition(endPoint), intervalStart, intervalEnd, nearest); + return nearest; +} + float2 mediumAtlasUv(float2 uv, int sliceIndex) { int tileX = sliceIndex % MEDIUM_FROXEL_ATLAS_COLUMNS; @@ -341,7 +501,6 @@ void integrateMediumSlice( float2 atlasUv = mediumAtlasUv(uv, sliceIndex); float4 diagnostic = mediumVolumeTexture.SampleLevel(gridSampler, atlasUv, 0.0); float4 transport = mediumTransportTexture.SampleLevel(gridSampler, atlasUv, 0.0); - float4 eventSummary = mediumEventTexture.SampleLevel(gridSampler, atlasUv, 0.0); float sliceTravel = mediumSliceTravel(sliceIndex); float fraction = saturate(intervalFraction); float fullSliceTransmittance = saturate(transport.a); @@ -350,13 +509,10 @@ void integrateMediumSlice( float scatterDenominator = max(1.0 - fullSliceTransmittance, 0.0001); float scatterFraction = (1.0 - partialTransmittance) / scatterDenominator; float densityContribution = diagnostic.x * fraction; - float eventSupport = saturate(eventSummary.x) * fraction; densityMean += densityContribution; densityTravelSum += densityContribution * sliceTravel; densitySum += densityContribution; - eventTravelSum += eventSupport * sliceTravel; - eventSupportSum += eventSupport; inScattering += transmittance * transport.rgb * scatterFraction; transmittance *= saturate(partialTransmittance); } @@ -444,21 +600,58 @@ RayMarchResult traverseRay(float2 uv, float3 origin, float3 direction) float intervalStart = mediumSliceStartTravel(sliceIndex); float intervalEnd = mediumSliceEndTravel(sliceIndex); SolidHit hit = nearestBinnedSolidHit(origin, direction, intervalStart, min(intervalEnd, farDistance)); - float intervalFraction = hit.hit - ? saturate((hit.travel - intervalStart) / max(intervalEnd - intervalStart, 0.0001)) - : 1.0; + TransparentEvent transparentEvent = nearestBinnedTransparentEvent(origin, direction, intervalStart, min(intervalEnd, farDistance)); + float intervalLength = max(intervalEnd - intervalStart, 0.0001); + float intervalStop = hit.hit ? hit.travel : min(intervalEnd, farDistance); - integrateMediumSlice( - uv, - sliceIndex, - intervalFraction, - transmittance, - inScattering, - densityAccumulation, - densityTravelSum, - densitySum, - eventTravelSum, - eventSupportSum); + if (transparentEvent.hit && transparentEvent.travel < intervalStop) + { + float beforeEventFraction = saturate((transparentEvent.travel - intervalStart) / intervalLength); + integrateMediumSlice( + uv, + sliceIndex, + beforeEventFraction, + transmittance, + inScattering, + densityAccumulation, + densityTravelSum, + densitySum, + eventTravelSum, + eventSupportSum); + + inScattering += transmittance * transparentEvent.color * transparentEvent.alpha; + transmittance *= 1.0 - transparentEvent.alpha; + eventTravelSum += transparentEvent.coverage * transparentEvent.travel; + eventSupportSum += transparentEvent.coverage; + + float afterEventFraction = saturate((intervalStop - transparentEvent.travel) / intervalLength); + integrateMediumSlice( + uv, + sliceIndex, + afterEventFraction, + transmittance, + inScattering, + densityAccumulation, + densityTravelSum, + densitySum, + eventTravelSum, + eventSupportSum); + } + else + { + float intervalFraction = saturate((intervalStop - intervalStart) / intervalLength); + integrateMediumSlice( + uv, + sliceIndex, + intervalFraction, + transmittance, + inScattering, + densityAccumulation, + densityTravelSum, + densitySum, + eventTravelSum, + eventSupportSum); + } if (hit.hit) { diff --git a/state/evidence.jsonl b/state/evidence.jsonl index 1e4785e..7a41e7c 100644 --- a/state/evidence.jsonl +++ b/state/evidence.jsonl @@ -87,3 +87,4 @@ {"area":"renderer/d3d12/overlay","lesson":"D3D12 debug overlay parity uses the official D3D11On12 bridge to preserve native DirectWrite/Direct2D hinted text. The D3D12 frame graph owns scene rendering and leaves the backbuffer as a render target; the overlay briefly acquires the current wrapped swapchain image, draws the shared retained DebugUi, releases it to Present, and marks the tracked resource state. Keep this bridge narrow and overlay-only; diegetic text remains MSDF/SDF renderer work.","files":["src/Aquarium.Engine/Render/D3D12Renderer.cs","src/Aquarium.Engine/Render/D3D12TrackedResource.cs","docs/d3d12-migration.md","docs/hlsl-renderer.md","state/scratch.md"],"verification":["dotnet build Aquarium.Engine.slnx",".\\scripts\\dev-reload.ps1 -Headless -RetainSlots 4 -HeadlessTimeoutSeconds 30 with AQUARIUM_RENDERER=d3d12 and AQUARIUM_RENDER_DEBUG_MODE=0 exited 0",".\\scripts\\dev-reload.ps1 -Headless -RetainSlots 4 -HeadlessTimeoutSeconds 30 with AQUARIUM_RENDERER=d3d12 and AQUARIUM_RENDER_DEBUG_MODE=11 exited 0"],"ts":"2026-05-09"} {"area":"renderer/d3d12/parity","lesson":"D3D12 is now the default Aquarium renderer. D3D11 remains selectable as the temporary reference backend, but host startup uses D3D12 unless --renderer or AQUARIUM_RENDERER overrides it. The D3D12 backend reports once-per-second steady-state CPU timing averages for total frame work, command-list recording, and the DirectWrite overlay bridge after skipping warmup frames so the bridge cost has a useful receipt while GPU timestamp instrumentation is still pending.","files":["src/Aquarium.Engine/AquariumHost.cs","src/Aquarium.Engine/Render/D3D12Renderer.cs","docs/d3d12-migration.md","docs/hlsl-renderer.md","docs/d3d12-best-practices-audit.md","state/scratch.md"],"verification":["dotnet build Aquarium.Engine.slnx",".\\scripts\\dev-reload.ps1 -Headless -RetainSlots 4 -HeadlessTimeoutSeconds 30 without AQUARIUM_RENDERER exited 0 and logged D3D12 device/swapchain creation",".\\scripts\\dev-reload.ps1 -Headless -RetainSlots 4 -HeadlessTimeoutSeconds 30 with AQUARIUM_RENDERER=d3d11 exited 0"],"ts":"2026-05-09"} {"area":"renderer/d3d12/unified-traversal","lesson":"D3D12 scene composition now uses one bounded ray interval traversal for solids, medium transport, and transparent events. Each interval samples medium/event transport, checks conservative start/mid/end froxel primitive bins for solid candidates, integrates partial transport up to the first opaque hit, and emits one ordered temporal packet. Current solid evaluators are analytic spheres, but future SDF surfaces should replace that evaluator inside this traversal rather than reintroducing a separate solid pass.","files":["src/Aquarium.Engine/Render/Shaders/D3D12Scene.hlsl","docs/d3d12-migration.md","docs/d3d12-best-practices-audit.md","docs/hlsl-renderer.md","state/scratch.md"],"verification":["dotnet build Aquarium.Engine.slnx",".\\scripts\\dev-reload.ps1 -Headless -RetainSlots 4 -HeadlessTimeoutSeconds 30 with default D3D12 final mode exited 0",".\\scripts\\dev-reload.ps1 -Headless -RetainSlots 4 -HeadlessTimeoutSeconds 30 with default D3D12 field-identity mode exited 0"],"ts":"2026-05-09"} +{"area":"renderer/d3d12/transparent-events","lesson":"Grid linework must not be represented as a pre-averaged medium froxel summary. D3D12 now treats the Grid as a froxel-binned transparent candidate: the scene traversal intersects the Grid height sheet, samples the height texture at the ray hit, evaluates cartesian lines, height isolines, and gradient-angle field lines there, composites the event without terminating, and keeps marching. Future particles and billboards need the same candidate/event pipe with quad intersections and richer per-froxel event lists, not alpha side channels or atlas summaries.","files":["src/Aquarium.Engine/Render/D3D12Renderer.cs","src/Aquarium.Engine/Render/Shaders/D3D12Medium.hlsl","src/Aquarium.Engine/Render/Shaders/D3D12Scene.hlsl","docs/d3d12-migration.md","docs/hlsl-renderer.md","state/memory.json","state/scratch.md"],"verification":["dotnet build Aquarium.Engine.slnx",".\\scripts\\dev-reload.ps1 -Headless -RetainSlots 4 -HeadlessTimeoutSeconds 30 with default D3D12 final mode exited 0 and shader stderr empty"],"ts":"2026-05-09"} diff --git a/state/memory.json b/state/memory.json index aec48f1..4ee575c 100644 --- a/state/memory.json +++ b/state/memory.json @@ -19,7 +19,7 @@ "D3D12 previous-frame camera/Grid/time state must be renderer-level temporal state, not per-swapchain-frame-resource state. The swapchain image index is an allocator/reuse index, not frame history.", "D3D12 Grid height must be brush-rendered, not a fullscreen per-texel loop over bodies. Use a top-down Grid-space orthographic brush pass: base field draw, then one additive up-facing quad per body into a scalar R16_Float height target. Height is one value; do not spend extra channels unless the pass contract actually gains more data. Do not use R32G32B32A32_Float for additive brush composition.", "D3D12 field data should live in default-heap structured buffers, updated from the per-frame upload ring by CopyBufferRegion, then bound through transient SRV descriptors owned by the consuming pass. Do not make shaders read dynamic field tables straight from upload memory. D3D11 is reference-only during migration; do not pay DRY tax to preserve it.", - "Transparent D3D12 surfaces must enter the same froxel/field integration path as volumetrics. Grid line transparency currently contributes to the D3D12 medium atlas through a transparent-surface table and froxel-binned surface ids, and must not also terminate scene depth; future transparent particles and billboard surfaces should extend that bin path rather than alpha side channels.", + "Transparent D3D12 surfaces must enter the same froxel/field candidate path as volumetrics, but not as pre-averaged froxel color. Grid line transparency is now a scene-traversal transparent event: the ray intersects the binned Grid height sheet, samples the height texture at the hit, evaluates cartesian lines/isolines/field lines there, composites without terminating, and keeps marching. Future transparent particles and billboard surfaces need the same candidate/event pipe with quad intersections and richer per-froxel event lists rather than alpha side channels or medium-atlas summaries.", "D3D12 pixel shader UAV registers share the output namespace. If a shader writes SV_Target0, bind the first manual UAV at u1, not u0.", "D3D12 shader routing must not inherit the D3D11 --shader-source override by accident. Backend-specific HLSL should compile from its copied output path unless an explicit backend-specific override exists.", "Use Vortice at the graphics API membrane. Keep CultMath as the CPU math grammar. Do not let third-party math opinions leak inward unless the conversion is explicit.", diff --git a/state/scratch.md b/state/scratch.md index 24f4e52..d77437d 100644 --- a/state/scratch.md +++ b/state/scratch.md @@ -285,10 +285,13 @@ the cut. atlases from the D3D12 field instance buffer. Render debug mode `11` displays D3D12 froxel density; the temporary Grid-height debug view was cut rather than left as stale bring-up scaffolding. -- D3D12 first scene pass: final mode now renders a D3D12 scene instead of smoke. - Self, planets, and medium transport are visible through the D3D12 frame graph. - Grid line transparency is injected into the medium froxel atlas as a thin - participating layer and is not traced as a surface terminator. +- D3D12 transparent candidate scene pass: Grid line transparency is no longer + injected into the medium froxel atlas. The scene traversal binds the + transparent surface table, discovers the binned Grid candidate through froxel + ids, intersects the Grid height sheet, evaluates cartesian gridlines, height + isolines, and gradient-angle field lines at the actual ray hit, composites the + transparent event without terminating, and continues marching toward medium + and opaque SDF/solid hits. - D3D12 transparent-surface bins: Grid line transparency now flows through a transparent surface table plus froxel-binned transparent surface ids. The medium shader discovers the Grid layer through the froxel bin, not through a @@ -328,13 +331,13 @@ the cut. implements direct ray-step registered-medium previews for modes 9 and 10. These are correctness probes independent of the froxel atlas; mode 11 remains the atlas density view. -- D3D12 transparent event temporal pass: the medium pass now writes a third - froxel atlas target for generic transparent-event support. The scene pass - samples that summary, derives support-weighted event travel, and emits - `FIELD_ID_TRANSPARENT_EVENT` for Grid/particle-class contributions. Resolve - treats medium and transparent-event identities as distributed history, not - opaque surfaces, so Grid is not special-cased and future stochastic billboards - can join the same path. +- D3D12 transparent event traversal pass: the scene pass now derives + transparent-event support and support-weighted travel from intersected + candidates instead of a froxel summary. This fixes the Grid blur/undersampling + failure caused by sampling linework once per low-resolution medium atlas + slice. The current implementation handles one transparent event per ray + interval; particles/billboards need the same pipe with richer per-froxel event + lists and quad intersection evaluators. - D3D12 overlay parity pass: DirectWrite/Direct2D debug UI remains native hinted overlay text through the documented D3D11On12 bridge. D3D12 renders the frame and leaves the backbuffer in render-target state; the bridge acquires the