🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Approaches to object scaling over large distances

Started by
3 comments, last by Gnollrunner 3 years, 3 months ago

First time poster, so apologies if this isn't the right sub-forum.

I'm working on a project capable of rendering the earth. When the user is viewing the planet from space objects on the ground become very difficult to see due to distance. To combat this, I've implemented a dynamic scaling system which stops objects from falling below a certain screen pixel size. It's a primitive check: if the width of the bounding sphere is < than a certain pixel threshold, I scale the object to maintain a constant size until the user is close enough to it that the bounding sphere exceeds that size. This works really nicely. The user can zoom into objects on the ground to see them in great detail, but when they pull away from the earth they shrink down to ~30px wide.

The issue I have is when the user is low to the ground but looking towards the horizon. Due to the fact that my objects are all scaled and forced to maintain a size of ≥ 30px, objects in the distance fail to shrink away and the user is able to see objects over hundreds of miles. I've tried to combat this by shrinking the minimum bounding sphere size for objects as the user approaches the ground and the pitch of the camera gets closer to the horizon line (so that when their pitch is ~90degrees and they're below a certain altitude the minimum bounding sphere size drops to 0 and distant objects disappear), but this results in objects ‘snapping’ from their fixed 30px size to some arbitrary value as the user passes the thresholds I've set.

I can't seem to come up with a sensible way to handle this. Does anyone have any suggestions?

Advertisement

You could fade out your upscaling with the angle between eye vector and gravity angle. Seems you only want to upscale if user looks downwards to earth. If he does so while being on ground, undesired upscaling should not happen because affected distant objects go out of sight.

I'm a bit confused about the snapping. Couldn't you just fade objects in between certain distance thresholds which, as far as I understand, are already height-related (or scale them down to zero if fading doesn't look good. Or both).

Given the user's distance from the ground you define a minimum and maximum bound around the user, which are scaled/adjusted as they move toward or away from the planet. That is, there's shell inside which objects get faded out or scaled below the 30px minimum size until the size becomes less than 1px (at which point you can simply not draw anything).

if(distance < minShell) objSize = max(objSize, 30px); // what you're doing right now
else if(distance < maxShell) objSize = 30px * ((distance - minShell) / (maxShell - minShell));
else discard;

If you adjust minShell and maxShell based on the distance from the ground you should see the the visibility of objects smoothly “adapt” as you move closer to or further away from the planet.

I'm confused. What's the difference between an object that is far away as viewed from space and one that is the same distance away but viewed from the ground? Shouldn't you're algorithm treat them the same way? I'm not sure why you would want to scale up objects at distance anyway. It seems to me you should fade them out completely. I would imagine if you didn't you would have a a Z-fighting problem.

This topic is closed to new replies.

Advertisement