浏览代码

HDRenderPipeline: Add HemiOct packing function

/RenderPassXR_Sandbox
Sebastien Lagarde 7 年前
当前提交
873c4048
共有 1 个文件被更改,包括 16 次插入0 次删除
  1. 16
      Assets/ScriptableRenderPipeline/ShaderLibrary/Packing.hlsl

16
Assets/ScriptableRenderPipeline/ShaderLibrary/Packing.hlsl


return normalize(n);
}
float2 PackNormalHemiOctEncode(float3 n)
{
float l1norm = dot(abs(n), 1.0);
float2 res = n.xy * (1.0 / l1norm);
return float2(res.x + res.y, res.x - res.y);
}
float3 UnpackNormalHemiOctEncode(float2 f)
{
float2 val = float2(f.x + f.y, f.x - f.y) * 0.5;
float3 n = float3(val, 1.0 - dot(abs(val), 1.0));
return normalize(n);
}
// Tetrahedral encoding - Looks like Tetra encoding 10:10 + 2 is similar to oct 11:11, as oct is cheaper prefer it
// To generate the basisNormal below we use these 4 vertex of a regular tetrahedron
// v0 = float3(1.0, 0.0, -1.0 / sqrt(2.0));

正在加载...
取消
保存