bvle-voxels/shaders/voxelAOApplyCS.hlsl
Samuel Bouchet 9de53e5293 Phase 6.3: RT ambient occlusion with bilateral blur
- 8 cosine-weighted hemisphere rays per pixel (inline ray queries, SM 6.5)
- Distance-weighted AO: quadratic falloff (1-hitT/aoRadius)² instead of binary hit/miss
- World-space hash seed: voxel coord + tangent-plane frac position (stable, no flicker)
- Bilateral blur pipeline: 2-pass separable (H+V), radius 6, depth+normal edge-stopping
- 4-pass dispatch: shadow+rawAO → blur H → blur V → apply
- AO written to separate R8_UNORM texture, blurred, then applied to color buffer
- Debug mode (F5 x3): grayscale AO visualization
2026-03-29 09:31:19 +02:00

32 lines
918 B
HLSL

// BVLE Voxels - AO Apply Compute Shader (Phase 6.3)
// Multiplies the blurred AO factor onto the color buffer.
#include "voxelCommon.hlsli"
Texture2D<float> aoBlurred : register(t0);
RWTexture2D<float4> colorOutput : register(u0);
struct ApplyPush {
uint width;
uint height;
uint debugMode; // 0=normal, 2=debug AO (show AO as grayscale)
uint pad[9];
};
[[vk::push_constant]] ConstantBuffer<ApplyPush> push : register(b999);
[RootSignature(VOXEL_ROOTSIG)]
[numthreads(8, 8, 1)]
void main(uint3 DTid : SV_DispatchThreadID) {
if (DTid.x >= push.width || DTid.y >= push.height) return;
float ao = aoBlurred[DTid.xy];
if (push.debugMode == 2) {
// Debug AO: grayscale visualization of blurred AO
colorOutput[DTid.xy] = float4(ao, ao, ao, 1);
} else {
float4 color = colorOutput[DTid.xy];
color.rgb *= ao;
colorOutput[DTid.xy] = color;
}
}