Sign in to follow this  
frca

Disabling far plane

Recommended Posts

frca    147
Is it somehow possible to disable the far plane? I didn't discovered it yet. I want to render every frame first very far WITHOUT depth test and then between far plane (which is quite close to the camera for optimal z-testing) and near plane WITH depth test. I'm searching for some optimal solution. Thank you, typek

Share this post


Link to post
Share on other sites
_DarkWIng_    602
Quote:
Original post by typek
Is it somehow possible to disable the far plane?

No. You can push it very far away at the cost of z-buffer resolution or you can use some wierd custom projection.
If you tell us what you are trying to do someone might know alternative way.

Share this post


Link to post
Share on other sites
mikeman    2942
NV_DEPTH_CLAMP extension allows you to disable clipping against the near and far planes. Instead of clipping geometry, the depth values are just clamped to the depth range. Unfortunately, it works only for NVidia.

Also, read here(Under the "View Frustum Clipping – The Ultimate Evil" paragraph) for a way to project the far plane into infinity.

Now, for your case IMO the best way is to:

1)Push the far plane just very far away,as far as your most distant object is. Since you don't want to use depth testing, depth precision doesn't matter.
2)Disable depth testing&writing
3)Render whatever you want
4)Setup the perspective normally now
5)Enable depth operations
6)Render the normal geometry

Share this post


Link to post
Share on other sites
Optus    422
Infinite Far Plane Perspective matrix calculation:
Note, source language is Java.

float fovy = 45f;
float aspect = ((float) AppContext.WIDTH)/((float)AppContext.HEIGHT);
float n = 1f; //Near Clip Value
float[] entries = new float[16];
float left, right, top, bottom;
float nudge=0.999f; //prevent artifacts with infinite far plane

//convert fov from degrees to radians
fovy*=(float)Math.PI/180;

top=n*(float)Math.tan(fovy/2.0f);
bottom=-top;

left=aspect*bottom;
right=aspect*top;

entries[0]=(2*n)/(right-left);
entries[5]=(2*n)/(top-bottom);
entries[8]=(right+left)/(right-left);
entries[9]=(top+bottom)/(top-bottom);
entries[10]=-nudge;
entries[11]=-1;
entries[14]=-2*n*nudge;

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this