浏览代码

Make ComputeCubeToSphereMapSqMagnitude() simpler to use

/main
Evgenii Golubev 8 年前
当前提交
10a41b5b
共有 1 个文件被更改,包括 5 次插入7 次删除
  1. 12
      Assets/ScriptableRenderLoop/ShaderLibrary/CommonLighting.hlsl

12
Assets/ScriptableRenderLoop/ShaderLibrary/CommonLighting.hlsl


return v * sqrt((float3)r2 - 0.5 * v2.yzx - 0.5 * v2.zxy + vr3.yxx * v2.zzy);
}
// Computes the squared magnitude of the vector 'v' after mapping it
// to a vector within the sphere of radius 'r', where r = sqrt(r2).
// The vector is originally defined within the cube of dimensions [-r, r]^3.
// The mapping is performed as per MapCubeToSphere().
// 'dotV' is dot(v, v) (often calculated when calling such a function)
float ComputeCubeToSphereMapSqMagnitude(float3 v, float dotV, float r2)
// Computes the squared magnitude of the vector computed by MapCubeToSphere().
float ComputeCubeToSphereMapSqMagnitude(float3 v, float r2)
return r2 * dotV - v2.x * v2.y - v2.y * v2.z - v2.z * v2.x + v2.x * v2.y * v2.z * rcp(r2);
// Note: dot(v, v) is often computed before this function is called,
// so the compiler should optimize and use the precomputed result here.
return r2 * dot(v, v) - v2.x * v2.y - v2.y * v2.z - v2.z * v2.x + v2.x * v2.y * v2.z * rcp(r2);
}
#endif // UNITY_COMMON_LIGHTING_INCLUDED
正在加载...
取消
保存