Ah, okay, understood, thanks for clarifying.
So, yes, adding 1e3 + 1e-4 is relatively inaccurate compared to the smaller number, and you can lose the smaller number completely. In that exact scenario when using fp32, 1e3 + 1e-4 == 1000.0001220703125, giving you an error of 2e-5 (or 20% of your offset). If you try to add 1e3 + 3e-5, you will get exactly 1e3, and lose the 3e-5 entirely (error of 100% of the offset).
Of course, this is always the case with floating point math, even when you don’t notice it. The result of any calculation will be rounded once the result is represented in fp32. When adding a offset to a point, the result will usually not be exact, and so in general it will move to the nearest point in the space of representable fp32 numbers. When you add any number that is smaller than half of the magnitude of the least significant bit of your 23-bit mantissa, then yes the final result will be equal to, and indistinguishable from, your larger number.
Do you know how much error in your ray origin would be acceptable?
You are not using any non-identity instance transforms? And these large-magnitude numbers are part of the original mesh data, correct? If these triangles are small and your mesh coordinates are large such that it’s difficult to compute a ray origin, then I’m wondering if the mesh data itself might be causing problems? Are any of the triangles degenerate? If the original mesh is fp64, and is being converted to fp32, for example, then you may have the same problem with your input data - vertices will be rounded, and they could easily snap to the same grid point and cause your triangle to have an area of zero. OptiX rays will automatically miss degenerate triangles.
In any case, based on what I believe from your description so far, I’m not aware of any way to fix this issue, it sounds like a fundamental mismatch of scale vs desired precision. If the precision you need for your ray origins is smaller than around 1e-7 (or around 2e-23) times the vertex coordinate, then fp32 simply can’t do that. It doesn’t even matter that the mesh values are large, it only matters how small your desired precision is compared to the mesh values. You could imagine scaling the model down, but I assume your precision needs would scale with it, so that doesn’t change anything. It is possible I still don’t understand the setup & goals correctly though.
–
David.