-
Notifications
You must be signed in to change notification settings - Fork 216
Closed
Description
Generation of color ramp uses different math than MSDN example.
and (from here):
UINT8 interpolate(UINT8 e0, UINT8 e1, UINT8 index, UINT8 indexprecision)
{
if(indexprecision == 2)
return (UINT8) (((64 - aWeights2[index])*UINT16(e0) + aWeights2[index]*UINT16(e1) + 32) >> 6);
else if(indexprecision == 3)
return (UINT8) (((64 - aWeights3[index])*UINT16(e0) + aWeights3[index]*UINT16(e1) + 32) >> 6);
else // indexprecision == 4
return (UINT8) (((64 - aWeights4[index])*UINT16(e0) + aWeights4[index]*UINT16(e1) + 32) >> 6);
}
The difference is that MSDN approach avoids floating-point calculations by using right-shift at the end.
This gives different results, e.g.:
mode 6:
color_bits = 7 + 1
ep0 = 1
ep1 = 82
index_bits = 4
index = 7 (30/64)
MSDN:
((64 - 30) * 1 + 30 * 82) >> 6 == 38
Compressonator:
1.0 * (1.0 - 0.46875) + 82.0 * 0.46875 + 0.5 == 39.46875
Metadata
Metadata
Assignees
Labels
No labels