Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

create the illusion of a big planet

Discussion in 'General Discussion' started by sebastian.g, Dec 23, 2014.

  1. sebastian.g

    sebastian.g

    Joined:
    Nov 20, 2014
    Posts:
    8
    Hello, I want to create a little game where you control a spaceship and just go around in space. I want to put in some planets but I'm afraid that such big objects would destroy the performance. Am I wrong? If not, how could I create the illusion of a really big object in space?
     
  2. ippdev

    ippdev

    Joined:
    Feb 7, 2010
    Posts:
    3,789
    Perspective. Object swap outs based on apparent distance. Maybe read some sfx how it was done guides to various movies that use planets and starships. They certainly do not use real ratio scaling. cgtalk has tons of that kind of post production insider looks.
     
    sebastian.g likes this.
  3. zombiegorilla

    zombiegorilla

    Moderator

    Joined:
    May 8, 2012
    Posts:
    8,952
    Also multiple cameras work. (small object close to camera)
     
    Ony, sebastian.g and AdamScura like this.
  4. AdamScura

    AdamScura

    Joined:
    Mar 25, 2012
    Posts:
    55
    As I recall, Half Life 2 did this. Every level would have a small "skybox" hidden somewhere far away from the player. There would be a second camera at the center of the skybox that rotated in sync with the main camera. Inside the skybox was a little miniature of the city skyline. When the skybox camera was rendered behind the primary camera, it created the illusion of the surrounding buildings being far away.



    You could do the same thing with planets. Set up a secondary camera, and make your miniature planets only visible to the secondary camera. Every LateUpdate, rotate the secondary camera to match the main camera, and position the secondary camera at a fraction of the main camera's position. For example if the scale is 100:1, moving the main camera 100 units moves the secondary camera 1 unit. If the player gets close to the planet, you would swap in a larger model that is visible to the main camera. (like @ippdev suggested).
     
    Last edited: Dec 24, 2014
    Not_Sure, Ryiah, Ony and 3 others like this.
  5. sebastian.g

    sebastian.g

    Joined:
    Nov 20, 2014
    Posts:
    8
    thank you guys, you're awesome! I'll try that
     
    Ony likes this.
  6. Not_Sure

    Not_Sure

    Joined:
    Dec 13, 2011
    Posts:
    3,541
    This is called a 3d Skybox, and it's exactly what Unreal Tournament did for the stage "Facing Worlds" way back in 1999.
     
  7. wbakunis

    wbakunis

    Joined:
    Jan 28, 2014
    Posts:
    50
    Interesting. How did games like Bulletstorm pull off using large vehicles like the grind wheel or the dinosaur entity? Are those actually to size or is it another perspective trick?



     
  8. Not_Sure

    Not_Sure

    Joined:
    Dec 13, 2011
    Posts:
    3,541
    Yup. 3d skyboxes.

    Probably.
     
  9. BFGames

    BFGames

    Joined:
    Oct 2, 2012
    Posts:
    1,543
    Procedural generated planets and LOD.
     
  10. lmbarns

    lmbarns

    Joined:
    Jul 14, 2011
    Posts:
    1,628
    PrimalCoder, GarBenjamin and goat like this.
  11. k1mset

    k1mset

    Joined:
    Dec 4, 2012
    Posts:
    64
    Was actually reading earlier on the forums and someone had a great idea. Have the planet, a giant sphere textured. With cloud type particles, or a animated atmoshere, when you get close you could have a zone warp to another scene where its the ground.
     
  12. Grimwolf

    Grimwolf

    Joined:
    Oct 12, 2013
    Posts:
    296
    More details would help in finding the best approach.
    Are the planets just in the distance, or can you actually fly by them? Do you intend to actually be able to get close enough to land on them, or just pass by?
     
  13. TylerPerry

    TylerPerry

    Joined:
    May 29, 2011
    Posts:
    5,577
    Why would you want them small? if the object is still high poly won't the performance be the same? The only thing I could think of is draw distance, but in the UT example it's the only model far away so would it really make a difference?

    (Though it would obviously be neater to do it with small objects)
     
  14. AdamScura

    AdamScura

    Joined:
    Mar 25, 2012
    Posts:
    55
    Draw distance is the limiting factor. 3D rendering hardware has to write all depth values to a z-buffer. This is basically an image where each pixel stores a 24-bit depth value instead of color. So if you set your camera depth too large (like over 1,000,000) you're going to start losing depth resolution and you'll start to see nasty rendering artifacts.

    z-fighting.png

    Figure 1 shows two 1m spheres with an offset of 0.01m between them, at 2m from the camera. You can see the hardware correctly shows the red sphere in front on the left side, and the yellow sphere in front on the right side.

    Figure 2 shows the same two spheres at a distance of 2,000,000m from the camera, and scaled appropriately. You can see the hardware is having trouble telling which one is in front of the other because of the depth buffer resolution.

    I actually expected the Z-Fighting effect to be much worse. Surprisingly Unity can render objects that are very very very far away without much difficulty. But the editor does warn you if you put anything more than 1,000,000m from the center that you will be losing floating point precision. I would be concerned it would mess up your physics simulation if you have objects that far away. Plus you can't even see the objects in the scene view when they are that far away, so it would be difficult to work with your scene. So, just don't do it. Use a skybox.
     
    TylerPerry likes this.
  15. sebastian.g

    sebastian.g

    Joined:
    Nov 20, 2014
    Posts:
    8
    just pass by ... anyway, the skybox solution seems to work wonderfully, I just have to practice more with it
     
  16. Arowx

    Arowx

    Joined:
    Nov 12, 2009
    Posts:
    8,194
    Check out how Kerbal space program overcame the physics and size limitations within Unity using 3 scaled camera scenes and their own 64bit solar system simulation, they did a talk on it that you can find on youtube.
     
  17. sebastian.g

    sebastian.g

    Joined:
    Nov 20, 2014
    Posts:
    8
    looks interesting, I'll look for it later
     
  18. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    20,071
    You're referring to the talk they did back at Unite 2013? I think the discussion relevant to sub-scenes starts around eleven minutes into the video.

     
    Arowx likes this.
  19. Illuminism

    Illuminism

    Joined:
    Jul 30, 2015
    Posts:
    5
    Full tutorial on this right here y'all!
     
    Benfont, PrimalCoder and Ryiah like this.