PDA

View Full Version : Finding stencil buffer dirty rectangles?



GameMaker
09-02-2003, 08:39 AM
After writing to the stencil buffer, I want to find the smallest rectangle that covers the stenciled area so that I can draw the capping texture. Does anyone know a fast way to find the min and max x and y where it wrote to the stencil buffer? In other words, the dirty rectangle in the stencil buffer?

Currently, I have to draw my capping texture across the full screen, which is very slow.

Thanks in advance!

I am using a GeForce4 if that matters.

CatAtWork
09-02-2003, 09:55 AM
I don't think you can do this with arbitrary writes. You have to know more information, such as the attenuation distance for lights. You find an OBB that encloses your light's sphere of influence, and project that box into window coordinates.

GameMaker
09-02-2003, 11:01 AM
Thanks for the reply.

Ya, I was thinking of doing it that way, but that will only give me a rough estimate of the rectangle and not the exact dirty stenciled area.

I am going to implement this method and see if the framerate improves though. It should be somewhat faster.

Since I would now have a rough estimate of the dirty rectangle, would it be a good idea to try and read the stencil buffer within that rectangle to find the exact rectangle before drawing the capping texture? Or would that be incredibly slow?

CatAtWork
09-02-2003, 11:20 AM
I think that the small decrease in fill will be FAR outweighed by the ReadPixels expense.