Sign in to follow this  
MickeyMouse

Disable near and far clipping (HLSL)

Recommended Posts

Hi everyone, I'm rendering a bounding sphere of a light to stencil buffer in order to speed up further expensive lighting pixel shader and I need a way to ignore near and far clipping planes when doing it - otherwise I won't stencil mark all required pixels. Is there any simple way to do it from HLSL? Thanks.

Share this post


Link to post
Share on other sites
What API are you using?

In DirectX9, you would use SetRenderState() and set the D3DRS_CLIPPING render state to false to disable clipping.

Share this post


Link to post
Share on other sites
Thanks,

Having thought of this for some time, I've just came to a different solution which will allow me for much better pixel shader bandwidth optimization - using stencil increase and decrease operation (like with shadow volumes) to mask out light area.

Share this post


Link to post
Share on other sites
Instead of a bounding sphere, I'd recommend finding a square that encompasses the light area in screenspace (like a billboard) and stencil, heck, even scissor, against that.

Share this post


Link to post
Share on other sites
Not all GPUs are capable of disabling clipping. I think that state is really for the software pipeline.

For instance, nvidia GPU's can't disable clipping.

Share this post


Link to post
Share on other sites
Quote:
Original post by Cypher19
Instead of a bounding sphere, I'd recommend finding a square that encompasses the light area in screenspace (like a billboard) and stencil, heck, even scissor, against that.


I'm using scissor test too.

But hence that rendering bounding sphere to stencil buffer using incr-decr schema will determine only the pixels within light's "radius". It's quite common that the scissor rectangle takes half a screen, while stencil test leaves only a few pixels - this is because bounding sphere clips along Z coordinate too.

Share this post


Link to post
Share on other sites
Quote:
Original post by Code-R
forgive me for my ignorance, but how is this better than standard per vertes is-out-of-range check?


When you do per-vertex (geometry) clipping, you can avoid rendering few triangles. But when you do per-pixel stencil clipping, you can clip single pixels. Only these pixels will be drawn to color buffer in consecutive rendering pass - in my case it uses an expensive pixel shader.

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