浏览代码

Further optimize the box projection clip factor for GCN

/RenderPassXR_Sandbox
Evgenii Golubev 7 年前
当前提交
2918766c
共有 1 个文件被更改,包括 4 次插入4 次删除
  1. 8
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Lit.hlsl

8
Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Lit.hlsl


{
// bool isInBounds = max(abs(positionNDC.x), abs(positionNDC.y)) <= 1 && positionLS.z >= 0;
// float clipFactor = isInBounds ? 1 : 0;
// This version is slightly faster (trade 1x VALU for 1x SALU):
float clipFactor = saturate(FLT_MAX - FLT_MAX * max(abs(positionNDC.x), abs(positionNDC.y))) * (positionLS.z >= 0 ? 1 : 0);
// This version is slightly more efficient:
float clipFactor = saturate(FLT_MAX - FLT_MAX * Max3(abs(positionNDC.x), abs(positionNDC.y), positionLS.z >= 0 ? 0 : 1));
}
float attenuation = clipFactor;

float2 positionNDC = positionLS.xy / perspectiveZ;
// bool isInBounds = max(abs(positionNDC.x), abs(positionNDC.y)) <= 1 && positionLS.z >= 0;
// float clipFactor = isInBounds ? 1 : 0;
// This version is slightly faster (trade 1x VALU for 1x SALU):
float clipFactor = saturate(FLT_MAX - FLT_MAX * max(abs(positionNDC.x), abs(positionNDC.y))) * (positionLS.z >= 0 ? 1 : 0);
// This version is slightly more efficient:
float clipFactor = saturate(FLT_MAX - FLT_MAX * Max3(abs(positionNDC.x), abs(positionNDC.y), positionLS.z >= 0 ? 0 : 1));
// Remap the texture coordinates from [-1, 1]^2 to [0, 1]^2.
float2 coord = positionNDC * 0.5 + 0.5;

正在加载...
取消
保存