- Home /
Make Object be rendered far away
How do i make a specific object be rendered from an infinite distance? For an example, if the rendering limit for a camera is 300, how can i make a script that makes a single object to be rendered no matter it's distance from the camera? Is it even possible? I need to be sure that a sphere in my game is going to be always rendered and seen.
Answer by SergeantBiscuits · Oct 13, 2016 at 11:49 PM
3D computer graphics operate on what's called a "z-buffer," which basically describes how 'far away' things are from the camera. That data is stored as a bunch of values (floats, I think), which have a finite size (and therefore a finite accuracy.) The z-buffer operates between the "near clip plane" and "far clip plane" of your camera. The smaller the difference between your near and far clip planes, the "more accurate" your scene is going to be rendered.
If the distance between your clip planes is too large, you'll start seeing geometry 'wiggle' because the step-increments for the z-buffer are too large.
You can generally put the clip plane out to a few thousand units without too much trouble, as long as you don't have any tiny objects close to your camera that you need to render accurately.
I made a space combat game once that required rendering both tiny fighters and huge battleships that were several kilometers away, so what I did was use two cameras, one set with clip planes from 1-500 units, and another with 500-10,000 units, and render the 'short range' camera 'on top' of the 'long range' camera. This works fine as long as you're not using anything too fancy as far as post-processing effects (like toon edges or whatever).
Let me know if any of that helps. If you can give an example of the kind of game you're trying to make I can give a more tailored suggestion. :)
I am making a FPS game. It's almost done, and i am very proud to say that it looks awesome! Currently i am making some scenarios for the players to play with their friends, and one of these scenarios is in night time.
The real problem here is that i need to render a medium size "sphere" that is in the sky. It is supposed to work as a parachute. As the time passes, the parachute's ropes will be cut and then the parachute is going to fall and give the first player to reach it a special gun.
But the distance between the sphere and the ground are very very near, so i wanted to make it stay far away from the player (at least 250 meters) so anyone could see it in the sky. But if i do this, the player will not be able to see it because i've limited it's rendering distance for performance purposes.
This was a beautiful explanation, thanks for taking the time to explain this! ^_^
Answer by DarkGate · May 06, 2019 at 05:28 PM
Yes, it is possible. Heres how you can do it. Set up two cameras A and B, where B is a child of A. (Note, make sure that you reset the transform of Camera B so they are looking at exactly the same location).
Camera A: near: 0.1, far: 300, clear flag: "Depth Only"
Camera B: near: 300, far: 3000, clear flag: "Skybox" or "Solid Color"
Let us assume you have an Object A that you want to view far away.
Create a layer called Infinite Range
Assign Object A to Infinite Range
Set Camera B's Culling Mask to Infinite Range
You should be able to see far away objects (such as mountains or whatever). Cheers!
Hi,
i'm beginner with Unity and i've setup your solution to achieve a project i'm starting (https://forum.unity.com/threads/perspective-cinematics.1052771)
The objects become transparents as soon as i add them to the Infinite Range layer. After that i cannot see them with the camera. Do you have some idea what could go wrong ?
Answer by Lilius · Oct 14, 2016 at 06:30 AM
I would do it the other way around. Set far clipping plane far away, 3000 units maybe or whatever distance you need. Then cull all the other objects at the distance you don't want to see them. For example you don't need to see a tiny screw from 20 meters away, but you might want to see a mountain 3 km away or a house 1 km away. I also use this to hide interiors from 50 meters away in one game, because I don't have bigger interior areas and if I'm 50 meters away from house there is always something in between so I wouldn't see the interior anyways. Kind of lazy mans substitute for occlusion culling in that case.
Setup is quite simple, you just need to add some layers to your objects and a little script to your camera: https://docs.unity3d.com/ScriptReference/Camera-layerCullDistances.html
Answer by mblt97976 · Jan 04 at 04:35 PM
To see massive objects from massive distances, just follow what Darkgate answered and set the far clipping plane on camera B to the highest number it can go 3.402823e+38, (3 followed by 38 digits) and remove the audio listener on camera B to prevent warning error on console
Your answer
Follow this Question
Related Questions
Why when changing the doors colors it's not changing anything ? 1 Answer
Only render part of object inside a circle 2 Answers
Hdrp [Render Scale] 0 Answers
I can't render a texture from the resources folder 2 Answers
How can I add a MeshRenderer component with all properties to a GameObject by script ? 1 Answer