minor voxel radiance update
This commit is contained in:
@@ -67,7 +67,7 @@ RendererWindow::RendererWindow(Renderable3DComponent* component)
|
||||
voxelRadianceSecondaryBounceCheckBox->SetCheck(wiRenderer::GetVoxelRadianceSecondaryBounceEnabled());
|
||||
rendererWindow->AddWidget(voxelRadianceSecondaryBounceCheckBox);
|
||||
|
||||
voxelRadianceVoxelSizeSlider = new wiSlider(0.25, 10, 1, 39, "Voxel GI Voxel Size: ");
|
||||
voxelRadianceVoxelSizeSlider = new wiSlider(0.125, 10, 1, 79, "Voxel GI Voxel Size: ");
|
||||
voxelRadianceVoxelSizeSlider->SetTooltip("Adjust the voxel size for Voxel GI calculations.");
|
||||
voxelRadianceVoxelSizeSlider->SetSize(XMFLOAT2(100, 30));
|
||||
voxelRadianceVoxelSizeSlider->SetPos(XMFLOAT2(x, y += 30));
|
||||
|
||||
@@ -76,7 +76,7 @@ inline float4 ConeTraceReflection(in Texture3D<float4> voxels, in float3 uvw, in
|
||||
float4 accumulation = 0;
|
||||
float3 tc = uvw + coneVec;
|
||||
float rayLengthCorrection = 1 - saturate(dot(N, V));
|
||||
coneVec *= lerp(g_xWorld_VoxelRadianceDataSize * 0.5f, g_xWorld_VoxelRadianceDataSize * 40, pow8(rayLengthCorrection));
|
||||
coneVec *= lerp(g_xWorld_VoxelRadianceDataSize, g_xWorld_VoxelRadianceDataSize * 40, pow8(rayLengthCorrection));
|
||||
|
||||
uint i = 0;
|
||||
while(accumulation.a < 1 && !any(tc - saturate(tc)))
|
||||
@@ -85,7 +85,7 @@ inline float4 ConeTraceReflection(in Texture3D<float4> voxels, in float3 uvw, in
|
||||
|
||||
tc += coneVec * (1 + mip);
|
||||
|
||||
float4 sam = voxels.SampleLevel(sampler_linear_clamp, tc, mip);
|
||||
float4 sam = voxels.SampleLevel(sampler_point_clamp, tc, mip);
|
||||
accumulation.a += sam.a;
|
||||
accumulation.rgb += sam.rgb * sam.a;
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ RWTEXTURE3D(output, float4, 0);
|
||||
[numthreads(1024, 1, 1)]
|
||||
void main( uint3 DTid : SV_DispatchThreadID )
|
||||
{
|
||||
uint3 writecoord = to3D(DTid.x, g_xWorld_VoxelRadianceDataRes);
|
||||
const uint3 writecoord = to3D(DTid.x, g_xWorld_VoxelRadianceDataRes);
|
||||
|
||||
float4 emission = input_emission[writecoord];
|
||||
|
||||
@@ -24,8 +24,6 @@ void main( uint3 DTid : SV_DispatchThreadID )
|
||||
float4 radiance = ConeTraceRadiance(input_emission, uvw, N);
|
||||
|
||||
output[writecoord] = emission + float4(radiance.rgb, 0);
|
||||
//output[writecoord] = float4(radiance.rgb, 1);
|
||||
//output[writecoord] = float4(N, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -4,33 +4,27 @@
|
||||
#define TEMPORAL_SMOOTHING
|
||||
|
||||
RWSTRUCTUREDBUFFER(input_output, VoxelType, 0);
|
||||
globallycoherent RWTEXTURE3D(output_emission, float4, 1);
|
||||
RWTEXTURE3D(output_emission, float4, 1);
|
||||
|
||||
[numthreads(1024, 1, 1)]
|
||||
void main( uint3 DTid : SV_DispatchThreadID )
|
||||
{
|
||||
VoxelType voxel = input_output[DTid.x];
|
||||
|
||||
float4 color = DecodeColor(voxel.colorMask);
|
||||
const float4 color = DecodeColor(voxel.colorMask);
|
||||
|
||||
uint3 writecoord = to3D(DTid.x, g_xWorld_VoxelRadianceDataRes);
|
||||
|
||||
//#ifdef TEMPORAL_SMOOTHING
|
||||
// uint3 loadPrev = writecoord + floor((g_xWorld_VoxelRadianceDataCenter - g_xWorld_VoxelRadianceDataInterpolatedCenter) * float3(1,-1,1));
|
||||
// loadPrev = clamp(loadPrev, 0, g_xWorld_VoxelRadianceDataRes);
|
||||
// float4 colorPrev = output_emission[loadPrev];
|
||||
// DeviceMemoryBarrier();
|
||||
//#endif
|
||||
const uint3 writecoord = to3D(DTid.x, g_xWorld_VoxelRadianceDataRes);
|
||||
|
||||
[branch]
|
||||
if (color.a > 0)
|
||||
{
|
||||
#ifdef TEMPORAL_SMOOTHING
|
||||
//output_emission[writecoord] = lerp(output_emission[writecoord], float4(color.rgb, 1), 0.1);
|
||||
|
||||
// Blend voxels with the previous frame's data to avoid popping artifacts for dynamic objects:
|
||||
[branch]
|
||||
if (g_xColor.z > 0)
|
||||
{
|
||||
// Do not perform the blend if an offset happened to the voxel grid's center.
|
||||
// The offset is not accounted for in the blend operation which can introduce severe light leaking.
|
||||
output_emission[writecoord] = float4(color.rgb, 1);
|
||||
}
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user