stencil volume shadows

  • Permalink
  • submit to reddit
  • Email
  • Follow


hi,

Im trying to implement shadowvolume rendering for
multiple objects, but I dont really see the light yet.
Here's a picture of the result, the code is below.
The even and odd parts in the stencil seem to be
cancelling out but I fail to see how that is.
http://www.xs4all.nl/~vdspek/shadowvolumes.jpg
The lower bunch of spheres only show the volumes.
The volumes are capped on both sides and the quads
that make up their surfaces have ccw winding, seen from outside.

Im using the algorithm from shadowvol.c at the opengl site:
http://www.opengl.org/developers/code/glut_examples/advanced/advanced.html
which utilises the 'carmack method', see:
http://developer.nvidia.com/docs/IO/2585/ATT/CarmackOnShadowVolumes.txt
and also implemented the slightly different nvidia method,
with the same result. Could anyone shed some light on this ?
Im really in the dark here  :-D

thanks,

Jonathan

----------------------------------------------------------------------

    glClear( GL_COLOR_BUFFER_BIT | \
                 GL_DEPTH_BUFFER_BIT | \
                 GL_STENCIL_BUFFER_BIT );

    glEnable(GL_CULL_FACE);
    glCullFace(GL_BACK);
    glEnable( GL_DEPTH_TEST );
    glColorMask(GL_FALSE, GL_FALSE, \
                         GL_FALSE, GL_FALSE);
    glDepthMask(GL_TRUE);

    // only depth
    DrawSpheres( );

    glEnable(GL_STENCIL_TEST);
    glDepthMask(GL_FALSE);

    glStencilFunc(GL_ALWAYS, 0, 0);
    glStencilOp(GL_KEEP, GL_KEEP, GL_INCR);
    glCullFace(GL_BACK);  // increment using front face of shadow volume

    DrawVolumes();

    // m�thode Carmaque: decrement for clipped faces
    glStencilOp(GL_KEEP, GL_KEEP, GL_DECR);
    glCullFace(GL_FRONT);  // decrement using back face of shadow volume

    DrawVolumes();

    glDepthMask(GL_TRUE);
    glDepthFunc(GL_LEQUAL);
    glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
    glCullFace(GL_BACK);
    glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
    glStencilFunc(GL_EQUAL, 1, 1);  // draw shadowed part
    glDisable(GL_LIGHTING);

    DrawSpheres();

    glStencilFunc(GL_EQUAL, 0, 1);  // draw lit part //
    glEnable(GL_LIGHTING);

    DrawSpheres();


-------------------------------------------------------------
  please tear the sticker off my eddress before use
-------------------------------------------------------------


0
Reply j 6/23/2003 6:05:20 PM

See related articles to this posting


When you render concave object(s) OR multiple convex objects, you may have
multiple overlapping shadows for the same pixel, resulting in a stencil buffer
value greater than 1.

Then for correcting your problem, for the shadowing part you should not test
if STENCIL==1, you should test if STENCIL!=0 and that should do the trick.
That is, replace :
glStencilFunc(GL_EQUAL, 1, 1);  // draw shadowed part
with :
glStencilFunc(GL_NOTEQUAL, 0, (GLuint)(-1));  // draw shadowed part
and replace :
glStencilFunc(GL_EQUAL, 0, 1);  // draw lit part
with :
glStencilFunc(GL_EQUAL, 0, (GLuint)(-1));  // draw lit part

Just in case you don't know what (GLuint)(-1) is, it's a simple way of setting
all bits of the mask to 1, just like (GLuint)(0) would reset all bits of the
mask to 0.

Note that with this technique you're still limited to the number of bits in
the stencil buffer. For instance, with 8-bit stencil buffer the number of
overlapping shadows is limited to 255 per pixel (generally that limit is
enough hopefully).

Vincent


j wrote:

> hi,
>
> Im trying to implement shadowvolume rendering for
> multiple objects, but I dont really see the light yet.
> Here's a picture of the result, the code is below.
> The even and odd parts in the stencil seem to be
> cancelling out but I fail to see how that is.
> http://www.xs4all.nl/~vdspek/shadowvolumes.jpg
> The lower bunch of spheres only show the volumes.
> The volumes are capped on both sides and the quads
> that make up their surfaces have ccw winding, seen from outside.
>
> Im using the algorithm from shadowvol.c at the opengl site:
> http://www.opengl.org/developers/code/glut_examples/advanced/advanced.html
> which utilises the 'carmack method', see:
> http://developer.nvidia.com/docs/IO/2585/ATT/CarmackOnShadowVolumes.txt
> and also implemented the slightly different nvidia method,
> with the same result. Could anyone shed some light on this ?
> Im really in the dark here  :-D
>
> thanks,
>
> Jonathan
>
> ----------------------------------------------------------------------
>
>     glClear( GL_COLOR_BUFFER_BIT | \
>                  GL_DEPTH_BUFFER_BIT | \
>                  GL_STENCIL_BUFFER_BIT );
>
>     glEnable(GL_CULL_FACE);
>     glCullFace(GL_BACK);
>     glEnable( GL_DEPTH_TEST );
>     glColorMask(GL_FALSE, GL_FALSE, \
>                          GL_FALSE, GL_FALSE);
>     glDepthMask(GL_TRUE);
>
>     // only depth
>     DrawSpheres( );
>
>     glEnable(GL_STENCIL_TEST);
>     glDepthMask(GL_FALSE);
>
>     glStencilFunc(GL_ALWAYS, 0, 0);
>     glStencilOp(GL_KEEP, GL_KEEP, GL_INCR);
>     glCullFace(GL_BACK);  // increment using front face of shadow volume
>
>     DrawVolumes();
>
>     // m�thode Carmaque: decrement for clipped faces
>     glStencilOp(GL_KEEP, GL_KEEP, GL_DECR);
>     glCullFace(GL_FRONT);  // decrement using back face of shadow volume
>
>     DrawVolumes();
>
>     glDepthMask(GL_TRUE);
>     glDepthFunc(GL_LEQUAL);
>     glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
>     glCullFace(GL_BACK);
>     glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
>     glStencilFunc(GL_EQUAL, 1, 1);  // draw shadowed part
>     glDisable(GL_LIGHTING);
>
>     DrawSpheres();
>
>     glStencilFunc(GL_EQUAL, 0, 1);  // draw lit part //
>     glEnable(GL_LIGHTING);
>
>     DrawSpheres();
>
> -------------------------------------------------------------
>   please tear the sticker off my eddress before use
> -------------------------------------------------------------

0
Reply Vincent 6/24/2003 11:08:11 AM

thanks, that did it


--
-------------------------------------------------------------
  please tear the sticker off my eddress before use
-------------------------------------------------------------
"Vincent DAVID" <vincentdavid@c-s.fr> wrote in message
news:3EF8311B.DF5157F4@c-s.fr...
> When you render concave object(s) OR multiple convex objects, you may have
> multiple overlapping shadows for the same pixel, resulting in a stencil
buffer
> value greater than 1.
>
> Then for correcting your problem, for the shadowing part you should not
test
> if STENCIL==1, you should test if STENCIL!=0 and that should do the trick.
> That is, replace :
> glStencilFunc(GL_EQUAL, 1, 1);  // draw shadowed part
> with :
> glStencilFunc(GL_NOTEQUAL, 0, (GLuint)(-1));  // draw shadowed part
> and replace :
> glStencilFunc(GL_EQUAL, 0, 1);  // draw lit part
> with :
> glStencilFunc(GL_EQUAL, 0, (GLuint)(-1));  // draw lit part
>
> Just in case you don't know what (GLuint)(-1) is, it's a simple way of
setting
> all bits of the mask to 1, just like (GLuint)(0) would reset all bits of
the
> mask to 0.
>
> Note that with this technique you're still limited to the number of bits
in
> the stencil buffer. For instance, with 8-bit stencil buffer the number of
> overlapping shadows is limited to 255 per pixel (generally that limit is
> enough hopefully).
>
> Vincent
>
>
> j wrote:
>
> > hi,
> >
> > Im trying to implement shadowvolume rendering for
> > multiple objects, but I dont really see the light yet.
> > Here's a picture of the result, the code is below.
> > The even and odd parts in the stencil seem to be
> > cancelling out but I fail to see how that is.
> > http://www.xs4all.nl/~vdspek/shadowvolumes.jpg
> > The lower bunch of spheres only show the volumes.
> > The volumes are capped on both sides and the quads
> > that make up their surfaces have ccw winding, seen from outside.
> >
> > Im using the algorithm from shadowvol.c at the opengl site:
> >
http://www.opengl.org/developers/code/glut_examples/advanced/advanced.html
> > which utilises the 'carmack method', see:
> > http://developer.nvidia.com/docs/IO/2585/ATT/CarmackOnShadowVolumes.txt
> > and also implemented the slightly different nvidia method,
> > with the same result. Could anyone shed some light on this ?
> > Im really in the dark here  :-D
> >
> > thanks,
> >
> > Jonathan
> >
> > ----------------------------------------------------------------------
> >
> >     glClear( GL_COLOR_BUFFER_BIT | \
> >                  GL_DEPTH_BUFFER_BIT | \
> >                  GL_STENCIL_BUFFER_BIT );
> >
> >     glEnable(GL_CULL_FACE);
> >     glCullFace(GL_BACK);
> >     glEnable( GL_DEPTH_TEST );
> >     glColorMask(GL_FALSE, GL_FALSE, \
> >                          GL_FALSE, GL_FALSE);
> >     glDepthMask(GL_TRUE);
> >
> >     // only depth
> >     DrawSpheres( );
> >
> >     glEnable(GL_STENCIL_TEST);
> >     glDepthMask(GL_FALSE);
> >
> >     glStencilFunc(GL_ALWAYS, 0, 0);
> >     glStencilOp(GL_KEEP, GL_KEEP, GL_INCR);
> >     glCullFace(GL_BACK);  // increment using front face of shadow volume
> >
> >     DrawVolumes();
> >
> >     // m�thode Carmaque: decrement for clipped faces
> >     glStencilOp(GL_KEEP, GL_KEEP, GL_DECR);
> >     glCullFace(GL_FRONT);  // decrement using back face of shadow volume
> >
> >     DrawVolumes();
> >
> >     glDepthMask(GL_TRUE);
> >     glDepthFunc(GL_LEQUAL);
> >     glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
> >     glCullFace(GL_BACK);
> >     glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
> >     glStencilFunc(GL_EQUAL, 1, 1);  // draw shadowed part
> >     glDisable(GL_LIGHTING);
> >
> >     DrawSpheres();
> >
> >     glStencilFunc(GL_EQUAL, 0, 1);  // draw lit part //
> >     glEnable(GL_LIGHTING);
> >
> >     DrawSpheres();
> >
> > -------------------------------------------------------------
> >   please tear the sticker off my eddress before use
> > -------------------------------------------------------------
>


0
Reply j 6/24/2003 12:23:19 PM
comp.graphics.api.opengl 7101 articles. 24 followers. Post

2 Replies
447 Views

Similar Articles

[PageSpeed] 55


  • Permalink
  • submit to reddit
  • Email
  • Follow


Reply:

Similar Artilces:

stencil shadow volumes
er... assume you have a model that casts a shadow. Now I need a shadow volume of that thing. The easiest way I can think of is to simply flatten the model perpendicular to the light direction, then run a delaunay over the points to get a silhouette of that thing. As you might expect, this is nothing for real time shadows. The next method: extrude every triangle's edge and remove edges that are twice in the list (front+back side are "glued together"). But I fear problems I can't see so far. Any idea how to (quickly) get the silhouette? -- -Gernot int main(int argc, ch...

MntVerifyTimeout, (remote shadow member), clustering, volume shadowing
I've got a bizarre problem. Perhaps someone can point me in the right direction. Please don't reply via email (see below). I have a three-node cluster. Node ELIJAH crashed (and for some reason didn't reboot, even though the console parameters should be set so that it reboots automatically). Nodes GLADIA and DANEEL remained up. DISK$USER is a shadow set consisting of two SEAGATE SCSI-2 disks, one member with a direct connection to ELIJAH and another with a direct connection to DANEEL. This shadow set is mounted on all nodes during startup. All disks are MSCP served to al...

Stencilled Shadows
Hi ! Based on this article http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=27 I wonder if it's possible to smooth the edges of the projected shadows, for exemple make them blurry. If you know another good paper about this, feel free to make me aware of this please. Thanks. <bruckner.olivier@tiscali.fr> a �crit dans le message de news:40a8a2fa$0$13004$626a14ce@news.free.fr... > Hi ! > > Based on this article > http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=27 I wonder if > it's possible to smooth the edges of the projected shadows, for exempl...

Stencil Shadow
Can i write fast animation with stencil shadows, or there is some better/faste way to make shadows? Maedowan schrieb: > Can i write fast animation with stencil shadows, or there is some better/faste way > to make shadows? If you want sharp shadows, stencil shadows are probably the fastest. Shadow maps require an additional texture, but easily expand to soft shadows. Philipp Maedowan wrote: > Can i write fast animation with stencil shadows Yes, that's how Doom 3 does shadows... -- <\___/> / O O \ \_____/ FTB. For email, remove my socks. Governments, like diaper...

Shadow volume
Hi! me again. Thanks for all the info re: radiosity and forward and backward distributed ray-tracing etc..., still getting my head round it though, as I'm not a mathematician, and I've only been looking into it for the past weeks, so my understanding is still very sketchy anyway, how does shadow volume fit into all this. I read briefly about. I believe it was introduced by Crow in 1977? Thanks Henry In fact, I'm slight confused. Can distributed ray-tracing be classed as a form of radiosity? In terms of view-dependency, I'm SURE I've read somewhere that radiosity is a...

artifacts during volume shadows
After the volume shadows algorithm, my program shows some cubes. Currently there are some strange effects that I don't know how to delete: -Shadows are totally black. I would like to have semi-trasparent shadows. -Some strange figures appear at the end of the shadow volumes and look like a projection of the cubes. -Black lines connect the cubes to their projection. These are the borders of the polygons of the shadows volumes. While I'm sure that the first could be solved playing a little with alpha settings, the last two artifacts are very strange. The base code I used was the same of...

Volume shadowing question
I have a two-node cluster with two shadowed volumes. Each volume has one physical disk on each node. Like this node_a:: node_b:: -- $100$dka100 = DSA1 = $101$dka400 -- -- $100$dka200 = DSA2 = $101$dka300 -- Now I've added a third node, node_c, that serves no disks. (It's not strictly a satellite as it has its own system disk. I gave it 0 votes anyhow. so that it could come and gor from the cluster without having to re-calculate quorum.) Anyhow, the problem is that when I reboot the third node, one or both of the shadow volumes will break ...

Shadow volumes normals
Hello, I'm using the shadow volumes technique to produce shadows in my 3D scenes. However, I have some problem with regards to the volume's normals computation. I tried several ways to compute them, none of them revealed themselves to be successful. Let L be the light position and V0 and V1 two vertices of a silhouette edge of the shadowing object. Here are some solutions I tried: 1. I first computed the normal like this: (V1-V0) x (L-V0). This gives a good normal but with no garantee that it is oriented "outside" the volume. 2. To reorient the normal computed in (1), ...

Shadow Volume Copy
We have a shadow logical disk, with two members. They want to copy the physical files which form the shadow to another machine. I'm trying to create DCL with this commands $ dismount lda1: $! $! copy file $! $ copy dkb0:[000000]vd1.dsk dkb1:[BACKUP] $! $! Mount disk again $ mou/sys/noassi dsa0: /shadow=($1$lda1:,$1$lda2:) shadowvol vds $disk $! $! $ dismount lda2: $! $! copy file $! $ copy dkb1:[000000]vd2.dsk dkb1:[BACKUP] $! $! Mount disk again $ mou/sys/noassi dsa0: /shadow=($1$lda1:,$1$lda2:) shadowvol vds $disk When I ran the commands manually one bye it w...

Volume shadowing stalls...
Sometimes we get very very long merge operations that seem to take days even though the system is quiet.... I think there is a back-off sensitivity to systenm I/O that is perhaps getting triggered.... has anyone seen this sort of thing ,. lots of memory and page resources of all sorts NPAGE and PAGEDYN... 7.3-1 current patch "Hal Kuff" <kuff@comcast.net> wrote in message news:<cmbuuu$uju@library1.airnews.net>... > Sometimes we get very very long merge operations that seem to take days even > though the system is quiet.... I think there is a back-off sensitivity ...

learning stencil shadows
I learn stencil shadows. The result of tutorial that I saw, sucks... It uses stencil buffer to return pure black color (no draw) for shadows. I dont want my shadows to be black color! I want to dark my shadowed regions of scene (I mean r/2 g/2 b/2 of original unshadowed rgb) I think many methods to produce that result, but faster method I think requires to draw an alpha texture polygon on the whole scene. What is the commonly used method from this? If stencil is 2, 3, 4 or more, I want this region to be more darken than stencil = 1. How I can do this? I can't help you directly with ...

other shadow volume questions...
Now I have understand shadow volumes. But I have some questions. 1. With which method can we determine which edges (between 2 neighbor polygons) must be extruded? I think a method: if 2 polygon normals have different Z sign (+ / -) (first we transform the scene with the light in the origin). Is there a faster method? 2. What we can do I we are in the shadow? (Except to close our eyes!) 3. What we can do if one shadow volume polygon intersects near plane? We must use the Carmack's inverse? 4. Then what we can do if one shadow volume polygon intersects far plane? We must use the origina...

volume shadowing over LAVC ?
hi, is it possible to do volume shadowing over LAVC without HSx controler (let say with local disk on each node) ? TIA, Pierre. Pierre wrote: > is it possible to do volume shadowing over LAVC without HSx controler > (let say with local disk on each node) ? Yes. Been there, done that on 10mbps ethernet back in 1992 at 5.5-2. You need host based volume shadowing. The software is pretty smart and for reads, if the local disk is already very busy, the reads are done on the remote disk. So read throughput is actually increased. Writes are slower because it waits for both disks to b...

Volume Shadowing Availability
Hi Guys There was a document kicking around some 10 years ago that gave a mathematical analysis of relative availability with single, two and three member shadow sets. Guess it was about 15-20 pages long. Anyone have an electronic copy or knwo where it was published? Thanks and regards -Neil Neil Lowden wrote: > Hi Guys > > There was a document kicking around some 10 years ago that gave a > mathematical analysis of relative availability with single, two and > three member shadow sets. Guess it was about 15-20 pages long. > > Anyone have an electronic copy or knwo w...

Help with stencil shadows?
I'm having a little trouble with stencil shadowing. Specifically my problem is with self-shadowing. I draw my object, then draw its shadow using the darkening method (copy object geometry and add degenerate quads along edges, draw with two-sided stencil, then draw an overlay poly to make the shadow). The problem is, the frontcap of the shadow z-fights with the object itself, resulting in a crawly, artifact-y self-shadow. I've tried a couple of things, like playing with z-bias, 'jittering' the shadow volume's verts in/out along their normals, etc, but nothing seems t...

Stencil shadowing and transparent objects.
Hi, I've implemented stencil shadows for the better part, which is working ok. But I'm wondering how to deal with transparent surfaces. For example if you're looking through a fence on a racetrack; for nice anti-aliasing you want to blend the fence, instead of doing an alpha test hard cut. That does mean though the Z-buffer won't get filled, but that interferes with the operation of stencil shadows, since the shadow volumes need to deal with Z-values to work. Anybody know a way around this problem? Thanks, Ruud van Gaal Free car sim: http://www.racer.nl/ Pencil art : http:...

Re: Volume shadowing question
helbig@astro.multiCLOTHESvax.de (Phillip Helbig---remove CLOTHES to reply) wrote on 02/17/2004 03:13:15 PM: > In article <Xns94928391CA344falkarcabca@198.80.55.250>, Alfred Falk > <falk@arc.REMOVE.ab.ca> writes: > > > I have a two-node cluster with two shadowed volumes. Each volume has > > one physical disk on each node. Like this > > node_a:: node_b:: > > -- $100$dka100 = DSA1 = $101$dka400 -- > > -- $100$dka200 = DSA2 = $101$dka300 -- > > > > Now I've added a third node, node_c, that...

Indexing shadow volumes with Spotlight
I found this tip http://www.dreness.com/blog/archives/16 on how to index read-only volumes with Spotlight. The tip seems reasonable, (and very useful) and correctly mounts the shadow volume, but for some reason I get an error when the script tries to turn on the indexing for the shadowed volume. Does anybody have any ideas? Thanks, Alan The script is below: #!/bin/sh # pass in the name of the r/o volume, e.g. DiskWarriorCD # this is proof of concept only. seriously :) if [ ! $1 ] ; then echo "supply a volume name" ; exit 1 ; fi vol=$1 rodevpath=`df | grep "$vol" ...

Faster shadow volume rendering
I am receiving major slowdowns when rendering shadow volumes, (mostly zfail, but it also occurs with zpass). The processing algorithm I use is not the culprit as no matter how slow it was to begin with or how fast it is optimised, the FPS can still drop from above 80 to 10 and below (simply by panning the camera down such that more of the volume would be visible). I am using an infinite frustum, and am making proper use of the homogenous coord in the volume vertices. As it stands, my rendering is as follows, for each mesh in respect to each light: -Set perspective correction, point smoothi...

volume shadowing question #2
Hello We are installing an EVA4000 in replacement of an MSA1000. I was wondering if I could use HBVS to switch my data onto the new storage, online. That is: create a new drive on the EVA4000, mount it as a shadow member of the existing one on MSA1000. When the merge is complete, dismount the member that's on the MSA1000. A possible technical problem: The VMScluster is comprised of 2 Alphaservers and one IA64 server. When I mount /cluster the shadow member, will all nodes see it properly (different architecture should not be a problem on VMS) ? And is there something obvious that ...

tricky shadow volume problem
Hi I have a program that uses the stencil incr decr method for making shadows. This is the situation. Think of a mast on a ship that is attached to the middle botom of the ship and assume that mast will cast a shadow. The inside hull and the outside hull of the boat are separate objects, one faces in and the other faces out. Here is what is happening. The mast casts its shadow correctly on the inside hull, but mysteriously, the shadow also appears on the outside hull. I have tried to thinik through the way the front and back shadow planes are drawn and I can see where this would happen. Sinc...

DVE and DDS (volume shadowing)
I've read the help and the documentation but want to make sure I am not missing anything. I have some shadow sets which I want to transfer to larger disks. Of course, I could do an image backup, but I want to avoid the problems with that (mainly time during which the source is not usable since it needs to be write-locked). I want to do this under 7.3-2; an upgrade to 8.3 will be done soon, but for various reasons I want to reconfigure my hardware first. Suppose I have a shadow set consisting of two small disk and want to transfer it to two (or, later, perhaps more) larger disks. Is...

Extruding polygons to infinity for shadow volume
Hi all, I'm reading up on Stencil Shadow Volumes. One thing that isn't clear yet is how I can extrude edges to infinity to generate the shadow volume polygons. What values do I pass to OpenGL, surely not infinity? Thanks for any help, Ruud van Gaal Free car sim: http://www.racer.nl/ Pencil art : http://www.marketgraph.nl/gallery/ Ruud van Gaal wrote: > Hi all, > > I'm reading up on Stencil Shadow Volumes. > One thing that isn't clear yet is how I can extrude edges to infinity > to generate the shadow volume polygons. What values do I pass to > OpenGL, su...

vertex shader shadow volumes example ...
Is anyone to direct me to a URL containing an example of a vertex shader implementing the shadow volumes algorithm? Russell ...