2
\$\begingroup\$

I don't know where the impression came from, but somehow it got in my head that having too small a "near" and too large a "far" in your projection at the same time would impact performance. In general that seems to hold true if there are many objects in your world like a crowded city where distant things are more likely not to be drawn because they're obstructed by closer objects. But what about fewer objects that don't obstruct each other?

I'm working out a game idea that has an "eye in the sky" camera that is expected to see a large portion of terrain kind of like an RTS (actually the camera is attached to a drone flying at altitude). I tried bringing my camera closer to the terrain and trying to make it behave like it's 50k ft in the air but nothing quite beat the feel of actually putting the camera very far away from the ground and using the field of view to zoom in and out. To make this work, I had to increase my Far plane by an extra order of magnitude.

All objects are on or near the ground in a relatively tight Y range compared to how far my camera is. I'm not drawing an obscene amount of things (at least not yet, it's still early in development) and very few objects are completely obscured by larger/closer objects. Is the large render distance of my camera going to be an issue or have side effects as I progress through development? Or should I re-approach the idea of bringing my camera closer to the world and having it simulate a larger distance (and how exactly would I do that)?

I'm using Unity 5, but I imagine my question won't be too specific to a framework.

\$\endgroup\$
4
  • \$\begingroup\$ Main reason for setting znear and zfar as close as possible is you will be losing precision otherwise (z-fighting). Ofcourse if there are much more rendered objects the performance will suffer too. \$\endgroup\$
    – wondra
    Commented Oct 21, 2015 at 16:53
  • \$\begingroup\$ If I understand correctly, I should be able to move my zNear closer to my zFar since there is nothing to render between my camera and things near the ground. That should help fight z-fighting right? \$\endgroup\$ Commented Oct 21, 2015 at 17:24
  • \$\begingroup\$ Well, I am not expert on on floats arithmetics, but basically yes. To be precise, the matter is more complicated: the inputs are usally maped to -1,+1 range for GPU, it is also the range where float is most precise - if you have objects far away (100k+) you might see precision issues too because of being in not-so precise range of float. Thats why you usually see something like 0.1 to 100.0 for znear/far to keep everything in reasonable range. \$\endgroup\$
    – wondra
    Commented Oct 21, 2015 at 17:37
  • \$\begingroup\$ That should help fight z-fighting right? Yes. What matters is the ratio between near and far, not their absolute values. \$\endgroup\$
    – jhocking
    Commented Oct 27, 2015 at 16:15

1 Answer 1

2
\$\begingroup\$

The issues surrounding depth range (the difference between your far plane and near plane) have more to do with precision than performance. The larger the range, the more precision you lose at the far extents using the usual non-linear depth mapping.

Performance isn't really impacted all that much, to the point where it's generally not a concern. (When you have a large viewable distance and lots of objects you generally want to be using culling methods that are earlier in the pipeline than the GPU's far-plane-based exclusion; by the time objects get that far they'll already have eaten up a ton of processing time.)

\$\endgroup\$
2
  • \$\begingroup\$ To piggyback on this correct response, if you need to move your far clipping plane further out, you should also move your near clipping plane further out. If your camera is up in the sky then nothing will come close to the camera anyway. \$\endgroup\$
    – jhocking
    Commented Oct 27, 2015 at 16:13
  • \$\begingroup\$ Coincidentally, just today someone asked about this on the Unity forum forum.unity3d.com/threads/… \$\endgroup\$
    – jhocking
    Commented Oct 27, 2015 at 16:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .