Jump to content

Rendering a Planet at a realistic scale.


Recommended Posts


For some time I have been working on a spherical terrain implementation in T3D. I have completed most of the basic work, and the terrain looks pretty good.

The terrain contains many "nodes" each of which is square, containing two triangular polygons. The vertex data for the polygons is in local space, and it between -1 and + 1. I scale the vertex data by the "radius" of the world.

The next goal I would like to tackle is rendering this terrain at a realistic planetary scale. I am not sure how to solve this issue, but I have spend some time thinking about it.

First of all, I am aware that the main issue is the floating point precision problem with 32-bit floats. I am assuming that I will be using a "floating origin" system, ie, the player will move around the world, but once they reach a certain distance from the origin, the entire world will be translated such that the player will be set to the origin. This is a fairly standard solution to this problem, and I believe it is what Kerbal Space Program uses.

Rendering a planet at long ranges is also fairly easy. I can just render the planet at the maximum distance that can safely be processed, say, 10,000 units, and then scale the planet to simulate a much further distance. IE a planet rendered at 10,000 units from the origin but scaled down by 50% will appear to be the same size as a planet rendered at 20,000 units from the origin and not scaled at all.

While the player is standing on the terrain, I should be able to treat the terrain as essentially flat, since the curvature won't be visible at that altitude. So, I could just render everything within the safe render distance of the player, and then cull anything beyond that. The player shouldn't notice this.

The problem I am having comes from the middle ground between being very near to the terrain and being very far.

For example, what if the player is in the upper atmosphere? They are high enough to see the curvature of the earth, and yet close enough that I can't scale the planet to a realistic size, since it's radius would then be greater than the safe value for a 32-bit float.

Can anyone shed any light on how I would solve this? I think there is something I am missing conceptually. I have done some testing, and scaling the terrain up to the size of a planet does cause rendering artifacts. What I need is some kind of floating origin system for the individual nodes of the terrain...

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...