浏览代码

Shader Library, revert change to force float usage

/feature-ReflectionProbeFit
sebastienlagarde 7 年前
当前提交
c45eb77b
共有 1 个文件被更改,包括 29 次插入29 次删除
  1. 58
      ScriptableRenderPipeline/Core/ShaderLibrary/Shadow/Resources/ShadowBlurMoments.compute

58
ScriptableRenderPipeline/Core/ShaderLibrary/Shadow/Resources/ShadowBlurMoments.compute


#include "../ShadowMoments.hlsl"
#if MAX_MSAA > 1
Texture2DMS<real> depthTex;
Texture2DMS<float> depthTex;
Texture2D<real> depthTex;
Texture2D<float> depthTex;
uniform real4 blurWeightsStorage[3]; // Unity expects real arrays to be tightly packed
static real blurWeights[12] = (real[12])blurWeightsStorage;
uniform float4 blurWeightsStorage[3]; // Unity expects float arrays to be tightly packed
static float blurWeights[12] = (float[12])blurWeightsStorage;
static const int kBits_16 = 1; // 16 bits per channel
static const int kChannels_2 = 2; // 2 channels per pixel

# define SHADOW_MOMENTS 2
real2 DepthToMoments( real depth )
float2 DepthToMoments( float depth )
return real2( depth, depth * depth );
return float2( depth, depth * depth );
uniform real evsmExponent;
uniform float evsmExponent;
real2 DepthToMoments( real depth )
float2 DepthToMoments( float depth )
real2 moments = ShadowMoments_WarpDepth( depth, evsmExponent.xx );
return real2( moments.x, moments.x * moments.x );
float2 moments = ShadowMoments_WarpDepth( depth, evsmExponent.xx );
return float2( moments.x, moments.x * moments.x );
uniform real2 evsmExponents;
uniform float2 evsmExponents;
real4 DepthToMoments( real depth )
float4 DepthToMoments( float depth )
real2 moments = ShadowMoments_WarpDepth( depth, evsmExponents );
return real4( moments.xy, moments.xy * moments.xy );
float2 moments = ShadowMoments_WarpDepth( depth, evsmExponents );
return float4( moments.xy, moments.xy * moments.xy );
real4 DepthToMoments( real depth )
float4 DepthToMoments( float depth )
real dsq = depth * depth;
return real4( depth, dsq, depth * dsq, dsq * dsq );
float dsq = depth * depth;
return float4( depth, dsq, depth * dsq, dsq * dsq );
}
}
#else

#define BLUR_BORDER (BLUR_SIZE / 2)
#define LDS_STRIDE (THREADS + BLUR_BORDER + BLUR_BORDER)
#define moment_t MERGE_NAME( real, SHADOW_MOMENTS )
#define moment_t MERGE_NAME( float, SHADOW_MOMENTS )
groupshared real moments1[THREADS * LDS_STRIDE]; // contains the blurred first moment
groupshared real moments2[THREADS * LDS_STRIDE]; // contains the blurred second moment
groupshared real moments3[THREADS * LDS_STRIDE]; // contains the blurred third moment
groupshared real moments4[THREADS * LDS_STRIDE]; // contains the blurred fourth moment
groupshared float moments1[THREADS * LDS_STRIDE]; // contains the blurred first moment
groupshared float moments2[THREADS * LDS_STRIDE]; // contains the blurred second moment
groupshared float moments3[THREADS * LDS_STRIDE]; // contains the blurred third moment
groupshared float moments4[THREADS * LDS_STRIDE]; // contains the blurred fourth moment
groupshared real sampleWeights[MAX_MSAA];
groupshared real sumWeights;
groupshared float sampleWeights[MAX_MSAA];
groupshared float sumWeights;
int getLDSIdx( int2 pos, int stride )
{

uint width, height, sampleCnt;
depthTex.GetDimensions( width, height, sampleCnt );
sampleCnt = clamp( sampleCnt, 2, MAX_MSAA );
real sampleCntRcp = 1.0 / sampleCnt;
float sampleCntRcp = 1.0 / sampleCnt;
real2 spos = depthTex.GetSamplePosition( groupThreadId.x );
float2 spos = depthTex.GetSamplePosition( groupThreadId.x );
real sum = 0.0;
float sum = 0.0;
for( uint i = 0; i < sampleCnt; i++ )
sum += sampleWeights[i];
sumWeights = 1.0 / sum;

[loop]
for( uint is = 0; is < sampleCnt; is++ )
{
real depth = depthTex.Load( min( srcIdx, validSrc ), is ).x;
float depth = depthTex.Load( min( srcIdx, validSrc ), is ).x;
depth = reverse_z ? (1.0 - depth) : depth;
# if SHADOW_MOMENT_ALGORITHM == MSM
// We're pancaking triangles to znear in the depth pass so depth and subsequently all moments can end up being zero.

writeToShared( avgMoments, int2( ldsIdx.x, groupThreadId.y ), LDS_STRIDE );
#else
real depth = depthTex.Load( int3( min( srcIdx, validSrc ), 0 ) ).x;
float depth = depthTex.Load( int3( min( srcIdx, validSrc ), 0 ) ).x;
depth = reverse_z ? (1.0 - depth) : depth;
# if SHADOW_MOMENT_ALGORITHM == MSM
// We're pancaking triangles to znear in the depth pass so depth and subsequently all moments can end up being zero.

正在加载...
取消
保存