Disable near and far clipping (HLSL)

Started by
6 comments, last by MickeyMouse 18 years, 9 months ago
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.
Maciej Sawitus
my blog | my games
Advertisement
What API are you using?

In DirectX9, you would use SetRenderState() and set the D3DRS_CLIPPING render state to false to disable clipping.
-Scoot
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.
Maciej Sawitus
my blog | my games
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.
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.

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.
Maciej Sawitus
my blog | my games
forgive me for my ignorance, but how is this better than standard per vertes is-out-of-range check?
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.
Maciej Sawitus
my blog | my games

This topic is closed to new replies.

Advertisement