Gamedev Diary – SpaceLife #4

Planet hacking – multiple distant cameras

Ok – attempt 1 – multiple cameras that allow distant objects to be rendered. To overcome Z buffer accuracy…

  • I added more cameras as children of the main camera.
  • I added a layer called ‘distant’ – this allows only distant objects to appear in this layer, making the culling mask ‘distant’ (not shown below).
  • I changed the depth order so that the cameras would render farthest first
  • I changed the most distant camera to contain the skybox
  • I altered the near and far clipping planes.
  • I received an ugly error flooding my console (didn’t stop the program though) when exceeding the far clipping plane value 1e+07


I made the sun super huge:


I’m not particularly a fan of errors and warnings in my programs.  This approach has worked – but it’s not entirely satisfactory. I also wonder how many cameras should I add, where does it stop?

Thoughts so far on this approach:

  1. Unity soon complained about the values I entered (just warnings).
  2. When I  approach the sun, it looked massive, yay, but very rough meshes.
  3. When approaching them, my ship coordinates are far from 0,0,0 – which allegedly will cause madness with the physics calculations (if I were to hit an asteroid etc).
  4. Any layered effects you put on the object tend to be very fiddly and don’t show up (e.g. scaled down transparent spheres/particle effects), and they might look ridiculous at close range – I’ll have to do some more playing around to see if those can be worked around. Multiple LODs? Maybe switch meshes/objects out as they transition to closer cameras?

I’m going to shelve this idea for now and play with another….

Planet Hacking – The scaled down universe

For this experiment I just moved my planet and sun to a point way out of the scene, and re-parented them under a new game object. I then added a camera with a normal viewing distance, and placed solar bodies apart scaled down to 1/100,000,000th (one millionth) of their sizes.


The final trick is to add a LateUpdate() function onto my camera and tie in the distant universe camera as a public property of my main camera:


This worked great!


You can see my spaceship moved a huge distance (11 million units) and my camera in the mini universe only moved 11 units. However, as you can see – I’m now getting warnings that my spaceship is too far away. Another issue presents itself – when I get close to the sun, it doesn’t appear big any more. It is only 20 units wide – and it looks 20 units wide close up.  I’ve scaled the distance, but not the size.  Should I scale the size whilst moving? it all seems perverse. Maybe have bounding colliders that allow me to reposition the sun further away but at a bigger scale?

Back to the drawing board!

I think it’s time to find out how others achieve this – rolling my own is starting to get frustrating!

Its fun trying though.




Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s