RealityKit SIMD3<Float> precision decreases with distance?

The farther away the center of a large entity is, the less accurate the positioning is?

For example I am changing only the y-axis position of an entity that is tens of meters long, but i notice x and z drifting slowly the farther away the center of the entity is. I would not expect the x and z to move.

It might be compounding rounding errors somewhere, or maybe the RealityKit engine is deciding not to be super precise about distant objects? Otherwise I just have a bug somewhere.

Yes, floating point values get less precise the larger they are. If that is a complete surprise to you, read something about floating point.

Whether that explains what you’re seeing or not, I don’t know. There could be other issues involved.

Maybe I am not explaining the problem correctly.

X and Z are not changing, only Y.

So I could see how X and Z would lose precision as they got larger, but not if they are remaining the same value.

Are you saying the implementation of SIMD3<Float> is not a collection or struct of three separate values?

Are you saying the implementation of SIMD3<Float> is not a collection or struct of three separate values?

No, I'm not saying that; the Swift SIMD type is certainly just a struct of regular floats. I believe the corresponding GPU arithmetic is too.

But by the time these values have gone through all of your transform matrices, and in particular perspective devision, every value could have had some sort of influence on every other.

However, as I said, "there could be other issues involved". Keep debugging.

Hello @jnorris441,

For example I am changing only the y-axis position of an entity that is tens of meters long, but i notice x and z drifting slowly the farther away the center of the entity is. I would not expect the x and z to move.

Can you clarify this behavior? Do you mean that you are changing the y-value only, but when you log the x and z values, they have changed?

-- Greg

@DTS Engineer

Yes I have seen x and z change when only setting y. I also tried setting x and z to stored values and logging the position looked correct. However visually the entity would be drifting on x and z the farther away y was.

My use case was dragging an entity up and down and attaching children to it to creating an infinite scroll. If you scroll for a while, the positioning of the parent entity on x and z would appear to change even if the correct values were logged. The workaround was to move the children out of the scroll entity, and just use the y to position them manually.

I could imagine you would see the same issue if you just created an entity that was 50 or 100 meters long and tried moving it along one axis though.

RealityKit SIMD3&lt;Float&gt; precision decreases with distance?
 
 
Q