Carmack's reversed vs unreversed

im now writing the shadow algorithm, and while i think i understand the different methods, im still a bit confused after reading a few posts here on board.
so tell me if thats right -
Carmacks reversed doesnt need near capping, but must have closed volumes. and if my volumes are extended outside the light? should i still use closed volumes?
The unreveresd method needs near capping, but uses open volumes, i.e i should only extend sil edges, right?


Yes Carmack’s Reverse uses closed volumes. As far as I know, they always have to be closed. And you don’t need any capping. So they are relatively simple to use. The only thing you need to pay attention to is that the shadow volumes don’t intersect the far clipping plane but this shouldn’t be too hard when you use attenuated lights. I’m using Carmack’s Reverse in my engine and it is working perfectly. I have looked into several other shadowing methods but this one is the most simple and at the same time most powerful one I have found.


Agree. And using the MAC Algo I explained in another thread to close the far plane provides a robust implementation.

Yes unreversed algorithm works with opened volumes, and yes you only need to extend the edges. Also, you have to cap on the near clipping plane.

what is the difference from closed volumes and
open volumes???

[This message has been edited by jeppa (edited 02-05-2002).]

closed volumes are volumes which need to be, huh, closed. Eg each segment of a polygon has a neighbour polygon.

opened volumes are volumes which can contain holes.

For instance, a cube is a closed volume.
If you remove one of its faces (at least), it becomes an opened volume.

Carmack’s reversed algorithm does not work with opened volumes, afaik.

It is a bit of a myth to say that traditional volumes require no far capping. Typically they should extend far enough to intersect potentially illuminated scene geometry. They WILL cast a false shadow on stuff in the uncapped region if it covers any potentially illuminated geometry as viewed from the eye position.

SOrry for my error(what->which).in my engine i use the method described on Nvidia doc(silhouette) .which are the method to make the
closed volumes???


For silhouettes :
1- determine which polygons are facing light, and which not
2- for each polygon facing the light, every neighbour which is a polygon NOT facing the light means that the segment between the 2 polygons (the polygon facing light, and the neighbour polygon) has to be extended : draw a quad between the “neighbour” segment and the “extended” segment.

For closed volumes, you have to add the volume itself :
1- idem
2- idem
3- for each polygon facing the light, draw the polygon.
4- for each polygon NOT facing the light, draw the “extended” polygon, eg the polygon where all its vertices have been extended like the segment was extended in step 2.

hope this helps

many thanks for your help

If you’re generating the volumes in a vertex shader, by using the cheesy hack of extending vertices with away-facing normals away from the light, couldn’t you also use the “min” function to pull the Z component of any transformed vert in hin of the yonder clipping plane? If you compensate a bit for Z buffer resolution and the potential for radial Z buffer, you may get some artifacts where a shadow isn’t long enough towards the end of the visible frustum, but that wouldn’t be too bad I would think. (Or you’d just pull ALL geometry in to that point, or hide it in fog, or something :slight_smile:

should the volumes be closed on both sides?
if yes, i dont see why. if the viewer doesnt see the ends of the volume, then its like they do not exist, and the shadow should still appear, you see what i mean?

volumes have to be closed on both sides because in one pass the “front” sides will be displayed and in the other pass the “back” sides will be displayed.
If you skip some of them, the volume will not be closed and the stencil will be incremented and decremented with a wrong balance.

are you sure? if thats true, then i have a problem.


It’s always possible to create a closed volume. Imagine a single triangle - if you use the method shown by vincoof then there won’t be any backfacing triangles ( and therefore the shadow volume with not be closed ). To get around this, use the triangles that are front facing wrt. the light, reverse the winding and extrude. The front facing, the extruded faces and the silhouette faces together make up the closed volume ( this method works for all types of geometry ).

ok, but my problem is with my data structure, anyway ill find a way to get it done. one more thing, in order for backface culling to work the winding for all sil edges should be the same, but if i have a complex model, how can i be sure it is so? beacause it isnt, unless you sort it some how.

All the triangles in your meshes have the same winding ( either CW or CCW for front faces ). So all the extracted silhouette edges are directed. If the extracted edge is AB ( from A to B, this infomation comes from the triangle of which the edge belongs ) and the extended edge is A’B’, then the silhouette quad is BAA’B’ for CCW. Personally, I create two triangles from the quads.

[This message has been edited by PH (edited 02-08-2002).]

Hmm, in Carmacks reverse dont you always have to close the volume?

If you use the near plane capping method then you only have to make the cap when the near plane intersects the volumes?

Is that right?

And also, doesnt that MAC algorithm eat a lot of fill rate? I guess it wouldnt matter if your game is not fill rate.

i wish all the triangles in a mesh would have the same winding. but it isnt, what i do now, is going over the sil edges, and sort them, so they will create a loop.

Can you clip your volumes to a box (closing them at the sides of the box) and still get the right result or do they have to have a trapezoid shape (It should work but I want to be shure before implementing box/volume clipping)
(Supposing the box extends further than your visible geometry of course)