Optimize DDGI software raytracing with point sampler

This commit is contained in:
2026-06-18 09:35:50 +02:00
parent b0629bcc67
commit 5ac9a41bfe
3 changed files with 13 additions and 4 deletions
+4
View File
@@ -9,6 +9,10 @@
// "Scaling Probe-Based Real-Time Dynamic Global Illumination for Production", https://jcgt.org/published/0010/02/01/
// "Dynamic Diffuse Global Illumination with Ray-Traced Irradiance Fields", https://jcgt.org/published/0008/02/01/
// Use point sampling in software raytracing
#define GLOBAL_SURFACE_ATLAS_SAMPLER SamplerPointClamp
#define GLOBAL_SDF_SAMPLER SamplerPointClamp
#include "./Flax/Common.hlsl"
#include "./Flax/Math.hlsl"
#include "./Flax/Noise.hlsl"
+7 -4
View File
@@ -25,6 +25,9 @@
#define GLOBAL_SURFACE_ATLAS_TILE_NORMAL_WEIGHT_ENABLED 0
#define GLOBAL_SURFACE_ATLAS_TILE_NORMAL_THRESHOLD 0
#endif
#ifndef GLOBAL_SURFACE_ATLAS_SAMPLER
#define GLOBAL_SURFACE_ATLAS_SAMPLER SamplerLinearClamp
#endif
struct GlobalSurfaceTile
{
@@ -119,9 +122,9 @@ struct GlobalSurfaceAtlasData
float3 SampleGlobalSurfaceAtlasTex(Texture2D atlas, float2 atlasUV, float4 bilinearWeights)
{
float4 sampleX = atlas.GatherRed(SamplerLinearClamp, atlasUV);
float4 sampleY = atlas.GatherGreen(SamplerLinearClamp, atlasUV);
float4 sampleZ = atlas.GatherBlue(SamplerLinearClamp, atlasUV);
float4 sampleX = atlas.GatherRed(GLOBAL_SURFACE_ATLAS_SAMPLER, atlasUV);
float4 sampleY = atlas.GatherGreen(GLOBAL_SURFACE_ATLAS_SAMPLER, atlasUV);
float4 sampleZ = atlas.GatherBlue(GLOBAL_SURFACE_ATLAS_SAMPLER, atlasUV);
return float3(dot(sampleX, bilinearWeights), dot(sampleY, bilinearWeights), dot(sampleZ, bilinearWeights));
}
@@ -154,7 +157,7 @@ float4 SampleGlobalSurfaceAtlasTile(const GlobalSurfaceAtlasData data, GlobalSur
bilinearWeights.w = (1 - bilinearWeightsUV.x) * (1 - bilinearWeightsUV.y);
// Tile depth weight based on sample position occlusion
float4 tileZ = depth.Gather(SamplerLinearClamp, atlasUV);
float4 tileZ = depth.Gather(GLOBAL_SURFACE_ATLAS_SAMPLER, atlasUV);
float depthThreshold = 2.0f * surfaceThreshold / tile.ViewBoundsSize.z;
float4 depthVisibility = 1.0f;
UNROLL
@@ -11,7 +11,9 @@
#define GLOBAL_SDF_WORLD_SIZE 60000.0f
#define GLOBAL_SDF_MIN_VALID 0.9f
#define GLOBAL_SDF_CHUNK_MARGIN_SCALE 4.0f
#ifndef GLOBAL_SDF_SAMPLER
#define GLOBAL_SDF_SAMPLER SamplerLinearClamp
#endif
// Global SDF data for a constant buffer
struct GlobalSDFData