Bin transparent surfaces for D3D12 medium
This commit is contained in:
parent
4014164334
commit
09bcd693dc
10 changed files with 217 additions and 23 deletions
|
|
@ -49,6 +49,11 @@ resource graph beyond smoke-pass scaffolding.
|
|||
contribution is sampled into the medium atlas as a thin participating layer,
|
||||
so it is integrated with volumetrics rather than alpha-blended or used to
|
||||
occlude the ray.
|
||||
- The transparent Grid layer is no longer hardcoded as a medium-special case:
|
||||
D3D12 now uploads a transparent-surface table and a froxel-binned transparent
|
||||
surface id buffer, then the medium shader resolves transparent contributions
|
||||
through that bin. This is the pipeline shape particles and billboards should
|
||||
grow into.
|
||||
- Renderer calls receive current window dimensions, and the D3D12 backend can
|
||||
recreate swapchain buffers plus dependent smoke resources on resize.
|
||||
- Resize waits for the GPU, disposes swapchain-dependent targets, rebuilds
|
||||
|
|
@ -77,9 +82,8 @@ resource graph beyond smoke-pass scaffolding.
|
|||
post-process graph needs it; otherwise present from the final render target
|
||||
path with no ornamental copy.
|
||||
- The D3D12 scene pass is still a first parity slice: no full temporal resolve,
|
||||
bloom pyramid, full terrain line shader, or transparent-surface bin table yet.
|
||||
The transparency contract is correct; the implementation still needs the
|
||||
general binned transparent surface representation.
|
||||
bloom pyramid, or full terrain line shader yet. The transparent-surface bin
|
||||
exists but currently has only the Grid layer as its first registered surface.
|
||||
- D3D11 and D3D12 field table builders are temporarily duplicated by design.
|
||||
D3D11 is reference-only and will be removed after migration; do not pay DRY
|
||||
tax merely to preserve it.
|
||||
|
|
|
|||
|
|
@ -36,6 +36,10 @@ has feature parity.
|
|||
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.
|
||||
- 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.
|
||||
- Resize waits for the GPU, releases swapchain-dependent resources, rebuilds
|
||||
static shader/RTV descriptor arenas, then recreates backbuffer views and
|
||||
dependent render targets. Descriptor exhaustion on resize is no longer a
|
||||
|
|
|
|||
|
|
@ -88,9 +88,9 @@ 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 a first scene pass for Self, planets, and
|
||||
medium transport. Grid line transparency contributes to the froxel medium as a
|
||||
thin participating layer, not as an alpha-blended surface or scene-depth
|
||||
terminator. The full temporal resolve, bloom pyramid, and full Grid line shader
|
||||
still need to move.
|
||||
thin binned transparent-surface layer, not as an alpha-blended surface or
|
||||
scene-depth terminator. The full temporal resolve, bloom pyramid, and full Grid
|
||||
line shader still need to move.
|
||||
|
||||
The shader far distance is frame-derived, not a fixed constant. C# sends the
|
||||
distance from the camera to the Grid origin plus the Grid radius, which matches
|
||||
|
|
|
|||
|
|
@ -28,6 +28,8 @@ public sealed class D3D12Renderer : IAquariumRenderer
|
|||
private const int FroxelSlotCount = 2;
|
||||
private const int FroxelBufferElementCount = FroxelCountX * FroxelCountY * FroxelCountZ * FroxelSlotCount;
|
||||
private const int FieldInstanceCount = PlanetCount + 5;
|
||||
private const int TransparentSurfaceCount = 1;
|
||||
private const int TransparentSurfaceBufferElementCount = FroxelBufferElementCount;
|
||||
private const float SunRadius = 1.12f;
|
||||
private const float FroxelMinZ = -2.0f;
|
||||
private const float FroxelMaxZ = 6.0f;
|
||||
|
|
@ -62,8 +64,12 @@ public sealed class D3D12Renderer : IAquariumRenderer
|
|||
private D3D12RenderTarget diagnosticUavTarget;
|
||||
private readonly D3D12StructuredBuffer froxelPrimitiveBuffer;
|
||||
private readonly D3D12StructuredBuffer fieldInstanceBuffer;
|
||||
private readonly D3D12StructuredBuffer transparentSurfaceIndexBuffer;
|
||||
private readonly D3D12StructuredBuffer transparentSurfaceBuffer;
|
||||
private readonly Int4[] froxelPrimitiveIds = new Int4[FroxelBufferElementCount];
|
||||
private readonly FieldInstanceGpu[] fieldInstances = new FieldInstanceGpu[FieldInstanceCount];
|
||||
private readonly Int4[] transparentSurfaceIds = new Int4[TransparentSurfaceBufferElementCount];
|
||||
private readonly TransparentSurfaceGpu[] transparentSurfaces = new TransparentSurfaceGpu[TransparentSurfaceCount];
|
||||
private Viewport viewport;
|
||||
private RawRect scissorRect;
|
||||
private int width;
|
||||
|
|
@ -134,8 +140,12 @@ public sealed class D3D12Renderer : IAquariumRenderer
|
|||
diagnosticUavTarget = CreateDiagnosticUavTarget();
|
||||
froxelPrimitiveBuffer = new D3D12StructuredBuffer(device, FroxelBufferElementCount, Marshal.SizeOf<Int4>(), "Aquarium D3D12 Froxel Primitive Buffer");
|
||||
fieldInstanceBuffer = new D3D12StructuredBuffer(device, FieldInstanceCount, Marshal.SizeOf<FieldInstanceGpu>(), "Aquarium D3D12 Field Instance Buffer");
|
||||
transparentSurfaceIndexBuffer = new D3D12StructuredBuffer(device, TransparentSurfaceBufferElementCount, Marshal.SizeOf<Int4>(), "Aquarium D3D12 Transparent Surface Index Buffer");
|
||||
transparentSurfaceBuffer = new D3D12StructuredBuffer(device, TransparentSurfaceCount, Marshal.SizeOf<TransparentSurfaceGpu>(), "Aquarium D3D12 Transparent Surface Buffer");
|
||||
resourceRegistry.Add("froxel-primitive-buffer", froxelPrimitiveBuffer);
|
||||
resourceRegistry.Add("field-instance-buffer", fieldInstanceBuffer);
|
||||
resourceRegistry.Add("transparent-surface-index-buffer", transparentSurfaceIndexBuffer);
|
||||
resourceRegistry.Add("transparent-surface-buffer", transparentSurfaceBuffer);
|
||||
commandList = device.CreateCommandList<ID3D12GraphicsCommandList>(0, CommandListType.Direct, frames[frameIndex].CommandAllocator, null);
|
||||
commandList.Name = "Aquarium D3D12 Graphics Command List";
|
||||
commandList.Close();
|
||||
|
|
@ -220,6 +230,7 @@ public sealed class D3D12Renderer : IAquariumRenderer
|
|||
BuildGridHeightBrushes(frame);
|
||||
BuildFroxelPrimitiveTable(frame);
|
||||
BuildFieldInstanceTable(frame);
|
||||
BuildTransparentSurfaceTable(frame);
|
||||
var frameConstants = frameResources.UploadRing.WriteConstant(new FrameConstants(
|
||||
new Vector2(width, height),
|
||||
frame.TimeSeconds,
|
||||
|
|
@ -274,6 +285,10 @@ public sealed class D3D12Renderer : IAquariumRenderer
|
|||
mediumVolumeRenderTarget.CreateShaderResourceView(device, frameResources.MediumTargetsDescriptor);
|
||||
frameResources.MediumTransportDescriptor = frameResources.TransientShaderDescriptors.Allocate();
|
||||
mediumTransportRenderTarget.CreateShaderResourceView(device, frameResources.MediumTransportDescriptor);
|
||||
frameResources.TransparentSurfaceIndexDescriptor = frameResources.TransientShaderDescriptors.Allocate();
|
||||
transparentSurfaceIndexBuffer.CreateShaderResourceView(device, frameResources.TransparentSurfaceIndexDescriptor);
|
||||
frameResources.TransparentSurfaceDescriptor = frameResources.TransientShaderDescriptors.Allocate();
|
||||
transparentSurfaceBuffer.CreateShaderResourceView(device, frameResources.TransparentSurfaceDescriptor);
|
||||
frameResources.CommandAllocator.Reset();
|
||||
commandList.Reset(frameResources.CommandAllocator, null);
|
||||
|
||||
|
|
@ -321,6 +336,8 @@ public sealed class D3D12Renderer : IAquariumRenderer
|
|||
fullscreenRootSignature.Dispose();
|
||||
fieldInstanceBuffer.Dispose();
|
||||
froxelPrimitiveBuffer.Dispose();
|
||||
transparentSurfaceBuffer.Dispose();
|
||||
transparentSurfaceIndexBuffer.Dispose();
|
||||
diagnosticUavTarget.Dispose();
|
||||
smokeRenderTarget.Dispose();
|
||||
mediumTransportRenderTarget.Dispose();
|
||||
|
|
@ -545,6 +562,8 @@ public sealed class D3D12Renderer : IAquariumRenderer
|
|||
{
|
||||
froxelPrimitiveBuffer.Upload(activeCommandList, frameResources.UploadRing, froxelPrimitiveIds);
|
||||
fieldInstanceBuffer.Upload(activeCommandList, frameResources.UploadRing, fieldInstances);
|
||||
transparentSurfaceIndexBuffer.Upload(activeCommandList, frameResources.UploadRing, transparentSurfaceIds);
|
||||
transparentSurfaceBuffer.Upload(activeCommandList, frameResources.UploadRing, transparentSurfaces);
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
|
@ -600,6 +619,7 @@ public sealed class D3D12Renderer : IAquariumRenderer
|
|||
activeCommandList.SetGraphicsRootDescriptorTable(0, frameResources.FrameConstantsDescriptor.Gpu);
|
||||
activeCommandList.SetGraphicsRootDescriptorTable(1, frameResources.GridHeightDescriptor.Gpu);
|
||||
activeCommandList.SetGraphicsRootDescriptorTable(5, frameResources.FieldInstanceDescriptor.Gpu);
|
||||
activeCommandList.SetGraphicsRootDescriptorTable(7, frameResources.TransparentSurfaceIndexDescriptor.Gpu);
|
||||
activeCommandList.RSSetViewports(mediumViewport);
|
||||
activeCommandList.RSSetScissorRects(mediumScissorRect);
|
||||
activeCommandList.OMSetRenderTargets(
|
||||
|
|
@ -844,6 +864,79 @@ public sealed class D3D12Renderer : IAquariumRenderer
|
|||
medium: new Vector4(0.190f, 0.130f, 0.0f, 1.20f));
|
||||
}
|
||||
|
||||
private void BuildTransparentSurfaceTable(AquariumFrame frame)
|
||||
{
|
||||
for (var i = 0; i < transparentSurfaceIds.Length; i++)
|
||||
{
|
||||
transparentSurfaceIds[i] = new Int4(-1, -1, -1, -1);
|
||||
}
|
||||
|
||||
transparentSurfaces[0] = new TransparentSurfaceGpu(
|
||||
new Vector4(frame.Grid.Center.X, frame.Grid.Center.Y, 0.0f, MathF.Max(frame.Grid.Radius, 0.001f)),
|
||||
new Vector4(1.0f, 0.42f, 0.24f, 0.075f),
|
||||
new Vector4(2.0f, 10.0f, 0.055f, 0.090f),
|
||||
new Vector4(0.30f, 0.90f, 0.82f, 0.24f));
|
||||
|
||||
var min = new Vector3(
|
||||
frame.Grid.Center.X - frame.Grid.Radius,
|
||||
frame.Grid.Center.Y - frame.Grid.Radius,
|
||||
FroxelMinZ);
|
||||
var max = new Vector3(
|
||||
frame.Grid.Center.X + frame.Grid.Radius,
|
||||
frame.Grid.Center.Y + frame.Grid.Radius,
|
||||
FroxelMaxZ);
|
||||
var minCell = FroxelCellForPosition(frame, min);
|
||||
var maxCell = FroxelCellForPosition(frame, max);
|
||||
for (var z = minCell.Z; z <= maxCell.Z; z++)
|
||||
{
|
||||
for (var y = minCell.Y; y <= maxCell.Y; y++)
|
||||
{
|
||||
for (var x = minCell.X; x <= maxCell.X; x++)
|
||||
{
|
||||
AddTransparentSurfaceToFroxel(FroxelIndex(x, y, z), 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void AddTransparentSurfaceToFroxel(int froxelIndex, int surfaceId)
|
||||
{
|
||||
var baseElement = froxelIndex * FroxelSlotCount;
|
||||
for (var slotGroup = 0; slotGroup < FroxelSlotCount; slotGroup++)
|
||||
{
|
||||
var elementIndex = baseElement + slotGroup;
|
||||
var element = transparentSurfaceIds[elementIndex];
|
||||
if (element.X == surfaceId || element.Y == surfaceId || element.Z == surfaceId || element.W == surfaceId)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (element.X == -1)
|
||||
{
|
||||
transparentSurfaceIds[elementIndex] = element with { X = surfaceId };
|
||||
return;
|
||||
}
|
||||
|
||||
if (element.Y == -1)
|
||||
{
|
||||
transparentSurfaceIds[elementIndex] = element with { Y = surfaceId };
|
||||
return;
|
||||
}
|
||||
|
||||
if (element.Z == -1)
|
||||
{
|
||||
transparentSurfaceIds[elementIndex] = element with { Z = surfaceId };
|
||||
return;
|
||||
}
|
||||
|
||||
if (element.W == -1)
|
||||
{
|
||||
transparentSurfaceIds[elementIndex] = element with { W = surfaceId };
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void SignalFrame(FrameResources frameResources)
|
||||
{
|
||||
var signalValue = ++fenceValue;
|
||||
|
|
@ -955,6 +1048,12 @@ public sealed class D3D12Renderer : IAquariumRenderer
|
|||
13,
|
||||
0,
|
||||
D3D12.DescriptorRangeOffsetAppend);
|
||||
var transparentSurfaceRange = new DescriptorRange(
|
||||
DescriptorRangeType.ShaderResourceView,
|
||||
2,
|
||||
15,
|
||||
0,
|
||||
D3D12.DescriptorRangeOffsetAppend);
|
||||
var rootParameters = new[]
|
||||
{
|
||||
new RootParameter(new RootDescriptorTable([constantBufferRange]), ShaderVisibility.All),
|
||||
|
|
@ -964,6 +1063,7 @@ public sealed class D3D12Renderer : IAquariumRenderer
|
|||
new RootParameter(new RootDescriptorTable([froxelPrimitiveRange]), ShaderVisibility.Pixel),
|
||||
new RootParameter(new RootDescriptorTable([fieldInstanceRange]), ShaderVisibility.Pixel),
|
||||
new RootParameter(new RootDescriptorTable([mediumTargetRange]), ShaderVisibility.Pixel),
|
||||
new RootParameter(new RootDescriptorTable([transparentSurfaceRange]), ShaderVisibility.Pixel),
|
||||
};
|
||||
var staticSamplers = new[]
|
||||
{
|
||||
|
|
@ -1278,6 +1378,13 @@ public sealed class D3D12Renderer : IAquariumRenderer
|
|||
}
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
private readonly record struct TransparentSurfaceGpu(
|
||||
Vector4 CenterRadius,
|
||||
Vector4 KindDensity,
|
||||
Vector4 LineParams,
|
||||
Vector4 ColorScatter);
|
||||
|
||||
private sealed class FrameResources(
|
||||
ID3D12CommandAllocator commandAllocator,
|
||||
D3D12UploadRing uploadRing,
|
||||
|
|
@ -1307,6 +1414,10 @@ public sealed class D3D12Renderer : IAquariumRenderer
|
|||
|
||||
public D3D12DescriptorSlot MediumTransportDescriptor { get; set; }
|
||||
|
||||
public D3D12DescriptorSlot TransparentSurfaceIndexDescriptor { get; set; }
|
||||
|
||||
public D3D12DescriptorSlot TransparentSurfaceDescriptor { get; set; }
|
||||
|
||||
public D3D12TrackedResource BackBuffer { get; set; } = null!;
|
||||
|
||||
public D3D12DescriptorSlot BackBufferRenderTargetView { get; set; }
|
||||
|
|
|
|||
|
|
@ -32,17 +32,31 @@ struct FieldInstance
|
|||
float4 mediumTerms;
|
||||
};
|
||||
|
||||
struct TransparentSurface
|
||||
{
|
||||
float4 centerRadius;
|
||||
float4 kindDensity;
|
||||
float4 lineParams;
|
||||
float4 colorScatter;
|
||||
};
|
||||
|
||||
StructuredBuffer<FieldInstance> fieldInstances : register(t12);
|
||||
StructuredBuffer<int4> transparentSurfaceIds : register(t15);
|
||||
StructuredBuffer<TransparentSurface> transparentSurfaces : register(t16);
|
||||
Texture2D<float4> gridHeightTexture : register(t0);
|
||||
SamplerState gridSampler : register(s0);
|
||||
|
||||
static const int FIELD_INSTANCE_COUNT = 10;
|
||||
static const int FIELD_FLAG_CLOUD = 2;
|
||||
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 GRID_LINE_WORLD_CELL = 2.0;
|
||||
static const float GRID_MAJOR_LINE_WORLD_CELL = GRID_LINE_WORLD_CELL * 5.0;
|
||||
|
||||
struct VertexOut
|
||||
{
|
||||
|
|
@ -217,22 +231,77 @@ float lineDistance(float2 p, float cell)
|
|||
return min(centered.x, centered.y);
|
||||
}
|
||||
|
||||
float transparentGridDensity(float3 p, out float3 scattering)
|
||||
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)
|
||||
{
|
||||
scattering = 0.0;
|
||||
float radiusMask = 1.0 - smoothstep(0.92, 1.0, length(gridLocal(p.xy)));
|
||||
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);
|
||||
float sheet = 1.0 - smoothstep(0.018, 0.075, abs(p.z - height));
|
||||
float minor = 1.0 - smoothstep(0.016, 0.055, lineDistance(p.xy, GRID_LINE_WORLD_CELL));
|
||||
float major = 1.0 - smoothstep(0.030, 0.090, lineDistance(p.xy, GRID_MAJOR_LINE_WORLD_CELL));
|
||||
float sheet = 1.0 - smoothstep(0.018, max(surface.kindDensity.w, 0.02), abs(p.z - height));
|
||||
float minor = 1.0 - smoothstep(0.016, max(surface.lineParams.z, 0.016), lineDistance(p.xy, surface.lineParams.x));
|
||||
float major = 1.0 - smoothstep(0.030, max(surface.lineParams.w, 0.030), lineDistance(p.xy, surface.lineParams.y));
|
||||
float density = sheet * radiusMask * saturate(minor * 0.42 + major * 0.92);
|
||||
scattering = float3(0.30, 0.90, 0.82) * density * 0.24;
|
||||
return density * 0.42;
|
||||
scattering = surface.colorScatter.rgb * density * surface.colorScatter.w;
|
||||
return density * surface.kindDensity.y;
|
||||
}
|
||||
|
||||
float registeredTransparentSurfaceDensity(float3 p, out float3 scattering)
|
||||
{
|
||||
scattering = 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 surfaceDensity = transparentSurfaceDensity(p, transparentSurfaces[id], surfaceScattering);
|
||||
density += surfaceDensity;
|
||||
scattering += surfaceScattering;
|
||||
}
|
||||
}
|
||||
|
||||
return saturate(density);
|
||||
}
|
||||
|
||||
float mediumSliceTravel(int sliceIndex)
|
||||
|
|
@ -256,8 +325,11 @@ MediumVolumeOut MediumVolumePS(VertexOut input)
|
|||
float3 p = cameraPosition + rayDirection * travel;
|
||||
float3 scattering;
|
||||
float density = registeredMediumDensity(p, scattering);
|
||||
float mediumBlend = saturate(mediumCompositeIntensity);
|
||||
density *= mediumBlend;
|
||||
scattering *= mediumBlend;
|
||||
float3 gridScattering;
|
||||
float gridDensity = transparentGridDensity(p, gridScattering);
|
||||
float gridDensity = registeredTransparentSurfaceDensity(p, gridScattering);
|
||||
density = saturate(density + gridDensity);
|
||||
scattering += gridScattering;
|
||||
float extinction = density * 0.16;
|
||||
|
|
|
|||
|
|
@ -251,8 +251,7 @@ float4 D3D12ScenePS(VertexOut input) : SV_Target0
|
|||
float3 inScattering;
|
||||
float mediumTravel = travel <= farDistance ? travel : farDistance;
|
||||
integrateMedium(input.uv, mediumTravel, densityMean, transmittance, inScattering);
|
||||
float mediumBlend = saturate(mediumCompositeIntensity);
|
||||
color = color * lerp(1.0, transmittance, mediumBlend) + inScattering * mediumBlend;
|
||||
color = color * transmittance + inScattering;
|
||||
|
||||
if (renderDebugMode >= 10.5 && renderDebugMode < 11.5)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -76,3 +76,4 @@
|
|||
{"area":"renderer/d3d12","lesson":"D3D12 now has the first real Aquarium field data upload path: froxel primitive ids and field instances are built on CPU, uploaded through the per-frame upload ring, copied into default-heap structured buffers, and bound through transient SRV descriptors for a shader that actually reads them. Static and transient CBV/SRV/UAV heaps cannot be co-bound; pass-visible descriptor tables need to live in the active transient heap or be copied there. D3D11 is reference-only during migration, so duplicate table-building code is acceptable when it keeps the D3D12 path moving toward ownership.","files":["src/Aquarium.Engine/Render/D3D12UploadRing.cs","src/Aquarium.Engine/Render/D3D12StructuredBuffer.cs","src/Aquarium.Engine/Render/D3D12ResourceRegistry.cs","src/Aquarium.Engine/Render/D3D12Renderer.cs","src/Aquarium.Engine/Render/Shaders/D3D12Smoke.hlsl","docs/d3d12-migration.md","docs/d3d12-best-practices-audit.md","docs/hlsl-renderer.md","state/memory.json","state/scratch.md"],"verification":["dotnet build src\\Aquarium.Engine\\Aquarium.Engine.csproj",".\\scripts\\dev-reload.ps1 -Headless -RetainSlots 4 -HeadlessTimeoutSeconds 20 with AQUARIUM_RENDERER=d3d12 and AQUARIUM_RENDER_DEBUG_MODE=0 exited 0",".\\scripts\\dev-reload.ps1 -Headless -RetainSlots 4 -HeadlessTimeoutSeconds 20 with AQUARIUM_RENDERER=d3d12 and AQUARIUM_RENDER_DEBUG_MODE=11 exited 0","dotnet build Aquarium.Engine.slnx"],"ts":"2026-05-09"}
|
||||
{"area":"renderer/d3d12","lesson":"D3D12 now renders the first medium froxel atlas pass into diagnostic and transport render targets from the field instance structured buffer. Render debug mode 11 displays D3D12 froxel density, and the old D3D12 Grid-height debug PSO was removed instead of preserving stale bring-up scaffolding.","files":["src/Aquarium.Engine/Render/D3D12Renderer.cs","src/Aquarium.Engine/Render/Shaders/D3D12Medium.hlsl","src/Aquarium.Engine/Render/Shaders/D3D12Smoke.hlsl","docs/d3d12-migration.md","docs/d3d12-best-practices-audit.md","docs/hlsl-renderer.md","state/map.yaml","state/scratch.md"],"verification":["dotnet build src\\Aquarium.Engine\\Aquarium.Engine.csproj","dotnet build Aquarium.Engine.slnx",".\\scripts\\dev-reload.ps1 -Headless -RetainSlots 4 -HeadlessTimeoutSeconds 20 with AQUARIUM_RENDERER=d3d12 and AQUARIUM_RENDER_DEBUG_MODE=11 exited 0",".\\scripts\\dev-reload.ps1 -Headless -RetainSlots 4 -HeadlessTimeoutSeconds 20 with AQUARIUM_RENDERER=d3d12 and AQUARIUM_RENDER_DEBUG_MODE=0 exited 0"],"ts":"2026-05-09"}
|
||||
{"area":"renderer/d3d12","lesson":"D3D12 final mode now renders a first real scene pass instead of smoke: Self, planets, and medium transport are composed from D3D12 resources. Grid line transparency is injected into the medium froxel atlas as a thin participating layer and is not used as a scene-depth terminator; transparent surfaces should enter the same binned froxel/field integration path as volumetrics rather than alpha-blending as a separate class.","files":["src/Aquarium.Engine/Render/D3D12RenderTarget.cs","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/d3d12-best-practices-audit.md","docs/hlsl-renderer.md","state/map.yaml","state/memory.json","state/scratch.md"],"verification":["dotnet build src\\Aquarium.Engine\\Aquarium.Engine.csproj","dotnet build Aquarium.Engine.slnx",".\\scripts\\dev-reload.ps1 -Headless -RetainSlots 4 -HeadlessTimeoutSeconds 20 with AQUARIUM_RENDERER=d3d12 and AQUARIUM_RENDER_DEBUG_MODE=0 exited 0",".\\scripts\\dev-reload.ps1 -Headless -RetainSlots 4 -HeadlessTimeoutSeconds 20 with AQUARIUM_RENDERER=d3d12 and AQUARIUM_RENDER_DEBUG_MODE=11 exited 0"],"ts":"2026-05-09"}
|
||||
{"area":"renderer/d3d12","lesson":"Transparent Grid contribution is now routed through an explicit transparent-surface table and froxel-binned transparent surface id buffer. The medium pass resolves transparent surface density/scattering by looking up the current froxel, so Grid/particles/billboards can share the same integration class instead of becoming alpha-blended scene-depth exceptions. The Medium Composite knob gates registered cloud media, while binned transparent surfaces still contribute to transport.","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/d3d12-best-practices-audit.md","docs/hlsl-renderer.md","state/map.yaml","state/memory.json","state/scratch.md"],"verification":["dotnet build src\\Aquarium.Engine\\Aquarium.Engine.csproj","dotnet build Aquarium.Engine.slnx",".\\scripts\\dev-reload.ps1 -Headless -RetainSlots 4 -HeadlessTimeoutSeconds 20 with AQUARIUM_RENDERER=d3d12 and AQUARIUM_RENDER_DEBUG_MODE=0 exited 0",".\\scripts\\dev-reload.ps1 -Headless -RetainSlots 4 -HeadlessTimeoutSeconds 20 with AQUARIUM_RENDERER=d3d12 and AQUARIUM_RENDER_DEBUG_MODE=11 exited 0"],"ts":"2026-05-09"}
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ renderer_state:
|
|||
- Direct2D/DirectWrite debug UI panel with code-first controls bound to renderer state.
|
||||
- Global GraphicsSettings document feeding render debug, exposure, bloom intensity, bloom veil, and medium composite intensity.
|
||||
- First field instance structured buffer feeding a half-resolution registered medium diagnostic/transport pass.
|
||||
- Parallel D3D12 scaffold behind IAquariumRenderer proving device/queue/swapchain, per-frame command allocators, fences, static/transient descriptor arenas, upload ring constants, RTV/SRV/UAV render targets, structured field buffers, tracked barriers, command events, resize descriptor-arena rebuild, the migrated Grid height pass, the first medium froxel atlas pass, and a first D3D12 scene pass.
|
||||
- Parallel D3D12 scaffold behind IAquariumRenderer proving device/queue/swapchain, per-frame command allocators, fences, static/transient descriptor arenas, upload ring constants, RTV/SRV/UAV render targets, structured field buffers, transparent-surface bins, tracked barriers, command events, resize descriptor-arena rebuild, the migrated Grid height pass, the first medium froxel atlas pass, and a first D3D12 scene pass.
|
||||
- Splash screen with bundled app icon and GameCult typefaces.
|
||||
next:
|
||||
- Port the D3D12 temporal resolve, bloom pyramid, full Grid line shader, and general binned transparent-surface representation.
|
||||
|
|
|
|||
|
|
@ -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 as a thin participating layer and must not also terminate scene depth; future transparent particles/surfaces need a general binned surface representation rather than alpha side channels.",
|
||||
"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.",
|
||||
"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.",
|
||||
|
|
|
|||
|
|
@ -293,6 +293,9 @@ can start porting real passes while keeping D3D11 as the visual reference.
|
|||
- 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. This honors the
|
||||
transparency lesson, though the general transparent-surface bin table is still
|
||||
future work.
|
||||
participating layer and is not traced as a surface terminator.
|
||||
- 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
|
||||
hardcoded alpha/composite side path. This is the first implementation of the
|
||||
particle/billboard transparency contract.
|
||||
|
|
|
|||
Loading…
Reference in a new issue