浏览代码

Fix orthographic camera detection

/fptl_cleanup
Evgenii Golubev 7 年前
当前提交
f347b262
共有 1 个文件被更改,包括 15 次插入9 次删除
  1. 24
      Assets/ScriptableRenderPipeline/HDRenderPipeline/ShaderVariables.hlsl

24
Assets/ScriptableRenderPipeline/HDRenderPipeline/ShaderVariables.hlsl


float3 GetCurrentCameraPosition()
{
#if SHADERPASS != SHADERPASS_DEPTH_ONLY
#if defined(SHADERPASS) && (SHADERPASS != SHADERPASS_DEPTH_ONLY)
return _WorldSpaceCameraPos;
#else
// TEMP: this is rather expensive. Then again, we need '_WorldSpaceCameraPos'

return -viewMat[2].xyz;
}
// Computes the world space view direction (pointing towards the camera).
float3 GetWorldSpaceNormalizeViewDir(float3 positionWS)
// Returns 'true' if the current camera performs a perspective projection.
bool IsPerspectiveCamera()
#if SHADERPASS != SHADERPASS_DEPTH_ONLY
if (unity_OrthoParams.w == 0)
#if defined(SHADERPASS) && (SHADERPASS != SHADERPASS_DEPTH_ONLY)
return (unity_OrthoParams.w == 0);
if (GetWorldToHClipMatrix()[3].x != 0 &&
GetWorldToHClipMatrix()[3].y != 0 &&
GetWorldToHClipMatrix()[3].z != 0 &&
GetWorldToHClipMatrix()[3].w != 1)
return (GetWorldToHClipMatrix()[3].x != 0 ||
GetWorldToHClipMatrix()[3].y != 0 ||
GetWorldToHClipMatrix()[3].z != 0 ||
GetWorldToHClipMatrix()[3].w != 1);
}
// Computes the world space view direction (pointing towards the camera).
float3 GetWorldSpaceNormalizeViewDir(float3 positionWS)
{
if (IsPerspectiveCamera())
{
// Perspective
float3 V = GetCurrentCameraPosition() - positionWS;

正在加载...
取消
保存