summaryrefslogtreecommitdiffstats
path: root/Shaders/PostProcess
diff options
context:
space:
mode:
authorEgor Yusov <egor.yusov@gmail.com>2019-06-02 04:10:12 +0000
committerEgor Yusov <egor.yusov@gmail.com>2019-06-02 04:10:12 +0000
commitd2f35fa5b6abc23593d7a2c96b37f6f5e34944aa (patch)
treebd245613a537f24d3084df2fac5ac4906360ae17 /Shaders/PostProcess
parentLight scattering posteffect: removed EARTH_RADIUS, ATM_TOP_HEIGHT, ATM_TOP_RA... (diff)
downloadDiligentFX-d2f35fa5b6abc23593d7a2c96b37f6f5e34944aa.tar.gz
DiligentFX-d2f35fa5b6abc23593d7a2c96b37f6f5e34944aa.zip
Light scattering posteffect: removed NUM_EPIPOLAR_SLICES and MAX_SAMPLES_IN_SLICE shader defines
Diffstat (limited to 'Shaders/PostProcess')
-rw-r--r--Shaders/PostProcess/EpipolarLightScattering/private/AtmosphereShadersCommon.fxh12
-rw-r--r--Shaders/PostProcess/EpipolarLightScattering/private/InitializeMinMaxShadowMap.fx4
-rw-r--r--Shaders/PostProcess/EpipolarLightScattering/private/RefineSampleLocations.fx2
-rw-r--r--Shaders/PostProcess/EpipolarLightScattering/private/RenderCoordinateTexture.fx4
-rw-r--r--Shaders/PostProcess/EpipolarLightScattering/private/RenderSliceEndPoints.fx4
-rw-r--r--Shaders/PostProcess/EpipolarLightScattering/private/UnwarpEpipolarScattering.fx16
6 files changed, 17 insertions, 25 deletions
diff --git a/Shaders/PostProcess/EpipolarLightScattering/private/AtmosphereShadersCommon.fxh b/Shaders/PostProcess/EpipolarLightScattering/private/AtmosphereShadersCommon.fxh
index f8c3966..f87f6fa 100644
--- a/Shaders/PostProcess/EpipolarLightScattering/private/AtmosphereShadersCommon.fxh
+++ b/Shaders/PostProcess/EpipolarLightScattering/private/AtmosphereShadersCommon.fxh
@@ -6,8 +6,8 @@
#include "EpipolarLightScatteringStructures.fxh"
#include "ShaderUtilities.fxh"
-#define PI 3.1415928f
-#define FLT_MAX 3.402823466e+38f
+#define PI 3.1415928
+#define FLT_MAX 3.402823466e+38
#define F4ZERO float4(0.0, 0.0, 0.0, 0.0)
#define F4ONE float4(1.0, 1.0, 1.0, 1.0)
@@ -16,14 +16,6 @@
#define F2ZERO float2(0.0, 0.0)
#define F2ONE float2(1.0, 1.0)
-#ifndef NUM_EPIPOLAR_SLICES
-# define NUM_EPIPOLAR_SLICES 1024u
-#endif
-
-#ifndef MAX_SAMPLES_IN_SLICE
-# define MAX_SAMPLES_IN_SLICE 512u
-#endif
-
#ifndef OPTIMIZE_SAMPLE_LOCATIONS
# define OPTIMIZE_SAMPLE_LOCATIONS 1
#endif
diff --git a/Shaders/PostProcess/EpipolarLightScattering/private/InitializeMinMaxShadowMap.fx b/Shaders/PostProcess/EpipolarLightScattering/private/InitializeMinMaxShadowMap.fx
index 86857c9..7d387ab 100644
--- a/Shaders/PostProcess/EpipolarLightScattering/private/InitializeMinMaxShadowMap.fx
+++ b/Shaders/PostProcess/EpipolarLightScattering/private/InitializeMinMaxShadowMap.fx
@@ -25,8 +25,8 @@ void InitializeMinMaxShadowMapPS(in FullScreenTriangleVSOutput VSOut,
uint uiSliceInd;
float fCascadeInd;
#if USE_COMBINED_MIN_MAX_TEXTURE
- fCascadeInd = floor(VSOut.f4PixelPos.y / float(NUM_EPIPOLAR_SLICES));
- uiSliceInd = uint(VSOut.f4PixelPos.y - fCascadeInd * float(NUM_EPIPOLAR_SLICES));
+ fCascadeInd = floor(VSOut.f4PixelPos.y / float(g_PPAttribs.uiNumEpipolarSlices));
+ uiSliceInd = uint(VSOut.f4PixelPos.y - fCascadeInd * float(g_PPAttribs.uiNumEpipolarSlices));
fCascadeInd += g_PPAttribs.fFirstCascadeToRayMarch;
#else
uiSliceInd = uint(VSOut.f4PixelPos.y);
diff --git a/Shaders/PostProcess/EpipolarLightScattering/private/RefineSampleLocations.fx b/Shaders/PostProcess/EpipolarLightScattering/private/RefineSampleLocations.fx
index b00a246..4e1a28a 100644
--- a/Shaders/PostProcess/EpipolarLightScattering/private/RefineSampleLocations.fx
+++ b/Shaders/PostProcess/EpipolarLightScattering/private/RefineSampleLocations.fx
@@ -135,7 +135,7 @@ void RefineSampleLocationsCS(uint3 Gid : SV_GroupID,
// are required to perform ray marching
uint uiInitialSample0GlobalInd = uiInitialSample0Ind + uiGroupStartGlobalInd;
float2 f2InitialSample0Coords = g_tex2DCoordinates.Load( int3(uiInitialSample0GlobalInd, uiSliceInd, 0) );
- if( float(uiInitialSample0GlobalInd)/float(MAX_SAMPLES_IN_SLICE) < 0.05 &&
+ if( float(uiInitialSample0GlobalInd)/float(g_PPAttribs.uiMaxSamplesInSlice) < 0.05 &&
length(f2InitialSample0Coords - g_PPAttribs.f4LightScreenPos.xy) < 0.1 )
{
uiInitialSampleStep = max( uint(INITIAL_SAMPLE_STEP) / g_PPAttribs.uiEpipoleSamplingDensityFactor, 1u );
diff --git a/Shaders/PostProcess/EpipolarLightScattering/private/RenderCoordinateTexture.fx b/Shaders/PostProcess/EpipolarLightScattering/private/RenderCoordinateTexture.fx
index bbd5018..d4995e6 100644
--- a/Shaders/PostProcess/EpipolarLightScattering/private/RenderCoordinateTexture.fx
+++ b/Shaders/PostProcess/EpipolarLightScattering/private/RenderCoordinateTexture.fx
@@ -41,10 +41,10 @@ void GenerateCoordinateTexturePS(FullScreenTriangleVSOutput VSOut,
// X - locations where rasterization happens
//
// We need remove this offset:
- float fSamplePosOnEpipolarLine = f2UV.x - 0.5 / float(MAX_SAMPLES_IN_SLICE);
+ float fSamplePosOnEpipolarLine = f2UV.x - 0.5 / float(g_PPAttribs.uiMaxSamplesInSlice);
// fSamplePosOnEpipolarLine is now in the range [0, 1 - 1/MAX_SAMPLES_IN_SLICE]
// We need to rescale it to be in [0, 1]
- fSamplePosOnEpipolarLine *= float(MAX_SAMPLES_IN_SLICE) / (float(MAX_SAMPLES_IN_SLICE)-1.0);
+ fSamplePosOnEpipolarLine *= float(g_PPAttribs.uiMaxSamplesInSlice) / (float(g_PPAttribs.uiMaxSamplesInSlice)-1.0);
fSamplePosOnEpipolarLine = saturate(fSamplePosOnEpipolarLine);
// Compute interpolated position between entry and exit points:
diff --git a/Shaders/PostProcess/EpipolarLightScattering/private/RenderSliceEndPoints.fx b/Shaders/PostProcess/EpipolarLightScattering/private/RenderSliceEndPoints.fx
index d8abd24..4364008 100644
--- a/Shaders/PostProcess/EpipolarLightScattering/private/RenderSliceEndPoints.fx
+++ b/Shaders/PostProcess/EpipolarLightScattering/private/RenderSliceEndPoints.fx
@@ -118,7 +118,7 @@ float4 GenerateSliceEndpointsPS(FullScreenTriangleVSOutput VSOut
// X - locations where rasterization happens
//
// We need to remove this offset. Also clamp to [0,1] to fix fp32 precision issues
- float fEpipolarSlice = saturate(f2UV.x - 0.5 / float(NUM_EPIPOLAR_SLICES) );
+ float fEpipolarSlice = saturate(f2UV.x - 0.5 / float(g_PPAttribs.uiNumEpipolarSlices) );
// fEpipolarSlice now lies in the range [0, 1 - 1/NUM_EPIPOLAR_SLICES]
// 0 defines location in exacatly left top corner, 1 - 1/NUM_EPIPOLAR_SLICES defines
@@ -203,7 +203,7 @@ float4 GenerateSliceEndpointsPS(FullScreenTriangleVSOutput VSOut
// Compute length of the epipolar line in screen pixels:
float fEpipolarSliceScreenLen = length( (f2ExitPoint - f2EntryPoint) * g_PPAttribs.f4ScreenResolution.xy / 2.0 );
// If epipolar line is too short, update epipolar line exit point to provide 1:1 texel to screen pixel correspondence:
- f2ExitPoint = f2EntryPoint + (f2ExitPoint - f2EntryPoint) * max(float(MAX_SAMPLES_IN_SLICE) / fEpipolarSliceScreenLen, 1.0);
+ f2ExitPoint = f2EntryPoint + (f2ExitPoint - f2EntryPoint) * max(float(g_PPAttribs.uiMaxSamplesInSlice) / fEpipolarSliceScreenLen, 1.0);
}
#endif
diff --git a/Shaders/PostProcess/EpipolarLightScattering/private/UnwarpEpipolarScattering.fx b/Shaders/PostProcess/EpipolarLightScattering/private/UnwarpEpipolarScattering.fx
index fd85e09..bf7cff2 100644
--- a/Shaders/PostProcess/EpipolarLightScattering/private/UnwarpEpipolarScattering.fx
+++ b/Shaders/PostProcess/EpipolarLightScattering/private/UnwarpEpipolarScattering.fx
@@ -134,20 +134,20 @@ void UnwarpEpipolarInsctrImage( in float2 f2PosPS,
// Now find two closest epipolar slices, from which we will interpolate
// First, find index of the slice which precedes our slice
// Note that 0 <= fEpipolarSlice <= 1, and both 0 and 1 refer to the first slice
- float fPrecedingSliceInd = min( floor(fEpipolarSlice * float(NUM_EPIPOLAR_SLICES)), float(NUM_EPIPOLAR_SLICES-1u) );
+ float fPrecedingSliceInd = min( floor(fEpipolarSlice * float(g_PPAttribs.uiNumEpipolarSlices)), float(g_PPAttribs.uiNumEpipolarSlices-1u) );
// Compute EXACT texture coordinates of preceding and succeeding slices and their weights
// Note that slice 0 is stored in the first texel which has exact texture coordinate 0.5/NUM_EPIPOLAR_SLICES
// (search for "fEpipolarSlice = saturate(f2UV.x - 0.5f / (float)NUM_EPIPOLAR_SLICES)"):
float fSrcSliceV[2];
// Compute V coordinate to refer exactly the center of the slice row
- fSrcSliceV[0] = fPrecedingSliceInd/float(NUM_EPIPOLAR_SLICES) + 0.5/float(NUM_EPIPOLAR_SLICES);
+ fSrcSliceV[0] = fPrecedingSliceInd/float(g_PPAttribs.uiNumEpipolarSlices) + 0.5/float(g_PPAttribs.uiNumEpipolarSlices);
// Use frac() to wrap around to the first slice from the next-to-last slice:
- fSrcSliceV[1] = frac( fSrcSliceV[0] + 1.0/float(NUM_EPIPOLAR_SLICES) );
+ fSrcSliceV[1] = frac( fSrcSliceV[0] + 1.0/float(g_PPAttribs.uiNumEpipolarSlices) );
// Compute slice weights
float fSliceWeights[2];
- fSliceWeights[1] = (fEpipolarSlice*float(NUM_EPIPOLAR_SLICES)) - fPrecedingSliceInd;
+ fSliceWeights[1] = (fEpipolarSlice*float(g_PPAttribs.uiNumEpipolarSlices)) - fPrecedingSliceInd;
fSliceWeights[0] = 1.0 - fSliceWeights[1];
f3Inscattering = F3ZERO;
@@ -169,7 +169,7 @@ void UnwarpEpipolarInsctrImage( in float2 f2PosPS,
// Note that the first sample on the line (fSamplePosOnLine==0) is exactly the Entry Point, while
// the last sample (fSamplePosOnLine==1) is exactly the Exit Point
// (search for "fSamplePosOnEpipolarLine *= (float)MAX_SAMPLES_IN_SLICE / ((float)MAX_SAMPLES_IN_SLICE-1.f)")
- float fSampleInd = fSamplePosOnLine * float(MAX_SAMPLES_IN_SLICE-1u);
+ float fSampleInd = fSamplePosOnLine * float(g_PPAttribs.uiMaxSamplesInSlice-1u);
// We have to manually perform bilateral filtering of the scattered radiance texture to
// eliminate artifacts at depth discontinuities
@@ -179,7 +179,7 @@ void UnwarpEpipolarInsctrImage( in float2 f2PosPS,
float fUWeight = fSampleInd - fPrecedingSampleInd;
// Get texture coordinate of the left source texel. Again, offset by 0.5 is essential
// to align with the texel center
- float fPrecedingSampleU = (fPrecedingSampleInd + 0.5) / float(MAX_SAMPLES_IN_SLICE);
+ float fPrecedingSampleU = (fPrecedingSampleInd + 0.5) / float(g_PPAttribs.uiMaxSamplesInSlice);
float2 f2SctrColorUV = float2(fPrecedingSampleU, fSrcSliceV[i]);
@@ -202,7 +202,7 @@ void UnwarpEpipolarInsctrImage( in float2 f2PosPS,
// z == g_tex2DEpipolarCamSpaceZ.SampleLevel(samPointClamp, f2SctrColorUV, 0, int2(1,0))
// w == g_tex2DEpipolarCamSpaceZ.SampleLevel(samPointClamp, f2SctrColorUV, 0, int2(0,0))
- const float2 f2ScatteredColorTexDim = float2(MAX_SAMPLES_IN_SLICE, NUM_EPIPOLAR_SLICES);
+ const float2 f2ScatteredColorTexDim = float2(g_PPAttribs.uiMaxSamplesInSlice, g_PPAttribs.uiNumEpipolarSlices);
float2 f2SrcLocationsCamSpaceZ = g_tex2DEpipolarCamSpaceZ.Gather(g_tex2DEpipolarCamSpaceZ_sampler, f2SctrColorUV + float2(0.5, 0.5) / f2ScatteredColorTexDim.xy).wz;
// Compute depth weights in a way that if the difference is less than the threshold, the weight is 1 and
@@ -225,7 +225,7 @@ void UnwarpEpipolarInsctrImage( in float2 f2PosPS,
// | |
// |<-------------------Clamp range------------------->|
//
- f2BilateralUWeights *= (abs(fSamplePosOnLine - 0.5) < 0.5 + 1.0 / float(MAX_SAMPLES_IN_SLICE-1u)) ? 1.0 : 0.0;
+ f2BilateralUWeights *= (abs(fSamplePosOnLine - 0.5) < 0.5 + 1.0 / float(g_PPAttribs.uiMaxSamplesInSlice-1u)) ? 1.0 : 0.0;
// We now need to compute the following weighted summ:
//f3FilteredSliceCol =
// f2BilateralUWeights.x * g_tex2DScatteredColor.SampleLevel(samPoint, f2SctrColorUV, 0, int2(0,0)) +