runes
7 年前
当前提交
da5e6aa6
共有 2 个文件被更改,包括 29 次插入 和 31 次删除
-
5ScriptableRenderPipeline/HDRenderPipeline/HDRenderPipeline.cs
-
55ScriptableRenderPipeline/HDRenderPipeline/RenderPipelineResources/DepthDownsample.compute
|
|||
#include "ShaderLibrary/Common.hlsl" |
|||
|
|||
Texture2D<float> _Source; |
|||
RWTexture2D<float> _Result; |
|||
|
|||
SamplerState sampler_LinearClamp; |
|||
|
|||
CBUFFER_START(cb) |
|||
float4 _Size; |
|||
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); |
|||
float p00 = _Source.SampleLevel(sampler_LinearClamp, (offset ) * _Size.zw, 0.0).x; |
|||
float p10 = _Source.SampleLevel(sampler_LinearClamp, (offset + float2(1.0, 0.0)) * _Size.zw, 0.0).x; |
|||
float p01 = _Source.SampleLevel(sampler_LinearClamp, (offset + float2(0.0, 1.0)) * _Size.zw, 0.0).x; |
|||
float p11 = _Source.SampleLevel(sampler_LinearClamp, (offset + float2(1.0, 1.0)) * _Size.zw, 0.0).x; |
|||
|
|||
float depth = min(min(min(p00, p01), p10), p11); |
|||
|
|||
// Write to the final target |
|||
_Result[dispatchThreadId] = depth; |
|||
#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; |
|||
} |
撰写
预览
正在加载...
取消
保存
Reference in new issue