0
\$\begingroup\$

I am implementing SDSM and in a GLSL compute shader I need to min/max vec3 values to compute the shadow map bounds. The sample implementation (in HLSL) uses vectors in "light space" that spans from 0-1 and then casts them with touint (in GLSL uintBitsToFloat) so that it can call InterlockedMinMax (atomicMin/Max) with them.

I was wondering if it is a better idea to quantize the values to an uint using the bounding volume in light space as uints instead of moving them into the 0-1 range so integer min/max works on the float bit pattern?

On the one hand using float bits in unit throws about about 2/3 the precision, because the sign bit and exponent are ignored. On the other hand almost all algorithms I came up to quantize the values somehow go past the 0-1 float range and would probably loose the precision anyway.

\$\endgroup\$
2
  • 1
    \$\begingroup\$ This looks like a question you could answer by writing up a method each way, and testing the two methods on every possible input float value, to compare how much precision you lose (how many input values get crunched to the same output) with one method versus the other. \$\endgroup\$
    – DMGregory
    May 6, 2019 at 8:31
  • \$\begingroup\$ Interesting approach. There are also non trivial performance considerations, but it is worth a try as it will give me an additional data point. \$\endgroup\$
    – rioki
    May 6, 2019 at 8:53

0

You must log in to answer this question.

Browse other questions tagged .