2
\$\begingroup\$

I'm trying to build a game in Unity similar to the game Kerbal Space Program where there are large celestial bodies that the player can orbit. I'm running into a few problems though. My first issue is that the larger I make a sphere, the slower the game gets. Secondly, whenever the sphere exceeds a certain size, the rendering engine cuts off part of the planet, which means I can only see half the model. How can I do this at the size that KSP has?

\$\endgroup\$
7
\$\begingroup\$

which means I can only see half the model

You can never see the "back" half of the model :P

The following is a high-level overview listing some of the LOD considerations for this type of game. 100% of it may not apply to your game and/or KSP. Also, I haven't specified any implementation details for Unity, since I don't know them yet; rather than define each rendering method, I've described how you'll need to be able to transition between a number of different methods, all geared toward reducing as much of the scene to quads as possible.

Bill-boarded impostors:
An impostor is a stand-in for the real thing; in this case, a celestial body. In graphics, a bill-board refers to a quad that is continuously reoriented such that the quad's face-normal is always pointing directly toward the camera; their full width and height are equally observable from any angle.

Very, very, near:
As you approach the surface of a planet, it starts to look "flat". While landing, transition from sphere rendering to quad rendering. This is, essentially, a first-person-shooter camera/perspective (fog near the far-plane). When leaving the surface, transition back to the sphere; "up" starts to become arbitrary, the fog vanishes, atmosphere glow appears, the "sky" becomes black. The height at which you begin the transition may be different, per-object/planet. As you continue to move away from the object, its' textures can transition to progressively lower mip-levels; the sphere geometry begins to produce less detail than a mipped bump-map would.

Near:
When the object's details start to become indistinguishable because of mip and/or size, switch to billboards. Update more-distant bill-boards, less-often; this reduces the number of spheres rendered per-second in favor of quads that look like the rendered spheres. Essentially, you "cache" the close-up, full-detail, sphere to an off-screen texture every now and then, and just pick a mip out of it that looks "good enough" based on the increasing distance from the camera when you render each billboard. The camera used to render the sphere to the bill-board is set up a little different than the normal one. When approaching a planet, the reverse applies; the mip level increases, bill-boards are updated more, and more, frequently and you move from the bump-map back toward the displacement-map.

Distant:
At some point, the majority of the remaining details will be lost and/or compressed to a very small number of pixels. At this point, you can get away without texture sampling and just output a "star-like" color, possibly with a hint of the atmospheric hue.

Very, very, distant:
Regardless of composition, very, very, very distant objects are usually rendered as (approximately) white dots, or not at all. A large planet might look like a star when it's somewhat near, but will be mostly indistinguishable next to the parent star's overwhelming relative magnitude. Pseudo-random "twinkling" of the dots gives the illusion that very distant things are happening. You can render the dots to another off-screen texture and apply it to a sky-box/sphere that follows you around. Since it contains only the most distant objects, you won't need to update it very often.

enter image description here

\$\endgroup\$
1
\$\begingroup\$

The issue is that you need a LOD algorithm. LOD stands for level of detail and it means essentially your sphere is only as big as it needs to be in each situation. When you are far away it uses fewer polygons. When you are zoomed in close, maybe only part of the sphere is in memory, and that visible section has a lot more detail than usual. There's lots of LOD techniques out there that might help you (:

\$\endgroup\$
  • \$\begingroup\$ Do you know any examples or a few tutorials that could get me started with this? \$\endgroup\$ – Ethan Bierlein Apr 26 '15 at 1:10
  • \$\begingroup\$ Yeah I found a ton when googling "unity level of derail tutorial", go check em out! \$\endgroup\$ – Alan Wolfe Apr 26 '15 at 1:54
  • \$\begingroup\$ since yu referenced ksp , try this youtube.com/watch?v=mXTxQko-JH0 at minuute 30 \$\endgroup\$ – dnk drone.vs.drones Apr 26 '15 at 8:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.