OpenGLContext.shadow.volume
Shadow-volume implementation
A volume is cast by a light from an edgeset, it's
basically the volume of space which is shadowed by
the given edgeset/object.
Classes
A shadow-volume object
This object represents the shadow cast by a single
light and a single occluder of that light. It is
rendered (along with all other volumes for a given
light) into the stencil buffer to determine what
parts of the scene are lit by the light.
XXX doesn't yet handle single-edges for faces or
(more cricitally) clock-wise windings
__init__(
self
,
edgeSet
,
sourceVector
)
Initialize the shadow volume
- edgeSet
- pointer to the edge set from which we retrieve most of our geometric data
- sourceVector
- the homogenous coordinates of the shadow-casting light.
calculate(
self
)
Calculate the shadow-volume's shape
Returns segments*2*3 array where each item in the array
has the property that it defines a face of the shadow
volume like so:
A,B = segment (2 3-item arrays)
for point lights (Quads):
Ax,Ay,Az,1.0
Bx,By,Bz,1.0
Bx,By,Bz,0.0
Ax,Ay,Az,0.0
for directional lights:
Ax,Ay,Az,1.0
Bx,By,Bz,1.0
0,0,0,0
Which is fed into the "equation 14" or "equation 15"
of the article. Note that this is pre-calculated to not
require switching calculations on the face when doing
the later transformation to a shadow volume. (i.e. in
the article there are two different cases for
whether the "first" or "second" face is facing the lights,
I've folded them together).
need certain things when we're done:
set of light-facing-faces
set of rearward-facing-faces (projected to infinity)
set of edge-faces (silouhette projected to infinity)
# the first two are currently missing
# should do those as indices into the points array
doubleEdges(
self
,
sourceVector
)
Calculate double-face-edges for given sourceVector
Returns an Nx2x3 array of line-segment coordinates