From 26f249e596d9974713428a51df41851aee288473 Mon Sep 17 00:00:00 2001 From: turanszkij Date: Mon, 13 Mar 2017 02:01:38 +0100 Subject: [PATCH] voxel radiance update --- WickedEngine/voxelConeTracingHF.hlsli | 8 ++++---- WickedEngine/voxelSceneCopyClearCS.hlsl | 2 -- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/WickedEngine/voxelConeTracingHF.hlsli b/WickedEngine/voxelConeTracingHF.hlsli index 4652f33cd..6b88cbc6e 100644 --- a/WickedEngine/voxelConeTracingHF.hlsli +++ b/WickedEngine/voxelConeTracingHF.hlsli @@ -34,26 +34,26 @@ inline float4 ConeTraceRadiance(in Texture3D voxels, in float3 uvw, in f float4 radiance = 0; for (uint cone = 0; cone < numCones; ++cone) { + // try to approximate a hemisphere from normal and random point inside a sphere: float3 coneVec = normalize(N * 2 + CONES[cone]) / g_xWorld_VoxelRadianceDataRes * float3(1, -1, 1); float4 accumulation = 0; - float step = 0; float3 tc = uvw; for (uint i = 0; i < g_xWorld_VoxelRadianceDataRes; ++i) { - step++; float mip = 0.7 * i; tc += coneVec * (1 + mip); float4 sam = voxels.SampleLevel(sampler_linear_clamp, tc, mip); accumulation.a += sam.a; - accumulation.rgb += sam.rgb * accumulation.a / g_xWorld_VoxelRadianceFalloff; + accumulation.rgb += sam.rgb * accumulation.a; if (accumulation.a >= 1.0f || mip >= (float)mips || any(tc - saturate(tc))) break; } - radiance += accumulation / step; + float searchDist = length(uvw - tc) * g_xWorld_VoxelRadianceDataRes * g_xWorld_VoxelRadianceFalloff; + radiance += accumulation / searchDist; } radiance /= numCones; radiance.a = saturate(radiance.a); diff --git a/WickedEngine/voxelSceneCopyClearCS.hlsl b/WickedEngine/voxelSceneCopyClearCS.hlsl index 4f0d7cf5d..bc307bb80 100644 --- a/WickedEngine/voxelSceneCopyClearCS.hlsl +++ b/WickedEngine/voxelSceneCopyClearCS.hlsl @@ -16,8 +16,6 @@ void main( uint3 DTid : SV_DispatchThreadID ) [branch] if (color.a > 0) { - // try to make it temporally more stable: - //output_emission[writecoord] = lerp(output_emission[writecoord], float4(color.rgb, 1), 0.1); output_emission[writecoord] = float4(color.rgb, 1); } else