# Rendering huge (space) distance technique

## Recommended Posts

Hi, I know that this topic was discussed not one time, but after reading all of them I could found, I still have questions.

I try to make for now simple space simulator, but I faced with some issues regarding projection matrix:

1. - If I set very big zFar value, I will see model even if it is huge, but in that case I will have problem with picking, because it is not working if zFar is more than 16777216

2. - I can set ZFar separately in shader as I use logarithmic z-buffer, but it will still have picking issues because it just return true/false randomly.

3. If I set zFar to 16777216, It will definately decrease my view distance even if I scale my models down.

Taking into view all this issues, I want to know the best technique to rendering huge objects and to keep picking algorithm work correct.

I read about multi-layer rendering with multiples depth buffers, but I didnt find any example and I dont know the concept in general.

Could anyone point me on the right way?

#### Share this post

##### Share on other sites

Skybox is good for very-very far objects like stars and nebulas, but not for rendering huge objects like planets and so on, which is near camera.

How it is implemented in space engine, for example. You see whole planet as huge as it is and as I understand it is not rendered as sprite or something like that.

Edited by BlackJoker

#### Share this post

##### Share on other sites

How it is implemented in space engine, for example. You see whole planet as huge as it is and as I understand it is not rendered as sprite or something like that.

Just scale down the planet?

#### Share this post

##### Share on other sites

Just scale down the planet?

And always change planet position during flight? Super. And what about when I will on planet? Scale part of the planet and move it too?

I asked about multi depth buffer rendering. Do you know something about this?

#### Share this post

##### Share on other sites

Hi BlackJoker

Scaling is a valid option. I have rendered planets and stars like this from very far away to ground level. You only need to start scaling and translating the planets when you are quite a way from the ground - so when you are standing on the planet it is OK. As you move away at some point you can reduce the planets scale and translate it closer to the viewer so that it looks the same.

I used this article to help me solve it: http://www.gamasutra.com/view/feature/131393/a_realtime_procedural_universe_.php?print=1

#### Share this post

##### Share on other sites

Hi BlackJoker

Scaling is a valid option. I have rendered planets and stars like this from very far away to ground level. You only need to start scaling and translating the planets when you are quite a way from the ground - so when you are standing on the planet it is OK. As you move away at some point you can reduce the planets scale and translate it closer to the viewer so that it looks the same.

I used this article to help me solve it: http://www.gamasutra.com/view/feature/131393/a_realtime_procedural_universe_.php?print=1

It will work if you have no physics engine, but what if I want to calculate detail gravity interaction? Or what if want to make MMO? You suggest to move shared for all objects individually for each player???

I dont want to do a mess from my world moving all objects around like in dance.

I take into view your suggestion but I also want to know about other variants, which, I beleive, present.

#### Share this post

##### Share on other sites

You can't have an universal general solution for this - no rendering engine is able to render simply astronomic distances, no physics engine is able to calculate physics of a galaxy, not a star system, not even a whole planet.

So, you'll need to split the problem in to some manageable such as:

- render scene several times, once for objects near the observer (maybe 0 - 5 km). Most of small ships could be drawn in this scale

- 5km to some very big number, heavy use of culling of small objects. Most of small ships won't be visible, only huge capital ships, asteroids etc

- "sky" box for the rest

The problem isn't just the only z-buffer. You'll notice that floating point accuracy isn't much when going to open space. I'm saying that you can't except a camera to work correctly with just 3 floats for position, even doubles won't cut it. You'll need to use some kind of a grid structure in order to keep the camera in some manageable range from origo.

Cheers!

#### Share this post

##### Share on other sites

- render scene several times, once for objects near the observer (maybe 0 - 5 km). Most of small ships could be drawn in this scale
- 5km to some very big number, heavy use of culling of small objects. Most of small ships won't be visible, only huge capital ships, asteroids etc
- "sky" box for the rest

Exactly about rendering a few times for different distances I want to know more. So, do you have some examples or links to articles about that?

#### Share this post

##### Share on other sites

Good luck - if you find something be sure to share it, I would like to know about this too!

Regarding the scaling option: This is no problem for the physics engine or the network code as you only scale and translate for rendering.

You can have an additional matrix which combines the two operations passed into the shader. It should not effect the actual objects position as far as the physics engine or network code are concerned as they can operate on the object "as is".

Its just a trick to move the Z-values back into an acceptable range for the Z-Buffer. It may also require some Z-sorting to when planets obscure each other.

#### Share this post

##### Share on other sites

Practically you'll just split your visible scene in slices and perform rendering for each slice. After that it is just a question to put those rendered slices together. Of course, you can and probably must use some scale tricks also with the further slices in order to keep the depth buffer happy.

Cheers!

## Create an account or sign in to comment

You need to be a member in order to leave a comment

## Create an account

Sign up for a new account in our community. It's easy!

Register a new account

## Sign in

Already have an account? Sign in here.

Sign In Now

• ## Partner Spotlight

• ### Forum Statistics

• Total Topics
627676
• Total Posts
2978582

• 11
• 12
• 10
• 12
• 22