Question Rendering engine camera far plane

dumbo2007

Crazy about real time sims
Joined
Nov 29, 2009
Messages
675
Reaction score
0
Points
0
Location
India
If we are rendering Earth from space, where do the rendering engines set the camera far plane ? I have heard that distances greater than 10,000 can cause z fighting due to the limited precision of the Z buffer. Yet the Earth's size is much larger and the entire globe needs to captured.
 

meson800

Addon Developer
Addon Developer
Donator
Joined
Aug 6, 2011
Messages
405
Reaction score
2
Points
18
Not sure about the details, but I think that several rendering passes are made. By the time vessel rendering occurs, the planets have already been drawn, so the far plane can be drawn much closer to the vessels.
 

SolarLiner

It's necessary, TARS.
Addon Developer
Joined
Jun 14, 2010
Messages
1,847
Reaction score
2
Points
0
Location
404 ROAD NOT FOUND
You scale down the entire scene. Or, you do the planet pass in a different layer, and put everything else in front when showing the frame.
 

dumbo2007

Crazy about real time sims
Joined
Nov 29, 2009
Messages
675
Reaction score
0
Points
0
Location
India
ok, scaling will work.

But even if doing the planet rendering in a different pass, the near and far plane would still be separated by a million or more meters I guess when rendering the planet ?

Otherwise the entire globe could not be rendered. Wouldn't this lead to z-fighting at the pixels belonging the planet ?


Or is it that the planet is rendered in several layers, each layer having the near and far plane 1000 units separated. So there would be many layers.
 
Last edited:

SolarLiner

It's necessary, TARS.
Addon Developer
Joined
Jun 14, 2010
Messages
1,847
Reaction score
2
Points
0
Location
404 ROAD NOT FOUND
Nope, you render the foreground full scale, then render the planet scaled down ! As long as the cameras match up it works.
 

dumbo2007

Crazy about real time sims
Joined
Nov 29, 2009
Messages
675
Reaction score
0
Points
0
Location
India
Oh you mean the camera view is in some way scaled down ? So if rendering at say 1/1000th scale, then the dimensions of the camera view is also scaled down to 1/1000th ? That reduces the view frustum depth to 1/1000th so that would bring the planes much closer.

But then this view has to be scaled up again to match the back buffer width and height, or at least the same camera view dimensions as the ones with which the vessel in orbit is rendered.

---------- Post added at 09:08 PM ---------- Previous post was at 09:02 PM ----------

Ok I got a good bunch of articles on this : http://www.gamasutra.com/view/authors/322755/Sean_O'Neil.php

So he sets the far plane at some constant, sufficient to ensure z-buffer precision, then scales down everything, size and distance, exponentially. So this preserves the z-order and everything fits inside the squeezed view frustum too.

Still digging into how to match this down scaled stuff up with the scale in which the normal objects like vessels etc are rendered. Just scale the planet's rendered image to match the back buffer size ? Or maybe I am totally wrong here and there is no need to match it up at all as the camera view is rendered to the entire viewport and is automatically stretched. As in, the view through the camera would not look any different even if the actual scale at which everything was rendered was lower.

---------- Post added 28-12-13 at 12:23 AM ---------- Previous post was 27-12-13 at 09:08 PM ----------

ok, I am beginning to understand this separate pass rendering more clearly now after reading : http://www.gamasutra.com/view/feature/131393/a_realtime_procedural_universe_.php?page=3

multiple times :p

The maximum allowable ratio of near to far plane distance seems to be 1:10000. So the earth being about 12,742,000 meters wide, it can be scaled down by 1/2000 to say a 6371 meter sphere. All rendering and texturing would be done at this scale. Then the rendered image is simply rendered as a textured quad into the backbuffer

If other bodies like the Moon is visible, it is scaled down and brought closer by the same distance.

But scaling down the Moon's distance by 1/2000 brings it to 192,200 meters. Thats still much farther than the far plane. Do we then scale down only the Moon further at perhaps 1/10,000 ? But still render the Earth at 1/2000 ?

When both images are composited into the final image, wont the difference in size be noticeable ?
 
Last edited:

SolarLiner

It's necessary, TARS.
Addon Developer
Joined
Jun 14, 2010
Messages
1,847
Reaction score
2
Points
0
Location
404 ROAD NOT FOUND
What I would do is render each planet separately, using their own Z-buffers. Then you just have to have a "rough" Z-depth what will place the passes on top of each other the correct way.

But if you take Orbiter as an example; there is no Z-depth: the planet is rendered, then the bases and finally the ships, so we are sure they're all correctly rendered without any Z-fight. Now with the terrain feature this had to be redone as you need Z-depth to tell if something is behind terrain or not.

After all, every game has Z-fights: I experienced some in FSX, LOFC2 and Tomb Raider (the last one) as well. And as it happens far away it is not that noticeable at all and should not be a big bug to be removed right away.
 

Glider

Addon Developer
Addon Developer
Joined
Apr 12, 2008
Messages
226
Reaction score
0
Points
16
Location
Saint-Petersburg
I think u can just put the far plane somewhere at few thousands km(so it can have most distant terrain tile within range) and render all distant stuff without depth first after its sorted by distance. and then render terrain and all objects with depth and cut off pixels with more depth. Probably should be ok to put near plane at 0.1 meter. Of course do not scale rendered image if you don't wanna get some ugly blur when it will get upsampled. :)
Default way to use depth buffer when u have 0 at near and 1.0 at far plane doesn't work with really different planes so there can be some depth fighting if u extend far plane to 1e6 or so. Also theres a way to use a reversed depth buffer(possible only with direct3d though, because of -1.0/+1.0 range in opengl ) or logarithmic(slower) which can allow u to have near plane at 0.01 meter and far plane at millions km (interesting article about depth mapping with very different far/near planes - http://outerra.blogspot.ru/2012/11/maximizing-depth-buffer-range-and.html).
 
Top