How to disable near (and far) clipping
In Virtual Reality you almost never want near clipping. But putting the near clipping plane too close wastes most of the depth buffer resolution.
Here is a simple solution that disables near and far clipping so everything is still rendered regardless of distance. The disadvantage is that when two things are both closer than the near clipping plane the wrong one may occlude the other one. But it is still almost always better than near clipping.
In OpenGL 3 and above, just add this at the start:
This site explains it well:
http://www.arcsynthesis.org/gltut/Positioning/Tut05%20Depth%20Clamping.html
(except when it says at the end "but that only gets us to exactly where we started" it means only for things in front of the near clipping plane... ie. it is a lot better than where they started overall)
A more complicated solution is to use the depth buffer differently, like this:
http://outerra.blogspot.com.au/2012/11/maximizing-depth-buffer-range-and.html
Here is a simple solution that disables near and far clipping so everything is still rendered regardless of distance. The disadvantage is that when two things are both closer than the near clipping plane the wrong one may occlude the other one. But it is still almost always better than near clipping.
In OpenGL 3 and above, just add this at the start:
glEnable(GL_DEPTH_CLAMP);In Direct3D 10 and above, set DepthClipEnable to false in the rasterizer state, for example:
D3D11_RASTERIZER_DESC rs;
memset(&rs, 0, sizeof(rs));
rs.AntialiasedLineEnable = true;
rs.CullMode = D3D11_CULL_BACK;
rs.DepthClipEnable = false;
rs.FillMode = D3D11_FILL_SOLID;
Rasterizer = NULL;
Device->CreateRasterizerState(&rs, &Rasterizer.GetRawRef());
This site explains it well:
http://www.arcsynthesis.org/gltut/Positioning/Tut05%20Depth%20Clamping.html
(except when it says at the end "but that only gets us to exactly where we started" it means only for things in front of the near clipping plane... ie. it is a lot better than where they started overall)
A more complicated solution is to use the depth buffer differently, like this:
http://outerra.blogspot.com.au/2012/11/maximizing-depth-buffer-range-and.html
