Skip to main content

Are there techniques for rendering objects very far away?

7 replies [Last post]
areeves42
Offline
Joined: 2010-08-12

I'm interested in writing an application that would simulate space travel and so the distances involved are astronomical (literally!). I know I can set the far plane from the view object to a fairly large value, but then the depth buffer is likely to be horribly inaccurate for objects which are very close. My question is whether there is any way around this?

My only thought on it is some sort of two-pass rendering- first rendering objects 10,000 meters to some very large distance in one pass and then rendering objects 1 meter to 10,000 meters in a second pass using the first pass as a background or something. This does seem quite inefficient, and I don't know, but I suspect there might end up being some significant rendering issues along the threshold between the two "layers"... assuming it works at all.

Anyone have any thoughts on this? Any input would be greatly appreciated! Thanks!

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
lyfox
Offline
Joined: 2010-08-17

And what about setting up several Locales, one for each planet or galaxy? Hi-resolution coords are designed specifically for those astronomical (and at the same time molecular) distances, as I see it. And with all that in mind renderer should behave properly, or elsewise there would be no use for such things.
Haven't tested it yet, so.. am I mistaken?

weiland
Offline
Joined: 2005-08-05

I'd suggest the multiple layer approach. You could use multiple JCanvas3Ds and stack them together using Swing's JLayeredPane (there are a few wrinkles to using that - I think you have to make sure to keep backgrounds transparent, and might have to tinker with layout managers to keep them stacked correctly). It might cost some render speed, but how dense are your layers likely to be?

Let us know how it works out!

Bill

areeves42
Offline
Joined: 2010-08-12

The "far" layer will probably be quite sparse (space is a cold, empty place, after all) but I could have a good bit of geometry in the "near" layer as I the camera moves around planetoids and space stations and other irregularly shaped things like that. If the rendering of the far layer becomes burdensome, it leaves open the ability of having two symmetric universes- only difference being the geometric complexity of the objects... but I'm getting ahead of myself here. :)

aces
Offline
Joined: 2003-07-17

Also check Background javadocs.

darwinjob
Offline
Joined: 2004-11-16

Hmm...
Maybe you can create a behavior which will "physically" scale down the objects that are far away? I mean that the objects will look smaller but they are actually not SO far away? You need a function of a distance from the camera to an object:
scaleFactor = f(distance)

Something like -1/x might do the trick I guess...
s = -1/(d - farClipPlane) + 1

Or maybe something logarithmic...

Don't judge me too hard - I'm inventing on the fly
:)

areeves42
Offline
Joined: 2010-08-12

Thanks for the input. I had considered something like this, and if I can't come up with anything better, this may be something I'll try. Not sure what the computational overhead would be, but it might not be too bad. Other problem would be that I'd end up with two coordinate spaces so I'd be converting coordinates from the universe in which my stellar bodies exist into java3d Universe coordinates to be rendered... and if that conversion isn't linear, it could get pretty computationally heavy pretty quickly.

The one thing I do like about this approach, though, is that it has a fairly similar effect to setting the far clip plane a very large distance from the camera, but doesn't distribute the depth buffer's discrete increments linearly, but rather, would give more resolution up close and less resolution the further away you get- which is a good thing.

yudanjiao
Offline
Joined: 2010-08-13

As a matter of fact, teachers' friendly appearance can greatly encourage the students' studying enthusiasm. Furthermore, the characteristics of theoretic and abstraction of knowledge also [url=http://www.uggboots-esales.com/ugg-classic-tall-boots.html]ugg boots tall chocolate[/url] [url=http://www.uggboots-esales.com/ugg-sundance-ii-boots.html]ugg ascot[/url] [url=http://www.uggboots-esales.com/ugg-sundance-ii-boots.html]ugg australia boots online store[/url]
requires the vivid, dramatic and an accessible gestures to make it specific and figurative. As a result, the students' interest is motivated and the effect of teaching is greatly improved.