0

I want to make sure that 3 valeus add up to 1 when added together. The values are floats, It doesn't seem possible to use doubles.

I'm in directx and c++, when I'm adding them together they all become 1 but when I send them to the vertex shader for some reason they only add to 0.999999 and its causing lots of issues.

I would like to saturate them or something so that they become one when added together but I dont know how. for example one value can be 0.2 another 0.2 and the third 0.6 but with more digits and when i send them to the shader instead of 1 they add up to 0.99

I am using them to scale different matrices.

So its important they become 1 together.

  • Why is it important that the sum is 1 and not 0.999999? It shouldn't be an issue. Relying on exact floating point values (without any error tolerance) is generally a bad idea. – Maciej Dziuban Mar 06 '20 at 15:50
  • You could add them up in the vertex shader and then divide by the sum, but again, I think it kinda smells. It might even be impossible to achieve that in every case - floating point arithmetics (including division) introduces errors by definition – Maciej Dziuban Mar 06 '20 at 15:53

0 Answers0