浏览代码

Merge pull request #198 from EvgeniiG/master

Fix the view-dependent depth offset issue
/fptl_cleanup
GitHub 8 年前
当前提交
6f4d4474
共有 2 个文件被更改,包括 7 次插入6 次删除
  1. 4
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/LitData.hlsl
  2. 9
      Assets/ScriptableRenderPipeline/ShaderLibrary/Common.hlsl

4
Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/LitData.hlsl


float depthOffset = ApplyPerPixelDisplacement(input, V, layerTexCoord);
#ifdef _DEPTHOFFSET_ON
ApplyDepthOffsetPositionInput(GetCameraForwardDir(), depthOffset, GetWorldToHClipMatrix(), posInput);
ApplyDepthOffsetPositionInput(V, depthOffset, GetWorldToHClipMatrix(), posInput);
#endif
// We perform the conversion to world of the normalTS outside of the GetSurfaceData

float depthOffset = ApplyPerPixelDisplacement(input, V, layerTexCoord);
#ifdef _DEPTHOFFSET_ON
ApplyDepthOffsetPositionInput(GetCameraForwardDir(), depthOffset, GetWorldToHClipMatrix(), posInput);
ApplyDepthOffsetPositionInput(V, depthOffset, GetWorldToHClipMatrix(), posInput);
#endif
SurfaceData surfaceData0, surfaceData1, surfaceData2, surfaceData3;

9
Assets/ScriptableRenderPipeline/ShaderLibrary/Common.hlsl


return positionVS.xyz / positionVS.w;
}
// 'depthOffsetVS' is always along the forward direction 'camDirWS' pointing away from the camera.
void ApplyDepthOffsetPositionInput(float3 camDirWS, float depthOffsetVS, float4x4 viewProjMatrix, inout PositionInputs posInput)
// The view direction 'V' points towards the camera.
// 'depthOffsetVS' is always applied in the opposite direction (-V).
void ApplyDepthOffsetPositionInput(float3 V, float depthOffsetVS, float4x4 viewProjMatrix, inout PositionInputs posInput)
posInput.depthVS += depthOffsetVS;
posInput.positionWS += depthOffsetVS * camDirWS;
posInput.positionWS += depthOffsetVS * (-V);
posInput.depthVS = positionCS.w;
posInput.depthRaw = positionCS.z / positionCS.w;
}

正在加载...
取消
保存