aggressive scissor for shadow volumes

Originally posted by PH:
Is it really worth the trouble to build connected loops while extracting the silhouette ? Or put another way, is anyone actually doing this and can confirm whether this is a definite win ?

Paul,

No hard evidence on this. It is mostly a function of how individual architectures make efficient use of bandwidth. Coherence of updates can have a significant impact on the overall fill efficiency.

Thanks -
Cass

I just noticed something in the code for this demo. This function here:

vec4f compute_homogeneous_plane(vec4f a, vec4f b, vec4f c)
{
vec4f v, t;

if(a[3] == 0)
{ t = a; a = b; b = c; c = t; }
if(a[3] == 0)
{ t = a; a = b; b = c; c = t; }

// can't handle 3 infinite points
if( a[3] == 0 )
    return v;

vec3f vb = homogeneous_difference(a, b);
vec3f vc = homogeneous_difference(a, c);

vec3f n = vb.cross(vc);
n.normalize();

v[0] = n[0];
v[1] = n[1];
v[2] = n[2];

v[3] = - n.dot(vec3f(a.v)) / a[3] ;

return v;

}

has some typos. First there is two exact copies of code one after another. This code here:

if(a[3] == 0)
{ t = a; a = b; b = c; c = t; }
if(a[3] == 0)
{ t = a; a = b; b = c; c = t; }

Also right after that it does this:

// can’t handle 3 infinite points
if( a[3] == 0 )
return v;

Well that check there does not check if there were 3 points that are infinite, it only checks two. First it checks if a is an infinite point, then the points get moved over so a now becomes b. Then that code snippet above checks for an infinite point which now is a but used to be b. The third point never get’s checked so this function only checks for two not three infinite points. Here is this function modified by me that is all fixed up.

vec4f compute_homogeneous_plane(vec4f a, vec4f b, vec4f c)
{
vec4f v;

// can't handle 3 infinite points
if( a[3] == 0 && b[3] == 0 && c[3] == 0 )
    return v;

vec3f vb = homogeneous_difference(a, b);
vec3f vc = homogeneous_difference(a, c);

vec3f n = vb.cross(vc);
n.normalize();

v[0] = n[0];
v[1] = n[1];
v[2] = n[2];

v[3] = - n.dot(vec3f(a.v)) / a[3] ;

return v;
}

Alright there ya go, glad to help.

-SirKnight

SirKnight,

Hmm. I’m not seeing the bug.

What I intend(ed) to do was rotate
the vertices until a.w was nonzero.

If after two rotations a.w was still
zero, then I would have checked all 3 points.

Maybe I’m missing something?

Thanks -
Cass

Oh wait I’m sorry cass I see what was going on now. I just saw two pieces of identical code and thought it was not needed. Ok ya I look at it again and see what you mean. Gosh I feel dumb.

-SirKnight

Ok I just thought of a way that would still allow 2 infinite points at most that (unlike the code I posted) and would do away with those 9 moves and 3 comparisons.

vec4f compute_homogeneous_plane(vec4f a, vec4f b, vec4f c)
{
vec4f v;

// can't handle 3 infinite points
if( !( a[3] + b[3] + c[3] ) )
    return v;

vec3f vb = homogeneous_difference(a, b);
vec3f vc = homogeneous_difference(a, c);

vec3f n = vb.cross(vc);
n.normalize();

v[0] = n[0];
v[1] = n[1];
v[2] = n[2];

v[3] = - n.dot(vec3f(a.v)) / a[3] ;

return v;
}

I hope this is better.

-SirKnight

Better, but homogeneous_difference() doesn’t really like two infinite points, so you need to make sure that if two points are infinite that “a” is the non-infinite point.

Details, details…

Thanks -
Cass

ARG, that dang homogeneous_difference function. Ya I see that would be bad if there are two infinite points and ‘a’ is one of them. Alright back to the drawing board.

-SirKnight

  1. It doesn’t look like Doom3 uses scissor per object but per light.
    Or what’s an object in a static gameworld?
  2. I don’t think that the portal culling stuff for shadow volumes is that simple than it looks.
    Some more information would be nice.
    For example you can use a portal’s scissor rect if the boundingbox of an object is outside the convex hull of the portal and the light, if you look through this portal, so the shadow volume stays in the areas behind the portal.
    I think there must be more things like this.
  3. The “Optimized Stencil Shadow Volumes” presentation was great!

[This message has been edited by Liquid (edited 04-24-2003).]

Originally posted by Liquid:
[b]1. It doesn’t look like Doom3 uses scissor per object but per light.
Or what’s an object in a static gameworld?
2. I don’t think that the portal culling stuff for shadow volumes is that simple than it looks.
Some more information would be nice.
For example you can use a portal’s scissor rect if the boundingbox of an object is outside the convex hull of the portal and the light, if you look through this portal, so the shadow volume stays in the areas behind the portal.
I think there must be more things like this.
3. The “Optimized Stencil Shadow Volumes” presentation was great!

[This message has been edited by Liquid (edited 04-24-2003).][/b]

  1. That’s true of the leaked version of Doom3 from a long time ago, but then nobody (that I’m aware of) was doing per-object scissor as a shadow volume optimization back then.

  2. I agree, some examples of of portal culling would have been helpful.

  3. Thanks!

Cass