Lance R. Marrou (marrou++at++vsl.ist.ucf.edu)
Wed, 14 Jun 1995 15:18:25 -0400 (EDT)
First, it works in Performer 2.0a, but with a little twist (read hack). The
final shading is done with this:
stencil(TRUE, MY_STENCIL_ZERO, SF_NOTEQUAL, 0xff,ST_KEEP,ST_KEEP,ST_REPLACE);
instead of:
stencil(TRUE, MY_STENCIL_ZERO, SF_GREATER, 0xff,ST_KEEP,ST_KEEP,ST_REPLACE);
I am using an Indigo2 Extreme, and only 1 stencil bit plane is allocated (from
the Z-buffer, I presume). I don't see a difference between SF_NOTEQUAL and
SF_GREATER when there is only 1 bit plane. I can change the mask 0x1 instead
of 0xff and nothing different happens.
Second, with the exact same code, it does not work in Performer 1.2. I'm glad
the newer version corrects any problems, but I could not find any problems with
the stencil plane reported in 1.2 (release notes, etc.). I suppose it might
be because no one ever considered using the stencil plane on an Extreme. The
results we get in 1.2 is that the shading (from the shadows) is only done over
the back facing shadow polygons.
Just FYI, I am not going to include the whole source file, but here are the
draw callbacks I use. The shadow polygons are cloned so that there are three
"copies"; one for the front-facing shadows, one for back-facing, and another
to shade the existing geometry. (Drawing just the diffuse components of the
previous geometry will be too slow...I can deal with transparent shading, as
Angus Dorbie pointed out.) P.S. They are called in the correct order.
Thanks for any help or response.
/////////////////////////////////////////////////////////////////
//
// front-facing shadow pre-draw callback
//
/////////////////////////////////////////////////////////////////
int Shadow::preFrontShadow( pfTraverser *trav, void *data )
{
if (trav || data); /* ignore compiler warnings */
shadow_cull_face = pfGetCullFace();
pfCullFace(PFCF_BACK);
zwritemask(0x0);
wmpack(0x0);
stencil(TRUE, MY_STENCIL_ZERO, SF_ALWAYS, 0xff, ST_KEEP, ST_KEEP, ST_INCR);
return PFTRAV_CONT;
}
/////////////////////////////////////////////////////////////////
//
// back-facing shadow pre-draw callback
//
/////////////////////////////////////////////////////////////////
int Shadow::preBackShadow( pfTraverser *trav, void *data )
{
if (trav || data); /* ignore compiler warnings */
pfCullFace(PFCF_FRONT);
stencil(TRUE, MY_STENCIL_ZERO, SF_ALWAYS, 0xff, ST_KEEP, ST_KEEP, ST_DECR);
return PFTRAV_CONT;
}
/////////////////////////////////////////////////////////////////
//
// shadow pre-draw callback
//
/////////////////////////////////////////////////////////////////
int Shadow::preShadow( pfTraverser *trav, void *data )
{
if (trav || data); /* ignore compiler warnings */
pfCullFace(PFCF_BACK);
wmpack(0xffffffff);
/* stencil(TRUE, MY_STENCIL_ZERO, SF_GREATER, 0xff,ST_KEEP,ST_KEEP,ST_REPLACE); */
stencil(TRUE, MY_STENCIL_ZERO, SF_NOTEQUAL, 0xff,ST_KEEP,ST_KEEP,ST_REPLACE);
shadow_trans = pfGetTransparency();
pfTransparency(PFTR_ON);
return PFTRAV_CONT;
}
/////////////////////////////////////////////////////////////////
//
// shadow post-draw callback
//
/////////////////////////////////////////////////////////////////
int Shadow::postShadow( pfTraverser *trav, void *data )
{
if (trav || data); /* ignore compiler warnings */
pfTransparency(shadow_trans);
zwritemask(0xffffffff);
stencil(FALSE, 0, SF_NEVER, 0xff, ST_KEEP, ST_KEEP, ST_KEEP);
pfCullFace(shadow_cull_face);
return PFTRAV_CONT;
}
______________________________________________________________________________
/\ ______ /\____ ______ ______ E-mail: marrou++at++vsl.ist.ucf.edu
Visual / / / _ / / __ // ____// ____/ VSL: (407)658-5073
Systems / /__ / /_/ / / / / // /___ / __/_ R. Marrou Fax: (407)658-5059
Lab /____//____/\\/_/ /_//_____//_____/ http://www.vsl.ist.ucf.edu/~marrou
"Reap the whirlwind." "We don't need no thought control."
This archive was generated by hypermail 2.0b2 on Mon Aug 10 1998 - 17:51:35 PDT