diff --git a/Source/Shaders/GI/DDGI.shader b/Source/Shaders/GI/DDGI.shader index a90d3c4c6..ca9635c96 100644 --- a/Source/Shaders/GI/DDGI.shader +++ b/Source/Shaders/GI/DDGI.shader @@ -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" diff --git a/Source/Shaders/GI/GlobalSurfaceAtlas.hlsl b/Source/Shaders/GI/GlobalSurfaceAtlas.hlsl index 26eeb875e..b4509effe 100644 --- a/Source/Shaders/GI/GlobalSurfaceAtlas.hlsl +++ b/Source/Shaders/GI/GlobalSurfaceAtlas.hlsl @@ -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 diff --git a/Source/Shaders/GlobalSignDistanceField.hlsl b/Source/Shaders/GlobalSignDistanceField.hlsl index c1bd4250b..466b56604 100644 --- a/Source/Shaders/GlobalSignDistanceField.hlsl +++ b/Source/Shaders/GlobalSignDistanceField.hlsl @@ -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