Are you talking about how you’d do triangle-frustum clipping so that you can generate these statistics yourself?
If so google homogenous clipping. If you need some pointers, let me know and I can dig some up. Clipping happens in “clip space” (intuitively), so you might read up on that:
> Are you talking about how you’d do triangle-frustum clipping so that you can generate these statistics yourself?
Yes, i was talking about the same.
> If you need some pointers, let me know and I can dig some up.
Oh, please, that would be great! What i basically wanted to know is, once you pass all your vertex data to shaders, how do these tools obtain these information? Now we can find if a single point lies within the clip space. How can i find if a triangle is within the clip space? The primitive assembly would be done after this stage right?
I imagine that the GPU stores information in its registers and the tool simply communicates with the driver and the driver gets the values from the GPU. Pretty much any GPU should have that kind of ability.
Main thing is you want to clip in 4D homogenous coordinates (i.e. before the perspective divide) so you don’t have nasty issues with divide by zero singularities and such. Jim Blinn’s got some good stuff on this.
For instance, clip to 3D planes defined in 4D. Using Blinn’s convention of upper-case letters for 3D affine coords and lower-case letters for homogeneous coordinates), we start with the basic 3D plane equation:
AX + BY + C*Z + D = 0
Now we plug in homogenous coordinates:
A*(x/w) + B*(y/w) + C*(z/w) + D = 0
aka Ax + By + Cz + Dw = 0
So if we take the std 3D plane equation coefficients and multiply (dot product) by a homogenous 4D point, we’ve actually evaluated the plane equation just as we did in 3D by plugging in for X,Y,Z.
Then you’ll probably want an “intersect line against plane” function that operates in 4D too to intersect against these 4D planes. Calls to this function are driven by the polygon clipping algorithm you choose to implement. At the time I used Sutherland-Hodgman (for just doing this all in software; Foley and van Daam has a decent writeup on this), but there’s nothing holy about that. You can choose another.