NL3D::CShadowMapManager Class Reference

A class to manage the render of shadow map. More...

#include <shadow_map_manager.h>

List of all members.

Public Member Functions

 CShadowMapManager ()
 Constructor.
 ~CShadowMapManager ()
void setQuadGridSize (uint size, float cellSize)
 change the QuadGrid size. it reset all the receivers!
void clearAllShadowCasters ()
 clear both _ShadowCasters and _GenerateShadowCasters lists WARNING: the _GenerateShadowCasters list of shadow caster (added with addShadowCaster() / selectShadowMapsToGenerate()) must have valid Ptrs.
void addShadowCaster (CTransform *model)
 Add a ShadowCaster that influence the scene this pass.
void selectShadowMapsToGenerate (CScene *scene)
 From List of ShadowCaster, select a sub - part (so called Loding ShadowMap Casters) NB: Beware that this clear the currentlist of shadowMap to generate NB: model->setGeneratingShadowMap(true); are called for each model selected.
void addShadowReceiver (CTransform *model)
 Add a ShadowRecevier visible in this scene for this pass.
void renderGenerate (CScene *scene)
 render ShadowMap with ShadowCasters.
void renderProject (CScene *scene)
 project ShadowMaps onto receivers.
void enableShadowPolySmooth (bool enable)
 Enable Polygon Smoothing.
bool getEnableShadowPolySmooth () const
 get Enable Polygon Smoothing flag
CMaterialgetCasterShadowMaterial ()
 Get the typical Material for Caster.
Texture Allocation



ITextureallocateTexture (uint textSize)
 Allocate a texture for a shadowMap. NB: owned by a smartPtr. nlassert powerof2.
void releaseTexture (ITexture *text)
 Release this one.

Private Types

typedef CQuadGrid< CTransform * > TShadowReceiverGrid
typedef std::map< ITexture
*, CSmartPtr< ITexture > > 
TTextureMap
typedef TTextureMap::iterator ItTextureMap

Private Member Functions

void computeShadowDirection (CScene *scene, CTransform *sc, CVector &lightDir)
void computeShadowColors (CScene *scene, CTransform *sc, CRGBA &ambient, CRGBA &diffuse)
void fillBlackBorder (IDriver *drv, uint numPassText, uint numTextW, uint numTextH, uint baseTextureSize)
void setBlackQuad (uint index, sint x, sint y, sint w, sint h)
void updateBlurTexture (IDriver &drv, uint w, uint h)
void copyScreenToBlurTexture (IDriver *drv, uint numPassText, uint numTextW, uint numTextH, uint baseTextureSize)
void applyFakeGaussianBlur (IDriver *drv, uint numPassText, uint numTextW, uint numTextH, uint baseTextureSize, uint blurSource)
void setBlurQuadFakeGaussian (uint index, sint x, sint y, sint w, sint h)
void clearGenerateShadowCasters ()
void garbageShadowTextures (CScene *scene)

Private Attributes

std::vector< CTransform * > _ShadowCasters
std::vector< CTransform * > _GenerateShadowCasters
TShadowReceiverGrid _ShadowReceiverGrid
bool _PolySmooth
CVertexBuffer _FillQuads
CMaterial _FillMaterial
CSmartPtr< ITexture_BlurTexture [2]
uint32 _BlurTextureW
uint32 _BlurTextureH
float _BlurTextureOOW
float _BlurTextureOOH
float _BlurTextureD05W
float _BlurTextureD05H
CMaterial _BlurMaterial [2]
CVertexBuffer _BlurQuads
CVertexBuffer _CopyQuads
CMaterial _CopyMaterial
CMaterial _ReceiveShadowMaterial
NLMISC::CSmartPtr< ITexture_ClampTexture
CShadowMapProjector _ShadowMapProjector
CMaterial _CasterShadowMaterial
TTextureMap _ShadowTextureMap
std::vector< ItTextureMap_FreeShadowTextures
NLMISC::CSmartPtr
< ITexture::CTextureCategory
_TextureCategory

Detailed Description

A class to manage the render of shadow map.

Author:
Lionel Berenguier
Nevrax France
Date:
2003

Definition at line 56 of file shadow_map_manager.h.


Member Typedef Documentation

typedef TTextureMap::iterator NL3D::CShadowMapManager::ItTextureMap [private]

Definition at line 170 of file shadow_map_manager.h.

Definition at line 122 of file shadow_map_manager.h.

Definition at line 169 of file shadow_map_manager.h.


Constructor & Destructor Documentation

NL3D::CShadowMapManager::CShadowMapManager (  ) 

Constructor.

Definition at line 58 of file shadow_map_manager.cpp.

References _BlurMaterial, _BlurQuads, _BlurTextureH, _BlurTextureW, _CasterShadowMaterial, _ClampTexture, _CopyMaterial, _CopyQuads, _FillMaterial, _FillQuads, _GenerateShadowCasters, _PolySmooth, _ReceiveShadowMaterial, _ShadowCasters, _TextureCategory, NL3D::CMaterial::always, NL3D::ITexture::Clamp, NL3D::CMaterial::Diffuse, NL3D::easeInEaseOut(), NL3D::CMaterial::enableUserTexMat(), NL3D::CMaterial::initUnlit(), NL3D::CMaterial::InterpolateConstant, NL3D::CMaterial::InvSrcColor, NL3D::CMaterial::invsrccolor, NL3D::ITexture::Linear, NL3D::ITexture::LinearMipMapOff, NL3D::CVertexBuffer::lock(), NL3D::CMaterial::Modulate, NL3D_SMM_QUADCELL_SIZE, NL3D_SMM_QUADGRID_SIZE, NL3D::CMaterial::one, NL3D::CVertexBuffer::PositionFlag, NL3D::CMaterial::Previous, NL3D::CVertexBuffer::RAMVolatile, NL3D::CMaterial::Replace, NL3D::CMaterial::setAlphaTest(), NL3D::CMaterial::setAlphaTestThreshold(), NL3D::CMaterial::setBlend(), NL3D::CMaterial::setBlendFunc(), NL3D::CMaterial::setColor(), NL3D::CMaterial::setDoubleSided(), NL3D::CVertexBuffer::setName(), NL3D::CVertexBuffer::setNumVertices(), NL3D::CVertexBuffer::setPreferredMemory(), setQuadGridSize(), NL3D::CMaterial::setTexCoordGen(), NL3D::CMaterial::setTexCoordGenMode(), NL3D::CMaterial::setTexture(), NL3D::CVertexBufferReadWrite::setVertexCoord(), NL3D::CVertexBuffer::setVertexFormat(), NL3D::CMaterial::setZFunc(), NL3D::CMaterial::setZWrite(), NL3D::CMaterial::SrcAlpha, NL3D::CMaterial::SrcColor, NL3D::CMaterial::texConstantColor(), NL3D::CVertexBuffer::TexCoord0Flag, NL3D::CVertexBuffer::TexCoord1Flag, NL3D::CVertexBuffer::TexCoord2Flag, NL3D::CVertexBuffer::TexCoord3Flag, NL3D::CMaterial::TexCoordGenObjectSpace, NL3D::CMaterial::texEnvArg0Alpha(), NL3D::CMaterial::texEnvArg0RGB(), NL3D::CMaterial::texEnvArg1Alpha(), NL3D::CMaterial::texEnvArg1RGB(), NL3D::CMaterial::texEnvOpAlpha(), NL3D::CMaterial::texEnvOpRGB(), NL3D::CMaterial::Texture, NLMISC::CRGBA::White, and NL3D::CMaterial::zero.

NL3D::CShadowMapManager::~CShadowMapManager (  ) 

Definition at line 224 of file shadow_map_manager.cpp.

References clearAllShadowCasters().


Member Function Documentation

void NL3D::CShadowMapManager::addShadowCaster ( CTransform model  ) 

Add a ShadowCaster that influence the scene this pass.

Definition at line 236 of file shadow_map_manager.cpp.

References _ShadowCasters.

Referenced by NL3D::CClipTrav::clipShadowCasters().

void NL3D::CShadowMapManager::addShadowReceiver ( CTransform model  ) 
ITexture * NL3D::CShadowMapManager::allocateTexture ( uint  textSize  ) 
void NL3D::CShadowMapManager::applyFakeGaussianBlur ( IDriver drv,
uint  numPassText,
uint  numTextW,
uint  numTextH,
uint  baseTextureSize,
uint  blurSource 
) [private]
void NL3D::CShadowMapManager::clearAllShadowCasters (  ) 

clear both _ShadowCasters and _GenerateShadowCasters lists WARNING: the _GenerateShadowCasters list of shadow caster (added with addShadowCaster() / selectShadowMapsToGenerate()) must have valid Ptrs.

=> Cannot leave this list non empty at end of CScene::render() because some CTransform may be deleted between render()

Definition at line 1129 of file shadow_map_manager.cpp.

References _ShadowCasters, _ShadowReceiverGrid, NL3D::CQuadGrid< T >::clear(), and clearGenerateShadowCasters().

Referenced by renderGenerate(), NL3D::CScene::renderPart(), renderProject(), and ~CShadowMapManager().

void NL3D::CShadowMapManager::clearGenerateShadowCasters (  )  [private]
void NL3D::CShadowMapManager::computeShadowColors ( CScene scene,
CTransform sc,
CRGBA ambient,
CRGBA diffuse 
) [private]
void NL3D::CShadowMapManager::computeShadowDirection ( CScene scene,
CTransform sc,
CVector lightDir 
) [private]
void NL3D::CShadowMapManager::copyScreenToBlurTexture ( IDriver drv,
uint  numPassText,
uint  numTextW,
uint  numTextH,
uint  baseTextureSize 
) [private]

Definition at line 967 of file shadow_map_manager.cpp.

void NL3D::CShadowMapManager::enableShadowPolySmooth ( bool  enable  )  [inline]

Enable Polygon Smoothing.

Definition at line 96 of file shadow_map_manager.h.

References _PolySmooth.

Referenced by NL3D::CScene::enableShadowPolySmooth().

void NL3D::CShadowMapManager::fillBlackBorder ( IDriver drv,
uint  numPassText,
uint  numTextW,
uint  numTextH,
uint  baseTextureSize 
) [private]
void NL3D::CShadowMapManager::garbageShadowTextures ( CScene scene  )  [private]
CMaterial& NL3D::CShadowMapManager::getCasterShadowMaterial (  )  [inline]

Get the typical Material for Caster.

Definition at line 101 of file shadow_map_manager.h.

References _CasterShadowMaterial.

Referenced by NL3D::CSkeletonModel::generateShadowMap(), and NL3D::CMeshInstance::generateShadowMap().

bool NL3D::CShadowMapManager::getEnableShadowPolySmooth (  )  const [inline]

get Enable Polygon Smoothing flag

Definition at line 98 of file shadow_map_manager.h.

References _PolySmooth.

Referenced by NL3D::CScene::getEnableShadowPolySmooth().

void NL3D::CShadowMapManager::releaseTexture ( ITexture text  ) 

Release this one.

NB: the texture is not deleted, but still will be used for later use

Definition at line 1196 of file shadow_map_manager.cpp.

References _FreeShadowTextures, _ShadowTextureMap, and nlassert.

Referenced by NL3D::CShadowMap::resetTexture().

void NL3D::CShadowMapManager::renderGenerate ( CScene scene  ) 

render ShadowMap with ShadowCasters.

Generate ShadowMap only (with the AuxDriver). NB: current driver Frustum, ViewMatrix kept their initial state but ModelMatrix not.

Definition at line 251 of file shadow_map_manager.cpp.

References _BlurTexture, _BlurTextureH, _BlurTextureOOH, _BlurTextureOOW, _BlurTextureW, _CopyMaterial, _CopyQuads, _GenerateShadowCasters, _PolySmooth, _ShadowCasters, NL3D::IDriver::activeVertexBuffer(), applyFakeGaussianBlur(), NLMISC::clamp(), NL3D::IDriver::clear2D(), clearAllShadowCasters(), clearGenerateShadowCasters(), computeShadowDirection(), NL3D::IDriver::enableFog(), NL3D::IDriver::enablePolygonSmoothing(), fillBlackBorder(), NL3D::IDriver::fogEnabled(), garbageShadowTextures(), NL3D::CTransform::generateShadowMap(), NL3D::CRenderTrav::getAuxDriver(), NL3D::CScene::getNumRender(), NL3D::CScene::getRenderTrav(), NL3D::CTransform::getShadowMap(), NL3D::CScene::getShadowMapBlurSize(), NL3D::CScene::getShadowMapTextureSize(), NL3D::CShadowMap::getTexture(), NL3D::IDriver::getViewport(), NL3D::IDriver::getWindowSize(), H_AUTO, NLMISC::CMatrix::Identity, NL3D::CScissor::init(), NL3D::CViewport::init(), NL3D::CViewport::initFullScreen(), NL3D::CScissor::initFullScreen(), NLMISC::isPowerOf2(), NL3D::CShadowMap::LastGenerationFrame, NL3D::CVertexBuffer::lock(), min, NL3D_SMM_MAX_TEXTDEST_SIZE, NLMISC::raiseToNextPowerOf2(), NL3D::IDriver::renderRawQuads(), NL3D::IDriver::setColorMask(), NL3D::IDriver::setFrustum(), NL3D::IDriver::setRenderTarget(), NL3D::CVertexBufferReadWrite::setTexCoord(), NL3D::CMaterial::setTexture(), NL3D::CRenderTrav::setupDriverCamera(), NL3D::IDriver::setupModelMatrix(), NL3D::IDriver::setupScissor(), NL3D::IDriver::setupViewMatrix(), NL3D::IDriver::setupViewport(), and updateBlurTexture().

Referenced by NL3D::CRenderTrav::traverse().

void NL3D::CShadowMapManager::renderProject ( CScene scene  ) 

project ShadowMaps onto receivers.

NB: renderGenerate() must have been called before. NB: current driver Frustum, ViewMatrix kept their initial state but ModelMatrix not. call clearShadowCaster

Get The Mean Ambiant and Diffuse the caster receive (and cast, by approximation)

Finally "modulate" with FinalFade.

Definition at line 519 of file shadow_map_manager.cpp.

References _ReceiveShadowMaterial, _ShadowCasters, _ShadowMapProjector, _ShadowReceiverGrid, NL3D::CShadowMapProjector::applyToMaterial(), NLMISC::CRGBA::B, NL3D::CQuadGrid< T >::begin(), NLMISC::CRGBA::Black, NL3D::CQuadGrid< CTransform * >::CIterator, NLMISC::clamp(), clearAllShadowCasters(), computeShadowColors(), NL3D::IDriver::enableLight(), NL3D::CQuadGrid< T >::end(), G, NLMISC::CRGBA::G, NLMISC::CAABBox::getCenter(), NL3D::CRenderTrav::getDriver(), NL3D::CShadowMap::getFinalFade(), NL3D::IDriver::getFogColor(), NL3D::IDriver::getFogEnd(), NL3D::IDriver::getFogStart(), NLMISC::CAABBox::getMax(), NLMISC::CAABBox::getMin(), NLMISC::CMatrix::getPos(), NL3D::CTransform::getReceiverRenderWorldMatrix(), NL3D::CScene::getRenderTrav(), NL3D::CTransform::getShadowMap(), NL3D::CShadowMap::getTexture(), NL3D::CScene::getVisualCollisionManagerForShadow(), NL3D::CTransform::getWorldMatrix(), H_AUTO, NLMISC::CMatrix::invert(), NL3D::CShadowMap::LocalBoundingBox, NL3D::CShadowMap::LocalProjectionMatrix, nlassert, NLMISC::OptFastFloor(), NLMISC::CRGBA::R, NL3D::CVisualCollisionManager::receiveShadowMap(), NL3D::CTransform::receiveShadowMap(), NL3D::CRenderTrav::resetLightSetup(), NL3D::CQuadGrid< T >::select(), NLMISC::CAABBox::setCenter(), NL3D::CMaterial::setColor(), NLMISC::CMatrix::setPos(), NL3D::CMaterial::setTexture(), NL3D::IDriver::setupFog(), and NL3D::CShadowMapProjector::setWorldSpaceTextMat().

Referenced by NL3D::CRenderTrav::traverse().

void NL3D::CShadowMapManager::selectShadowMapsToGenerate ( CScene scene  ) 
void NL3D::CShadowMapManager::setBlackQuad ( uint  index,
sint  x,
sint  y,
sint  w,
sint  h 
) [private]
void NL3D::CShadowMapManager::setBlurQuadFakeGaussian ( uint  index,
sint  x,
sint  y,
sint  w,
sint  h 
) [private]
void NL3D::CShadowMapManager::setQuadGridSize ( uint  size,
float  cellSize 
)

change the QuadGrid size. it reset all the receivers!

Definition at line 230 of file shadow_map_manager.cpp.

References _ShadowReceiverGrid, and NL3D::CQuadGrid< T >::create().

Referenced by CShadowMapManager().

void NL3D::CShadowMapManager::updateBlurTexture ( IDriver drv,
uint  w,
uint  h 
) [private]

Member Data Documentation

Definition at line 144 of file shadow_map_manager.h.

Referenced by renderGenerate(), and updateBlurTexture().

Definition at line 150 of file shadow_map_manager.h.

Referenced by setBlurQuadFakeGaussian(), and updateBlurTexture().

Definition at line 149 of file shadow_map_manager.h.

Referenced by setBlurQuadFakeGaussian(), and updateBlurTexture().

Definition at line 146 of file shadow_map_manager.h.

Referenced by CShadowMapManager(), renderGenerate(), and updateBlurTexture().

Definition at line 145 of file shadow_map_manager.h.

Referenced by CShadowMapManager(), renderGenerate(), and updateBlurTexture().

Definition at line 164 of file shadow_map_manager.h.

Referenced by CShadowMapManager(), and getCasterShadowMaterial().

Definition at line 160 of file shadow_map_manager.h.

Referenced by CShadowMapManager().

Definition at line 156 of file shadow_map_manager.h.

Referenced by CShadowMapManager(), and renderGenerate().

Definition at line 155 of file shadow_map_manager.h.

Referenced by CShadowMapManager(), and renderGenerate().

Definition at line 141 of file shadow_map_manager.h.

Referenced by CShadowMapManager(), and fillBlackBorder().

Definition at line 140 of file shadow_map_manager.h.

Referenced by CShadowMapManager(), fillBlackBorder(), and setBlackQuad().

Definition at line 173 of file shadow_map_manager.h.

Referenced by allocateTexture(), garbageShadowTextures(), and releaseTexture().

Definition at line 159 of file shadow_map_manager.h.

Referenced by CShadowMapManager(), and renderProject().

Definition at line 161 of file shadow_map_manager.h.

Referenced by renderProject().

Definition at line 171 of file shadow_map_manager.h.

Referenced by allocateTexture(), garbageShadowTextures(), and releaseTexture().

Definition at line 178 of file shadow_map_manager.h.

Referenced by allocateTexture(), CShadowMapManager(), and updateBlurTexture().


The documentation for this class was generated from the following files:

Generated on Thu Jan 7 08:30:11 2010 for NeL by  doxygen 1.6.1