浏览代码

Clean up Common.hlsl

/feature-ReflectionProbeFit
Evgenii Golubev 7 年前
当前提交
914d5a35
共有 2 个文件被更改,包括 25 次插入16 次删除
  1. 38
      ScriptableRenderPipeline/Core/ShaderLibrary/Common.hlsl
  2. 3
      ScriptableRenderPipeline/Core/ShaderLibrary/Hammersley.hlsl

38
ScriptableRenderPipeline/Core/ShaderLibrary/Common.hlsl


return (x < 1.0) ? poly : HALF_PI - poly;
}
// TODO: this intrinsic is unavailable outside compute. This is a Unity shader compiler bug.
#if (SHADER_TARGET >= 50) && (SHADER_STAGE_COMPUTE != 0)
uint FastLog2(uint x)
{
return firstbithigh(x) – 1u;
}
#endif
// 4 VGPR, 16 FR (12 FR, 1 QR), 2 scalar
// input [-infinity, infinity] and output [-PI/2, PI/2]
float FastATan(float x)

}
// Same as smoothstep except it assume 0, 1 interval for x
float Smoothstep01(float x)
{
return x * x * (3.0 - (2.0 * x));
}
static const float3x3 k_identity3x3 = {1.0, 0.0, 0.0,
0.0, 1.0, 0.0,
0.0, 0.0, 1.0};
static const float4x4 k_identity4x4 = {1.0, 0.0, 0.0, 0.0,
0.0, 1.0, 0.0, 0.0,
0.0, 0.0, 1.0, 0.0,
0.0, 0.0, 0.0, 1.0};
// Using pow often result to a warning like this
// "pow(f, e) will not work for negative f, use abs(f) or conditionally handle negative values if you expect them"

float3 Orthonormalize(float3 tangent, float3 normal)
{
return normalize(tangent - dot(tangent, normal) * normal);
}
// Same as smoothstep except it assume 0, 1 interval for x
float Smoothstep01(float x)
{
return x * x * (3.0 - (2.0 * x));
}
// ----------------------------------------------------------------------------

// ----------------------------------------------------------------------------
// Space transformations
// ----------------------------------------------------------------------------
static const float3x3 k_identity3x3 = {1, 0, 0,
0, 1, 0,
0, 0, 1};
static const float4x4 k_identity4x4 = {1, 0, 0, 0,
0, 1, 0, 0,
0, 0, 1, 0,
0, 0, 0, 1};
// Use case examples:
// (position = positionCS) => (clipSpaceTransform = use default)

3
ScriptableRenderPipeline/Core/ShaderLibrary/Hammersley.hlsl


// Ref: http://holger.dammertz.org/stuff/notes_HammersleyOnHemisphere.html
uint ReverseBits32(uint bits)
{
#if 1 // Shader model 5
// TODO: this intrinsic is unavailable outside compute. This is a Unity shader compiler bug.
#if (SHADER_TARGET >= 50) && (SHADER_STAGE_COMPUTE != 0)
return reversebits(bits);
#else
bits = (bits << 16) | (bits >> 16);

正在加载...
取消
保存