浏览代码

HDRenderPipeline: Add FastSign() function

/RenderPassXR_Sandbox
sebastienlagarde 7 年前
当前提交
a8bef5fd
共有 2 个文件被更改,包括 8 次插入1 次删除
  1. 7
      Assets/ScriptableRenderPipeline/ShaderLibrary/Common.hlsl
  2. 2
      Assets/ScriptableRenderPipeline/ShaderLibrary/Packing.hlsl

7
Assets/ScriptableRenderPipeline/ShaderLibrary/Common.hlsl


return pow(max(abs(base), float4(FLT_EPSILON, FLT_EPSILON, FLT_EPSILON, FLT_EPSILON)), power);
}
// Ref: https://twitter.com/SebAaltonen/status/878250919879639040
// 2 mads (mad_sat and mad), faster than regular sign
float3 FastSign(float x)
{
return saturate(x * FLT_MAX) * 2.0 - 1.0;
}
// ----------------------------------------------------------------------------
// Texture utilities
// ----------------------------------------------------------------------------

2
Assets/ScriptableRenderPipeline/ShaderLibrary/Packing.hlsl


if (index == 2) quat = quat.xywz;
float4 packedQuat;
packedQuat.xyz = quat.xyz * sign(quat.w) * sqrt(0.5) + 0.5;
packedQuat.xyz = quat.xyz * FastSign(quat.w) * sqrt(0.5) + 0.5;
packedQuat.w = index / 3.0;
return packedQuat;

正在加载...
取消
保存