Class ShadowType
Description:
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.