#include <shadgen.h>
Class Description
- See also:
- Class ShadowType,
Class ShadBufRenderer, Class RendContext,
Class RenderGlobalContext, Class
ShadeContext,
Class Matrix3, Class
Point3, Class Color.
- Description:
- This class is used by a Shadow Type plug-in to generate the
shadows. It only exists during a render, with one per instance of
the light. Methods of this class perform the shadow buffer creation
and sampling.
The ShadowGenerator API allows for
two methods of sampling: A generator can use either a "generic"
sampling method:
float Sample(ShadeContext &sc, Point3 &norm, Color& color);
Or, if it the generator is to work with Volumetric lights, it must
use the following sampling shadow-map style interface:
float Sample(ShadeContext &sc, float x, float y, float z, float xslope, float yslope);
BOOL QuickSample(int x, int y, float z);
FiltSample(int x, int y, float z, int level);
LineSample(int x1, int y1, float z1, int x2, int y2, float z2);
To indicate that the latter interface is used, the method ShadowType::SupportStdMapInterface()
must return TRUE;
Public Member Functions
|
virtual |
~ShadowGenerator
() |
virtual
int |
Update
(TimeValue
t, const RendContext &rendCntxt, RenderGlobalContext *rgc,
Matrix3
&lightToWorld, float aspect, float param, float
clipDist=DONT_CLIP)=0 |
virtual
int |
UpdateViewDepParams
(const Matrix3
&worldToCam)=0 |
virtual
void |
FreeBuffer
()=0 |
virtual
void |
DeleteThis
()=0 |
virtual
float |
Sample
(ShadeContext
&sc, Point3
&norm, Color
&color) |
virtual
float |
Sample
(ShadeContext
&sc, float x, float
y, float z, float
xslope, float yslope) |
virtual
BOOL |
QuickSample
(int x, int
y, float z) |
virtual
float |
FiltSample
(int x, int
y, float z, int
level) |
virtual
float |
LineSample
(int x1, int y1, float z1, int x2, int y2, float z2) |
Constructor & Destructor Documentation
Member Function Documentation
- Parameters:
- TimeValue t
The time for the update.
const RendContext&
rendCntxt
The render context -- this is used for the progress bar.
RenderGlobalContext
*rgc
This is used to get an instance list.
Matrix3&
lightToWorld
The light to world space transformation matrix. This is not
necessarily the same as that of the light.
float aspect
This is the aspect ratio for non-square buffers. The aspect gives
the height/width ratio of the shadow rectangle. The shadow buffer
bitmap is always the same number of pixels wide as it is high, but
it can be mapped into a non-square rectangle.
float param
This is the field-of-view of the light in radians for perspective
projections or the width in world coordinates for parallel
projections.
float clipDist = DONTCLIP
This parameter specifies the far clipping distance for the light.
This is used when the far distance attenuation is turned on, and
can result in much more efficient shadow buffer creation. If you
have a small scene in the middle of a large complex scene, and the
small scene is lit by, for instance, a shadow-casting omni, if you
don't use far attenuation the omni has to take into account the
entire large scene in its shadow map. Using far attenuation will
clip all this outside stuff. Also omnis free up any of their 6
shadow buffer that end up being empty, so this can save memory
usage.
- Returns:
- Nonzero on success; otherwise zero.
virtual int UpdateViewDepParams |
( |
const Matrix3 & |
worldToCam |
) |
[pure virtual] |
- Parameters:
- const Matrix3& worldToCam
This is the direction the view is looking from. Object
coordinates are relative to this 'camera'. This is not always a
'camera', it is just world to whatever view is needed, for example
from a mirror.
- Returns:
- Nonzero on success; otherwise zero.
virtual void FreeBuffer |
( |
|
) |
[pure virtual] |
virtual void DeleteThis |
( |
|
) |
[pure virtual] |
- Parameters:
- ShadeContext &sc
The shade context provides the point on the surface
(sc.P()).
Point3
&norm
This is the normal to the surface.
Color&
color
The input color.
- Returns:
- It returns an attenuation, where 1.0 indicates it is not in
shadow, and 0.0 indicates it is in shadow.
- Default Implementation:
- { return 1.0f; }
virtual float Sample |
( |
ShadeContext & |
sc, |
|
|
float |
x, |
|
|
float |
y, |
|
|
float |
z, |
|
|
float |
xslope, |
|
|
float |
yslope |
|
) |
|
[inline, virtual] |
- Parameters:
- ShadeContext &sc
The shade context.
float x
The x coordinate of the point to check. This point is normalized
into shadow buffer space. For example if the shadow buffer was
256x256 a point at the center would be 128, 128.
float y
The y coordinate of the point to check. This point is normalized
into shadow buffer space.
float z
The z coordinate of the point to check. This is the distance
perpendicular to the light where 0.0 is right at the light.
float xslope
This indicates the slope of the surface relative to the shadow
buffer in x.
float yslope
This indicates the slope of the surface relative to the shadow
buffer in y.
- Default Implementation:
- { return 1.0f; }
virtual BOOL QuickSample |
( |
int |
x, |
|
|
int |
y, |
|
|
float |
z |
|
) |
|
[inline, virtual] |
- Parameters:
- int x
The x coordinate of the point to check. This point is normalized
into shadow buffer space. For example if the shadow buffer was
256x256 a point at the center would be 128, 128.
int y
The y coordinate of the point to check. This point is normalized
into shadow buffer space.
float z
The z coordinate of the point to check. This is the distance
perpendicular to the light where 0.0 is right at the light.
- Returns:
- TRUE if the point is in shadow; otherwise FALSE.
- Default Implementation:
- { return 1; }
virtual float FiltSample |
( |
int |
x, |
|
|
int |
y, |
|
|
float |
z, |
|
|
int |
level |
|
) |
|
[inline, virtual] |
- Parameters:
- int x
The x coordinate of the point to check. This point is normalized
into shadow buffer space. For example if the shadow buffer was
256x256 a point at the center would be 128, 128.
int y
The y coordinate of the point to check. This point is normalized
into shadow buffer space.
float z
The z coordinate of the point to check. This is the distance
perpendicular to the light where 0.0 is right at the light.
int level
This may be 0 or 1. If 0, four neighboring pixels are blended in.
If 1, eight neighboring pixels are blended in.
- Returns:
- A value in the range 0.0 to 1.0.
- Default Implementation:
- { return 1.0f; }
virtual float LineSample |
( |
int |
x1, |
|
|
int |
y1, |
|
|
float |
z1, |
|
|
int |
x2, |
|
|
int |
y2, |
|
|
float |
z2 |
|
) |
|
[inline, virtual] |
- Parameters:
- int x1
The start x coordinate of the line. This point is normalized into
shadow buffer space. For example if the shadow buffer was 256x256 a
point at the center would be 128, 128.
int y1
The start y coordinate of the line. This point is normalized into
shadow buffer space.
float z1
The start z coordinate of the line. This is the distance
perpendicular to the light where 0.0 is right at the light.
int x2
The end x coordinate of the line. This point is normalized into
shadow buffer space.
int y2
The end y coordinate of the line. This point is normalized into
shadow buffer space.
float z2
The end z coordinate of the line. This is the distance
perpendicular to the light where 0.0 is right at the light.
- Returns:
- A value in the range 0.0 to 1.0 which represents how much of
the ray was inside the light and how much was outside the
light.
- Default Implementation:
- { return 1.0f; }