浏览代码

add correct support of float

/main
sebastienlagarde 7 年前
当前提交
3717cdb2
共有 1 个文件被更改,包括 23 次插入7 次删除
  1. 30
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Debug/DebugDisplay.hlsl

30
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Debug/DebugDisplay.hlsl


// Draw a signed integer
// Can't display more than 16 digit
void DrawInteger(int intValue, float3 fontColor, uint2 currentUnormCoord, inout uint2 fixedUnormCoord, bool flipY, inout float3 color)
// leading0 is used when drawing frac part of a float to draw the leading 0 (call is in charge of it)
void DrawInteger(int intValue, float3 fontColor, uint2 currentUnormCoord, inout uint2 fixedUnormCoord, bool flipY, inout float3 color, uint leading0)
{
const uint maxStringSize = 16;

int numEntries = min((intValue == 0 ? 0 : log10(absIntValue)) + (intValue < 0 ? 1 : 0), maxStringSize);
int numEntries = min((intValue == 0 ? 0 : log10(absIntValue)) + (intValue < 0 ? 1 : 0) + leading0, maxStringSize);
// 3. Display the number
for (uint i = 0; i < maxStringSize; ++i)
// 3. Display leading 0
if (leading0 > 0) // Avoid warning
{
for (uint i = 0; i < leading0; ++i)
{
DrawCharacter('0', fontColor, currentUnormCoord, fixedUnormCoord, flipY, color, -1);
}
}
// 4. Display the number
for (uint j = 0; j < maxStringSize; ++j)
{
// Numeric value incurrent font start on the second row at 0
DrawCharacter((absIntValue % 10) + '0', fontColor, currentUnormCoord, fixedUnormCoord, flipY, color, -1);

}
// 4. Display sign
// 5. Display sign
// 5. Reset cursor at end location
// 6. Reset cursor at end location
void DrawInteger(int intValue, float3 fontColor, uint2 currentUnormCoord, inout uint2 fixedUnormCoord, bool flipY, inout float3 color)
{
DrawInteger(intValue, fontColor, currentUnormCoord, fixedUnormCoord, flipY, color, 0);
}
void DrawFloat(float floatValue, float3 fontColor, uint2 currentUnormCoord, inout uint2 fixedUnormCoord, bool flipY, inout float3 color)
{
if (IsNan(floatValue))

DrawInteger(intValue, fontColor, currentUnormCoord, fixedUnormCoord, flipY, color);
DrawCharacter('.', fontColor, currentUnormCoord, fixedUnormCoord, flipY, color);
int fracValue = int(frac(floatValue) * 1e6); // 6 digit
DrawInteger(fracValue, fontColor, currentUnormCoord, fixedUnormCoord, flipY, color);
uint leading0 = max(6 - (log10(fracValue) + 1), 0); // Counting leading0 to add in front of the float
DrawInteger(fracValue, fontColor, currentUnormCoord, fixedUnormCoord, flipY, color, leading0);
}
}
正在加载...
取消
保存