The w coordinate

Ok, this might show that I don’t get it

If the eye is inside the shadow volume, would that mean the the rendered volume would be behind you and hence not shadow anything?

Using w = -1 represent a fixed point that would project to the same point as w = 1 but directional lights have no position, only direction. So you wouldn’t be able to specify a directional light in the first place. Is this correct ?

Edit: That would mean that the vertices that are to be projected ( silhouette ) cannot be specified for directional lights, as they are specified as directions.

[This message has been edited by PH (edited 02-05-2003).]

PH, you don’t just set w=-1 instead of that you negate all the components. Take the demo, set blue vertex w coordinate to 0 and press ‘b’.

What demo ? Blue vertex ?

Look at the homepage of this site. In the news there is a title about understanding the w coordinate. Clicking on it takes you to the NVIDIA site where you can download the demo.

  • Halcyon

With this approach, a triangle is drawn from the two points with positive w, away to infinity. The triangle is drawn to infinity on the side of (0, 0, 0, 0) where the triangle crosses w=0.
For example, if the x-coordinates on the line where the triangle intersects the plane w=0 are all negative, the triangle will be drawn with the “infinite part” to the left of the line between the other 2 vertices in the window.

For the shadow volumes:

Imagine the light source lies on an edge which you wish to project. With the original infinite shadow volumes approach, this would produce a single (infinitely long) line due to all 4 points of the “extruded edge quad” being colinear.

With this approach however, one side of the line (in window coordinates) is filled, but we do not know which side this will be, as the triangle passes through w=0 at exactly (0, 0, 0, 0).

Cass’ app confirms this. If the situation is set up so that a triangle passes through (0, 0, 0, 0), one side or the other is drawn arbitrarily.

Is this right?

PH, I simplified the code snippets above by assuming that all W’s were 1. If you don’t make this assumption, then the regular case becomes:

glVertex4f(Bx, By, Bz, Bw);
glVertex4f(Ax, Ay, Az, Aw);
glVertex4f(Ax*Lw - Lx*Aw, Ay*Lw - Ly*Aw, Az*Lw - Lz*Aw, 0);
glVertex4f(Bx*Lw - Lx*Bw, By*Lw - Ly*Bw, Bz*Lw - Lz*Bw, 0);

Using external triangles, you’d change the last two vertices to:

glVertex4f(-Lx, -Ly, -Lz, -Lw);

For a directional light, Lw = 0. If you assume that your vertices all have W=1 and your light either has W=1 or W=0, then substituting Lw=0 into the two code snippets above will show that they end up exactly the same. Hence, directional lights should work fine.

What happens, however, if not all vertices have W=1, or if Lw is neither 0 nor 1? Are the two approaches still equivalent in that case? I’m not sure, but I am sure that my head hurts now

– Tom

P.S.: The demo is here: http://developer.nvidia.com/view.asp?IO=understanding_w

Originally posted by Tom Nuydens:

For a directional light, Lw = 0. If you assume that your vertices all have W=1 and your light either has W=1 or W=0, then substituting Lw=0 into the two code snippets above will show that they end up exactly the same. Hence, directional lights should work fine.

Ah ok. Well, I’m not 100% clear on all of this yet.

You’re getting colder.

Hint: water-tight rasterization

This is fun.

Cass

Ok, this is totally a very randomn guess. I’m just starting to understand the w-coordinate and i can’t apply it to explain my guess.

Anyways, along the lines of what castano said…Is the w-coordinate going to create a t-junc and create cracks in the rendering of the shadow? Or maybe it’s if you use it on higher order curves? Ok the reason i’m spitting this out is because I’m reading the article on NVIDIA’s site about the GF3 architecture. There was a part where they were talking about higher order surfaces and they mentioned Water-tight Tesselation and had a bullet under it saying that you would get crack free rendering.

So, don’t ask me to explain myself…because i can’t .

  • Halcyon

Edit: Cass, I was just looking over some of the articles you wrote for NVIDIA. I have one thing to say: … … … … WOW!!! They are really good and informative but not like a billion pages long with size 8 font! Can I ask you how you learnt all the stuff you have up there? I’m just getting into lighting and what not with OpenGL…and I am obviously a beginner!

[This message has been edited by HalcyonBlaze (edited 02-05-2003).]

Originally posted by castano:
PH, you don’t just set w=-1 instead of that you negate all the components. Take the demo, set blue vertex w coordinate to 0 and press ‘b’.

Yes, you’re right. I simply had w = -1 and thought that was it. I modified Cass’ shadow volume demo and indeed both local and infinite lights work.

I’m completely blank.

Cass, next hint ?

With ‘watertight rasterization’ he means: “no double hitting of pixels or missed pixels along shared edges of rasterized triangles”

However, I don’t know for sure how the rasterization rules work in this case…

Originally posted by cass:

Hint: water-tight rasterization

I think it is related to the nudge with infinite far plane. Your demo produces artifacts when using a nudge != 1. This nudge = 1 - 1.0 / (1<<23) never seems to work on Radeons ( I use 0.995 normally ). Infinite lights seem to work with the nudge…

Ok, several people have hit on the key point. The problem is a T-junction cracking problem at infinity. External triangles pass through infinity rather than stopping at infinity, so it’s not possible to render the infinite caps without T-junctions along the silhouette.

Still this does not answer the question:
When can’t you use this approach?

Or, if you prefer:
When can you use this approach?

We’ve identified the problem, but what we really need to know is when it is and isn’t safe to use this technique.

Thanks -
Cass

Edit: Cass, I was just looking over some of the articles you wrote for NVIDIA. I have one thing to say: … … … … WOW!!! They are really good and informative but not like a billion pages long with size 8 font! Can I ask you how you learnt all the stuff you have up there? I’m just getting into lighting and what not with OpenGL…and I am obviously a beginner!
[/b]

Thanks, Halcyon. I’ve had lots of good “teachers” at NVIDIA. There is information everywhere, and all the important topics show up in various forms over and over. Eventually the fundamentals sink in, and all we’re left with is homoegeneous coordinates to keep us feeling like newbies.

Cass

Well, it should be safe to use with the zpass approach ( with the “infinite” far plane ) but that answer almost seems too obvious.

Edit: I see Tom already mentioned this…

[This message has been edited by PH (edited 02-05-2003).]

You can use this approach when your inside a shadow-volume, because then you don’t have to render the caps but could use the z-pass method.
Am I right?

You can use this approach when you don’t need to cap the shadow volumes, that is:

  • directional lights. (dummy answer)
  • the shadow volume doesn’t intersect the near plane.
  • the caps are outside the view frustum.

Anyway, that was obvious, so I suppose you are talking about something else, right?

I’m not sure I see why T-juctions are generated. From the shadow volumes demo, it almost seems like the cracks go away as the nugde value approaches 1.0. If that is the case, wouldn’t NV_depth_clamp make this approach possible all the time ?

Castano gets the gold star.

You can use this approach anytime you don’t need to render infinite cap. Since zpass rendering doesn’t require caps, that’s the important case when you know you can use it.

Paul (PH),

For infinite shadow volumes, you have vertexes at infinity - both to extrude to and to cap with. With the external triangle approach, you extrude through not to infinity, so your infinite caps don’t have actual vertexes to seam up with. It’s the same problem as trying to cap an object that intersects the near plane.

Good job, all.

Thanks -
Cass