- Home /
Large scales, increased clipping planes, and performance
The standard clipping planes on the camera are 0.3 and 1000, near and far. I'm experimenting with parallax vs real perspective movement in a space game.
In my 2D game 1 Unity unit/meter is 10 real world units, but I want to get nearby planets and backgrounds to move appropriately in the background as the player moves in X and Y.
One thing I'm trying is using a perspective camera and putting a sprite of a planet WAAY into the background and enlarging its scale. Scale = 50 and Z distance is 9000 currently. This is giving me a 10km diameter planet (.063% Earth-size approx) 90km away, according to my game's own relative scale. That size is workable for a game, but I wonder about having something bigger further in the background.
To do just this little I had to set the camera far clipping planes to 10,000 instead of 1,000. I'd like to go even x10 bigger than this again, so x100 times normal clipping distances, scales, and game distances.
Will those kind of numbers be doing terrible things to the performance I'm wondering, or is a couple of extra zeros no big deal to the engine? Worth noting that there's no physics or colliders on the enlarged planets.
don't forget that the distance of your near-clip plane to the camera is a huge factor in the precision of your z-buffer. it's extremely non-linear. if you start to see "$$anonymous$$ring", where two polygons that are close together in distance seem to be "fighting" for which one is in front, try increasing your near clip-plane. generally you want your near clip to be as far away as possible without bumping into geometry.
Answer by _Yash_ · May 16, 2016 at 11:40 AM
If increasing far clip plane is not adding new objects in view than it is not changing performance. But in the other case if increasing far clip plane adds a new object in the scene it will affect the performance. The camera uses Occlusion culling which allows the engine to discard anything far away from far clipping plane. It is an optimization technique used for very large maps. In your case, I guess there is no change in the number of objects being drawn when you increase the far clip plane hence no change in performance.
Thank you. Yes the only new objects are a planet or two that I put right in the background, and they're just large sprites. Do you know if the scale would cause problems? Like 5000 in the x and y?
No scale would not cause any problem. But it can be serious problem if any how it is being used as physics object (has rigidbody) because physics calculates everything in 1 meter = 1 unity scale.
also consider what @elenzil said, it can be solved by keeping near clip plan as far as possible.
Your answer
Follow this Question
Related Questions
Unrealistic size of sun, viewed from earth 2 Answers
Camera position 1 Answer
Auto Scale camera depending on Screen Size - How?? 3 Answers
Show squares in the camera 0 Answers
Multiple cameras, foreground strangely obscured, clip distance 0 Answers