浏览代码

Optimize GetCurrentViewPosition()

/main
Evgenii Golubev 7 年前
当前提交
11ff5460
共有 1 个文件被更改,包括 4 次插入7 次删除
  1. 11
      ScriptableRenderPipeline/HDRenderPipeline/ShaderVariablesFunctions.hlsl

11
ScriptableRenderPipeline/HDRenderPipeline/ShaderVariablesFunctions.hlsl


#if defined(SHADERPASS) && (SHADERPASS != SHADERPASS_SHADOWS)
return GetPrimaryCameraPosition();
#else
// TEMP: this is rather expensive. Then again, we need '_WorldSpaceCameraPos'
// to represent the position of the primary (scene view) camera in order to
// have identical tessellation levels for both the scene view and shadow views.
// Otherwise, depth comparisons become meaningless!
float4x4 trViewMat = transpose(GetWorldToViewMatrix());
float3 rotCamPos = trViewMat[3].xyz;
return mul((float3x3)trViewMat, -rotCamPos);
// This is a generic solution.
// However, for the primary camera, using '_WorldSpaceCameraPos' is better for cache locality,
// and in case we enable camera-relative rendering, we can statically set the position is 0.
return UNITY_MATRIX_I_V._14_24_34;
#endif
}

正在加载...
取消
保存