Keeping an object the same apparent size regardless of distance

Started by Irony, July 14, 2014, 01:58:30 PM

Previous topic - Next topic

Irony

When I call
setScale (distanceToCamera)
on an object, shouldn't it always appear at the same size regardless of distance?  It seems to not work that way, so maybe my thought is wrong?


Irony

It is getting bigger when you are close. It's better than when there is no scaling done at all, but it's still very visible that the size changes.
I was thinking
twice the distance + twice the size => same apparent size,
but maybe I am thinking too simple?

EgonOlsen

How much does it change? Just subtle or quite visible? Your thinking seems reasonable to me, but maybe you are running into some accuracy issues with that approach.

Irony

It's subtle when the distance is > ~500 units
When you are very close it's very visible (multiple times the size)

As the use case is a particle effect, I guess I'll just use blitting instead of geometry.

EgonOlsen

It's most likely an accuracy issue then. Due to the limitations of the floating point format, neither the distance nor the scaling will be 100% correct and depending on the distance, this inaccuracies might become noticable. I don't see how to fix this...

Irony

Final update on this issue: it actually works exactly as it should the way I described. I was just stupid enough to not update the variable holding the distance.