浏览代码

Use macro for depth down sample and support when gather red is not available

/feature-ReflectionProbeFit
Frédéric Vauchelles 7 年前
当前提交
281fe5bf
共有 2 个文件被更改,包括 16 次插入6 次删除
  1. 11
      ScriptableRenderPipeline/Core/CoreRP/ShaderLibrary/API/D3D11.hlsl
  2. 11
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/RenderPipelineResources/DepthDownsample.compute

11
ScriptableRenderPipeline/Core/CoreRP/ShaderLibrary/API/D3D11.hlsl


#define LOAD_TEXTURE3D(textureName, unCoord3) textureName.Load(int4(unCoord3, 0))
#define LOAD_TEXTURE3D_LOD(textureName, unCoord3, lod) textureName.Load(int4(unCoord3, lod))
#define GATHER_TEXTURE2D(textureName, samplerName, coord2) textureName.Gather(samplerName, coord2)
#define GATHER_TEXTURE2D_ARRAY(textureName, samplerName, coord2, index) textureName.Gather(samplerName, float3(coord2, index))
#define PLATFORM_SUPPORT_GATHER
#define GATHER_TEXTURE2D(textureName, samplerName, coord2, offset) textureName.Gather(samplerName, coord2, offset)
#define GATHER_TEXTURE2D_ARRAY(textureName, samplerName, coord2, index) textureName.Gather(samplerName, float3(coord2, index), offset)
#define GATHER_RED_TEXTURE2D(textureName, samplerName, coord2) textureName.GatherRed(samplerName, coord2)
#define GATHER_GREEN_TEXTURE2D(textureName, samplerName, coord2) textureName.GatherGreen(samplerName, coord2)
#define GATHER_BLUE_TEXTURE2D(textureName, samplerName, coord2) textureName.GatherBlue(samplerName, coord2)
#define GATHER_RED_TEXTURE2D(textureName, samplerName, coord2, offset) textureName.GatherRed(samplerName, coord2, offset)
#define GATHER_GREEN_TEXTURE2D(textureName, samplerName, coord2, offset) textureName.GatherGreen(samplerName, coord2, offset)
#define GATHER_BLUE_TEXTURE2D(textureName, samplerName, coord2, offset) textureName.GatherBlue(samplerName, coord2, offset)

11
ScriptableRenderPipeline/HDRenderPipeline/HDRP/RenderPipelineResources/DepthDownsample.compute


// Downsample the block
float2 offset = float2(threadUL) * 2.0f + 1.0f;
float4 depths = _Source.GatherRed(sampler_PointClamp, offset * _SrcSize.zw, 0.0);
#if defined(PLATFORM_SUPPORT_GATHER)
float4 depths = GATHER_RED_TEXTURE2D(_Source, sampler_PointClamp, offset * _SrcSize.zw, 0.0);
#else
// Downsample the block
float p00 = SAMPLE_TEXTURE2D_LOD(_Source, sampler_PointClamp, (offset) * _SrcSize.zw, 0.0).x;
float p10 = SAMPLE_TEXTURE2D_LOD(_Source, sampler_PointClamp, (offset + float2(1.0, 0.0)) * _SrcSize.zw, 0.0).x;
float p01 = SAMPLE_TEXTURE2D_LOD(_Source, sampler_PointClamp, (offset + float2(0.0, 1.0)) * _SrcSize.zw, 0.0).x;
float p11 = SAMPLE_TEXTURE2D_LOD(_Source, sampler_PointClamp, (offset + float2(1.0, 1.0)) * _SrcSize.zw, 0.0).x;
float4 depths = float4(p00, p10, p01, p11);
#endif
float minDepth = min(min(depths.x, depths.y), min(depths.z, depths.w));

正在加载...
取消
保存