您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
27 行
862 B
27 行
862 B
#include "ShaderLibrary/Common.hlsl"
|
|
|
|
Texture2D<float> _Source;
|
|
RWTexture2D<float> _Result;
|
|
|
|
SamplerState sampler_PointClamp; //TODO: could we use min-sampler instead of using ALU?
|
|
|
|
CBUFFER_START(cb)
|
|
float4 _SrcSize;
|
|
CBUFFER_END
|
|
|
|
#pragma kernel KMain
|
|
[numthreads(8, 8, 1)]
|
|
void KMain(uint2 groupId : SV_GroupID, uint2 groupThreadId : SV_GroupThreadID, uint2 dispatchThreadId : SV_DispatchThreadID)
|
|
{
|
|
// Upper-left pixel coordinate of quad that this thread will read
|
|
int2 threadUL = dispatchThreadId;
|
|
|
|
// Downsample the block
|
|
float2 offset = float2(threadUL) * 2.0f + 1.0f;
|
|
float4 depths = _Source.GatherRed(sampler_PointClamp, offset * _SrcSize.zw, 0.0);
|
|
|
|
float minDepth = min(min(depths.x, depths.y), min(depths.z, depths.w));
|
|
|
|
// Write to the final target
|
|
_Result[dispatchThreadId] = minDepth;
|
|
}
|