diff --git a/WickedEngine/shaders/voxelConeTracingHF.hlsli b/WickedEngine/shaders/voxelConeTracingHF.hlsli index af9a8ce57..d8cbccc4b 100644 --- a/WickedEngine/shaders/voxelConeTracingHF.hlsli +++ b/WickedEngine/shaders/voxelConeTracingHF.hlsli @@ -4,10 +4,6 @@ // With help from: https://github.com/compix/VoxelConeTracingGI/blob/master/assets/shaders/voxelConeTracing/finalLightingPass.frag -#ifndef VOXEL_INITIAL_OFFSET -#define VOXEL_INITIAL_OFFSET 1 -#endif // VOXEL_INITIAL_OFFSET - inline float4 SampleVoxelClipMap(in Texture3D voxels, in float3 P, in uint clipmap_index, float step_dist, in float3 face_offsets, in float3 direction_weights, uint precomputed_direction = 0) { VoxelClipMap clipmap = GetFrame().vxgi.clipmaps[clipmap_index]; @@ -63,7 +59,7 @@ inline float4 ConeTrace(in Texture3D voxels, in float3 P, in float3 N, i // We need to offset the cone start position to avoid sampling its own voxel (self-occlusion): float dist = voxelSize0; // offset by cone dir so that first sample of all cones are not the same float step_dist = dist; - float3 startPos = P + N * voxelSize0 * VOXEL_INITIAL_OFFSET * SQRT2; // sqrt2 is diagonal voxel half-extent + float3 startPos = P + N * voxelSize0; float3 aniso_direction = -coneDirection; float3 face_offsets = float3( @@ -108,19 +104,18 @@ inline float4 ConeTrace(in Texture3D voxels, in float3 P, in float3 N, i alpha += a * sam.a; float stepSizeCurrent = stepSize; - if (use_sdf) { // half texel correction is applied to avoid sampling over current clipmap: const float half_texel = 0.5 * GetFrame().vxgi.resolution_rcp; - tc = clamp(tc, half_texel, 1 - half_texel); - tc.y = (tc.y + clipmap_index) / VXGI_CLIPMAP_COUNT; // remap into clipmap - float sdf = bindless_textures3D[GetFrame().vxgi.texture_sdf].SampleLevel(sampler_linear_clamp, tc, 0).r; + float3 tc0 = clamp(tc, half_texel, 1 - half_texel); + tc0.y = (tc0.y + clipmap_index) / VXGI_CLIPMAP_COUNT; // remap into clipmap + float sdf = bindless_textures3D[GetFrame().vxgi.texture_sdf].SampleLevel(sampler_linear_clamp, tc0, 0).r; stepSizeCurrent = max(stepSize, sdf - diameter); } + step_dist = diameter * stepSizeCurrent; // step along ray: - step_dist = diameter * stepSizeCurrent; dist += step_dist; } diff --git a/WickedEngine/shaders/vxgi_temporalCS.hlsl b/WickedEngine/shaders/vxgi_temporalCS.hlsl index b5e7dba3b..07c5c5a34 100644 --- a/WickedEngine/shaders/vxgi_temporalCS.hlsl +++ b/WickedEngine/shaders/vxgi_temporalCS.hlsl @@ -1,4 +1,3 @@ -#define VOXEL_INITIAL_OFFSET 1 //#define ENVMAPRENDERING // modified ambient calc //#define NO_FLAT_AMBIENT #include "globals.hlsli" @@ -62,7 +61,7 @@ void main(uint3 DTid : SV_DispatchThreadID) radiance = baseColor; // Voxel indirect lighting: - float3 P = GetFrame().vxgi.clipmap_to_world((DTid) * GetFrame().vxgi.resolution_rcp, clipmap); + float3 P = GetFrame().vxgi.clipmap_to_world((DTid + 0.5) * GetFrame().vxgi.resolution_rcp, clipmap); Lighting lighting; lighting.create(0, 0, 0, 0); lighting.direct.diffuse = directLight; diff --git a/WickedEngine/wiVersion.cpp b/WickedEngine/wiVersion.cpp index 8eadad446..61b80bf74 100644 --- a/WickedEngine/wiVersion.cpp +++ b/WickedEngine/wiVersion.cpp @@ -9,7 +9,7 @@ namespace wi::version // minor features, major updates, breaking compatibility changes const int minor = 71; // minor bug fixes, alterations, refactors, updates - const int revision = 132; + const int revision = 133; const std::string version_string = std::to_string(major) + "." + std::to_string(minor) + "." + std::to_string(revision);