浏览代码

Rename packing functions for consistency

/RenderPassXR_Sandbox
Evgenii Golubev 8 年前
当前提交
45027d1e
共有 1 个文件被更改,包括 7 次插入7 次删除
  1. 14
      Assets/ScriptableRenderPipeline/ShaderLibrary/Packing.hlsl

14
Assets/ScriptableRenderPipeline/ShaderLibrary/Packing.hlsl


//-----------------------------------------------------------------------------
// Ref: http://realtimecollisiondetection.net/blog/?p=15
float4 PackLogLuv(float3 vRGB)
float4 PackToLogLuv(float3 vRGB)
{
// M matrix, for encoding
const float3x3 M = float3x3(

return vResult;
}
float3 UnpackLogLuv(float4 vLogLuv)
float3 UnpackFromLogLuv(float4 vLogLuv)
{
// Inverse M matrix, for decoding
const float3x3 InverseM = float3x3(

}
// The standard 32-bit HDR color format
uint PackR11G11B10f(float3 rgb)
uint PackToR11G11B10f(float3 rgb)
{
uint r = (f32tof16(rgb.x) << 17) & 0xFFE00000;
uint g = (f32tof16(rgb.y) << 6) & 0x001FFC00;

float3 UnpackR11G11B10f(uint rgb)
float3 UnpackFromR11G11B10f(uint rgb)
{
float r = f16tof32((rgb >> 17) & 0x7FF0);
float g = f16tof32((rgb >> 6) & 0x7FF0);

return saturate(i * rcp(maxInt));
}
// Unpacks a [0..1] float into an integer using at most 'numBits'.
// Unpacks a [0..1] float into an integer of size 'numBits'.
uint UnpackInt(float f, uint numBits)
{
uint maxInt = 0xFFFFFFFFu >> (32u - numBits);

return float(BitFieldExtract(src, numBits, offset)) * rcp(maxInt);
}
uint PackR10G10B10A2(float4 rgba)
uint PackToR10G10B10A2(float4 rgba)
float4 UnpackR10G10B10A2(uint rgba)
float4 UnpackFromR10G10B10A2(uint rgba)
{
float4 ouput;
ouput.x = UnpackUIntToFloat(rgba, 10, 0);

正在加载...
取消
保存