Author Topic: Keeping an object the same apparent size regardless of distance  (Read 1093 times)

Offline Irony

  • long
  • ***
  • Posts: 151
    • View Profile
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?

Offline lawless_c

  • int
  • **
  • Posts: 91
    • View Profile
Re: Keeping an object the same apparent size regardless of distance
« Reply #1 on: July 14, 2014, 06:26:08 pm »
What is it doing?

Offline Irony

  • long
  • ***
  • Posts: 151
    • View Profile
Re: Keeping an object the same apparent size regardless of distance
« Reply #2 on: July 14, 2014, 06:57:54 pm »
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?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11745
    • View Profile
    • http://www.jpct.net
Re: Keeping an object the same apparent size regardless of distance
« Reply #3 on: July 15, 2014, 08:46:24 am »
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.

Offline Irony

  • long
  • ***
  • Posts: 151
    • View Profile
Re: Keeping an object the same apparent size regardless of distance
« Reply #4 on: July 15, 2014, 09:40:58 am »
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.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11745
    • View Profile
    • http://www.jpct.net
Re: Keeping an object the same apparent size regardless of distance
« Reply #5 on: July 15, 2014, 03:39:53 pm »
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...

Offline Irony

  • long
  • ***
  • Posts: 151
    • View Profile
Re: Keeping an object the same apparent size regardless of distance
« Reply #6 on: August 15, 2014, 01:48:33 pm »
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.