Long Distance Rendering
I wan't to be able to see objects from VERY far away, but it takes up too much CPU when I have lots of detailed objects. Sometimes I can't even see the object from too far, even though the distance on the camera is to the max. I am trying to make the solar system, with somewhat realistic distances and still lots of detail to the planets, and still being able to see the tiny dot (as a planet) in the distance. Does anyone know how I can do this?
Answer by lodendsg · Jul 16, 2017 at 11:54 AM
KaletheQuick's reply is a solid answer if your game has a single scale e.g. if you only ever play from a very far distance camera view.
We are also working on a space game and have need of very long distance views but we also needed a rather close nearly 'human perspective' view as KaletheQuick called it.
To achieve this we use layered cameras, note that in Unity you can discribe the order in whcih your cameras will render and what objects (layers) it will render. In our case for example we have UI, Near, Far and Back we also have 4 cameras that coraspond to thouse each camera renders only the objects on its respective layer and has a resonable clip distance with a total range less than 1000 units anything more than this and you will see shadow flicker.
Next we have our scene split up such that objects on the 'Back' are scaled similar to the 1 unit = 1 AU range Near uses 1 = 10m and Far uses a 1 = 100000m. Far camera moves at a rate scaled to Far camera e.g. when Near moves 1unit Far moves 1/10000 units ... in our case Back camera is fixed e.g. it never moves only maps rotation like a skybox camera would.
The ranges you use will depend on your game ... in our case we know no object will transition from Near to Far or Far to Near without the player 'warping' which means we can use the warp effect to hide the transition.
Few notes about this method ... shadows cannot cross cameras e.g. an object rendering on Far will not cast shadow on an object in the Near ... there are a few situations where you might need an object to do this and you can use the Shadow Only option of Mesh Renderer to suit these situations in most cases.
As I recall Kerbal Space accadamy used a similar method and had a talk on it at a GDC or a Unite session though I cant recall which nor can I find it on YouTube at the moment.
The point being to use a variable scale and multiple cameras to achieve both a high detailed near by view and a long distnace view with the draw back that objects cannot enteract between the near and far views without some special trickery depndent on your game.
Answer by KaletheQuick · Jun 12, 2017 at 05:17 PM
@GameMaker102 Unity has a built in level of detail system that can automatically swap one mesh with another at distance.
https://docs.unity3d.com/Manual/LevelOfDetail.html
You can use this system with meshes of lower and lower detail. I believe the trees in the "standard assets" are set up with this. And the terrain system has another trick that might help you out. The last and farthest level of detail are taken down to a single quad, that's just a flat square mesh, two triangles!! The quad is pointed at the camera all the time, so it is called a billboard. For the trees it just has a picture of the tree. For your planets, an appropriately colored dot would work. Beyond that you would get into some complicated stuff involving "apparent magnitude" and other stuff astronomers talk about.
I would also like to tell you about scale for a solar system... system. Normally for games and stuff we use 1 unity unity to mean one meter. But that's just a human perception. You could easily just say that 1 unity unit is a thousand, or a million meters! I would recommend that you use 1 unit to be 1astronomical unit. That way you can fit everything out to Pluto in a 80 unit circle, so you would avoid any floating point errors.
@$$anonymous$$aletheQuick @lodendsg Thanks for answers guys, though I've given up on it ever since I discovered $$anonymous$$erbal Space Program. It was almost exactly what I wanted to make (but with kerbals ins$$anonymous$$d of people). Still, thanks for the replies.
Answer by jnbbender · Nov 27, 2017 at 01:25 PM
@GameMaker102 - Just in case someone else comes across this question, I use an asset for this (https://assetstore.unity.com/packages/tools/camera/per-layer-camera-culling-35100). Not too sure if this applies to your problem but you can at least isolate your objects to a specific layer.
Your answer
![](https://koobas.hobune.stream/wayback/20220612111329im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Terrain detail rendering squares 0 Answers
My detail meshes turns black when they don't have a geometry behind (Oculus VR) 0 Answers
Android Render Issue 0 Answers
Aura Rendering 1 Answer
Render All Squares in a Grid 0 Answers