浏览代码

Merge pull request #171 from Unity-Technologies/Add-depth-offset-in-debug-view

HDrenderPipeline: Add depth offset support in debug view depth mode
/Branch_Batching2
GitHub 8 年前
当前提交
8b9da4f7
共有 2 个文件被更改,包括 12 次插入3 次删除
  1. 13
      Assets/ScriptableRenderPipeline/HDRenderPipeline/ShaderPass/ShaderPassDebugViewMaterial.hlsl
  2. 2
      Assets/ScriptableRenderPipeline/ShaderLibrary/Common.hlsl

13
Assets/ScriptableRenderPipeline/HDRenderPipeline/ShaderPass/ShaderPassDebugViewMaterial.hlsl


#endif // TESSELLATION_ON
float4 Frag(PackedVaryingsToPS packedInput) : SV_Target
void Frag( PackedVaryingsToPS packedInput
, out float4 outColor : SV_Target
#ifdef _DEPTHOFFSET_ON
, out float outputDepth : SV_Depth
#endif
)
{
FragInputs input = UnpackVaryingsMeshToFragInputs(packedInput.vmesh);

if (!needLinearToSRGB)
result = SRGBToLinear(max(0, result));
return float4(result, 0.0);
#ifdef _DEPTHOFFSET_ON
outputDepth = posInput.depthRaw;
#endif
outColor = float4(result, 1.0);
}

2
Assets/ScriptableRenderPipeline/ShaderLibrary/Common.hlsl


void ApplyDepthOffsetPositionInput(float3 V, float depthOffsetVS, float4x4 viewProjMatrix, inout PositionInputs posInput)
{
posInput.depthVS += depthOffsetVS;
posInput.positionWS -= depthOffsetVS * V;
posInput.positionWS += depthOffsetVS * -V; // opposite to V
float4 positionCS = mul(viewProjMatrix, float4(posInput.positionWS, 1.0));
posInput.depthRaw = positionCS.z / positionCS.w;

正在加载...
取消
保存