3
votes

I have a terrain mesh generated in 3ds Max that is of size 10k by 10k. My problem is that far clipping is just to close and I can not see as far as I would like to. I am trying to implement a fog shader and what i see now is just not OK.

My camera constructor looks like this

Camera::Camera():
    cameraPosition_(glm::vec3(-1.0f, 1000.0f, 20.0f)),
    cameraLook_(glm::vec3(0.0f, 800.0f, 200.0f)),
    lookAt_(glm::lookAt(cameraPosition_,
                        cameraLook_,
                        WORLD_YAXIS)),
    near_(0.1f),
    far_(10000.0f),

    projection_(glm::perspective(
        70.0f,
        4.0f / 3.0f,
        near_,
        far_)),
    name_("Default Camera") 
{
}

and the result looks like this enter image description here

1
1) try to check 3ds max export units must be units not mm, sm, or m 2) try to disable polygon culling for terrain mesh (may be some issues with polygon orientation after exporting) .Mykola
You can try to normalize your mesh. Make it in box from 0 to 1Unick
Z-buffer limitation came from z_far/z_near ratio. Try near_(10f). See: gamedev.net/topic/173562-max-far-clip-plane-distanceOrace
Yes the issue was near near plane. I did set near to 1.0f and now it is working as it should. Thank you a lot guys.Lum Zhaveli
if you need bigger range for depth you can stack up more frustrums on top of each other something like this realistic n-body solar system simulation where I render from 0.1m up to 1000 AU also instead of FOG I use atmospheric scattering there.Spektre

1 Answers

1
votes

Real cameras don't have near and far clipping planes. Virtual camera need them because of numerical precision issues. It's tempting to set the near and far plane to extreme values to emulate a real camera, but that defeats the object. The smaller the range between the planes, the fewer artifacts you will get, and they should be set to just slightly outside the the range of the the actual objects.

(If you do need both aircraft in the sky and bugs on a leaf in the same shot, fake it by drawing twice with different camera settings).