Kathy Loynes (kathyl++at++wormald.com.au)
Fri, 17 Feb 1995 18:23:47 +1100 (EST)
I have been attempting to implement some basic shadows using
stencilling and the "Shadow Volumes" technique. This approach was
described by Angus Dorbie in a recent posting and there is a full treatment
(with example code) provided on the Developer Toolbox CD.
My basic problem has been in getting it to work from within Perfomer. I
have a lot of example code using this technique written in GL. It works
fine and I thought it would be straightforward to implement the approach
in Performer. However, I've had no success and wondered if anyone else
has fared any better.
What I did was :
modelled the shadow polygons as 8 triangles to define the shadow volume
(top, bottom, 2 per side). I created 2 geosets, each containing this
geometry and attached them as the final nodes on the scene-graph. This
was to ensure that all the rest of the scene had been rendered (with
depths in zbuffer) prior to the shadow rendering. The first geoset
represented front facing geometry (with PFSTATE_CULLFACE set to
PFCF_BACK) and the second represented back facing geometry (with
PFSTATE_CULLFACE set to PFCF_FRONT).
I then set pre & post draw node callbacks on each of these.
PRE draw for front facing contained the following :-
sclear (0);
stencil (TRUE, 0, SF_ALWAYS, 0x1, ST_KEEP, ST_KEEP, ST_INCR);
zwritemask (0x00000000);
wmpack (0x0);
POST draw for front facing :-
(nothing, zbuffer & RGB writes already disabled)
PRE draw for back facing contained the following :-
stencil (TRUE, 0, SF_ALWAYS, 0x1, ST_KEEP, ST_KEEP, ST_DECR);
POST draw for back facing :-
wmpack (0xFFFFFFFF);
stencil (TRUE, 0, SF_GREATER, 0x1, ST_KEEP, ST_KEEP, ST_ZERO);
pfDrawGSet (shadowGSetFF); /* the front facing geoset */
zwritemask (0xFFFFFFFF);
stencil (FALSE, 0, 0, 0, 0, 0, 0);
Nothing is drawn. I also tried not attaching the geosets to the scene
graph (as I was positioning them so that they weren't culled anyway) and
calling pfDrawGSet 3 times after pfDraw but this didn't work either.
I am absolutely certain that all the geometry faced the correct way and
was drawn at the correct location. (If I did not disable zbuffer and RGB
framebuffer writes then all geometry was drawn facing the expected way.)
Also, the viewpoint itself was never in shadow and the shadow polygons
were capped.
After all this (and thanks to those who've persevered this far..), the only
thing I can think of is that I've not configured something the right way
in the stencil calls.
I am running on an RE2 (2 RMs) with the following config :
GC_BITS_ZBUFFER : 0
GC_BITS_STENCIL : 0
GC_MS_SAMPLES : 8
GC_BITS_MS_ZBUFFER : -24
GC_BITS_MS_STENCIL : 1
Is one stencil bit enough ? I couldn't see why not and when I set
GC_BITS_MS_STENCIL to 2 it made no difference.
Hopefully there's something really obvious I've missed ?????
Thanks for any help.
----------------------------------------------------------------------
Kathy Loynes | Wormald Technology
kathyl++at++wormald.com.au | Advanced Systems Engineering
Ph: +61 2 981 0611 | Sydney, Australia
This archive was generated by hypermail 2.0b2 on Mon Aug 10 1998 - 17:50:58 PDT