This class is only available in release 5 or later.
The user of GetAreaShadowType()
is a linear or area light. The usage is:
void AreaShadowLightObjDesc::createShadowGenerator(AreaLight* light,bool forceShadowBuf) { ShadowType* shad = light->ActiveShadowType(); IAreaShadowType* area = shad->GetAreaShadowType(); // If we aren't forcing Shadow Map and the shadow generator // supports area shadows, then create the area shadow generator. // The flags are the same as for CreateShdowGenerator if (!forceShadowBuf && area != NULL) { _areaShadGen = area->CreateAreaShadowGenerator(light, this, SHAD_2SIDED) } else { _shadGen = shad->CreateShadowGenerator(light, this, SHAD_2SIDED); } }
Sampling the area shadows is a little tricky to allow for some optimizaton. This is an example of the code needed in AreaShadowLightObjDesc::Illuminate. The variable, sampler, should be local to allow multithreading.
AreaShadowSampler* sampler =_areaShadGen->InitializeSampler(alloca(_areaShadGen->GetSamplerSize()));
Once the sampler has been initialized, you can calculate the visibility between any point on the light and the point being shaded by using:
float atten = sampler->(sc, pointOnLight, shadedNormal, lightColor);
The value of pointOnLight depends on the type of light we are sampling. If the light is parallel, then pointOnLight needs to be in the local light coordinates. If the light is not parallel, then pointOnLight needs to be in camera coordinates.
#include <shadgen.h>
Public Member Functions |
|
SClass_ID | SuperClassID () |
Retrieves a constant representing the type
of the plugin. |
|
virtual ShadowParamDlg * | CreateShadowParamDlg (Interface *ip) |
virtual ShadowGenerator * | CreateShadowGenerator (LightObject *l, ObjLightDesc *ld, ULONG flags)=0 |
virtual BOOL | SupportStdMapInterface () |
BOOL | BypassPropertyLevel () |
virtual BOOL | CanDoOmni () |
virtual void | ConvertParamBlk (ParamBlockDescID *descOld, int oldCount, IParamBlock *oldPB) |
virtual int | MapSize (TimeValue t) |
virtual void | SetMapRange (TimeValue t, float f) |
virtual float | GetMapRange (TimeValue t, Interval &valid=Interval(0, 0)) |
virtual void | SetMapSize (TimeValue t, int f) |
virtual int | GetMapSize (TimeValue t, Interval &valid=Interval(0, 0)) |
virtual void | SetMapBias (TimeValue t, float f) |
virtual float | GetMapBias (TimeValue t, Interval &valid=Interval(0, 0)) |
virtual void | SetAbsMapBias (TimeValue t, int a) |
virtual int | GetAbsMapBias (TimeValue t, Interval &valid=Interval(0, 0)) |
virtual float | GetRayBias (TimeValue t, Interval &valid=Interval(0, 0)) |
virtual void | SetRayBias (TimeValue t, float f) |
virtual int | GetMaxDepth (TimeValue t, Interval &valid=Interval(0, 0)) |
virtual void | SetMaxDepth (TimeValue t, int f) |
IAreaShadowType * | GetAreaShadowType () |
SClass_ID SuperClassID | ( | ) | [inline, virtual] |
Retrieves a constant representing the type of the plugin.
Reimplemented from ReferenceTarget.
{ return SHADOW_TYPE_CLASS_ID;}
virtual ShadowParamDlg* CreateShadowParamDlg | ( | Interface * | ip | ) | [inline, virtual] |
{ return NULL; }
virtual ShadowGenerator* CreateShadowGenerator | ( | LightObject * | l, |
ObjLightDesc * | ld, | ||
ULONG | flags | ||
) | [pure virtual] |
virtual BOOL SupportStdMapInterface | ( | ) | [inline, virtual] |
{ return FALSE; }
BOOL BypassPropertyLevel | ( | ) | [inline, virtual] |
Reimplemented from Animatable.
{ return TRUE; } // want to promote shadowtype props to light level
virtual BOOL CanDoOmni | ( | ) | [inline, virtual] |
{ return FALSE; }
virtual void ConvertParamBlk | ( | ParamBlockDescID * | descOld, |
int | oldCount, | ||
IParamBlock * | oldPB | ||
) | [inline, virtual] |
virtual int MapSize | ( | TimeValue | t | ) | [inline, virtual] |
{ return 512; }
virtual void SetMapRange | ( | TimeValue | t, |
float | f | ||
) | [inline, virtual] |
{ return 0.0f; }
virtual void SetMapSize | ( | TimeValue | t, |
int | f | ||
) | [inline, virtual] |
{ return 0; }
virtual void SetMapBias | ( | TimeValue | t, |
float | f | ||
) | [inline, virtual] |
{ return 0.0f; }
virtual void SetAbsMapBias | ( | TimeValue | t, |
int | a | ||
) | [inline, virtual] |
{ return 0; }
{ return 0.0f; }
virtual void SetRayBias | ( | TimeValue | t, |
float | f | ||
) | [inline, virtual] |
{ return 1; }
virtual void SetMaxDepth | ( | TimeValue | t, |
int | f | ||
) | [inline, virtual] |
IAreaShadowType * GetAreaShadowType | ( | ) | [inline] |
{ return static_cast<IAreaShadowType*>(GetInterface(AREA_SHADOW_TYPE_INTERFACE_ID)); }