コード例 #1
0
ファイル: shadowMapManager.cpp プロジェクト: caomw/Torque3D
void ShadowMapManager::setLightShadowMapForLight( LightInfo *light )
{
    ShadowMapParams *params = light->getExtended<ShadowMapParams>();
    if ( params )
        mCurrentShadowMap = params->getShadowMap();
    else
        mCurrentShadowMap = NULL;
}
コード例 #2
0
bool AdvancedLightManager::setTextureStage(  const SceneData &sgData,
                                             const U32 currTexFlag,
                                             const U32 textureSlot, 
                                             GFXShaderConstBuffer *shaderConsts, 
                                             ShaderConstHandles *handles )
{
   LightShadowMap* lsm = SHADOWMGR->getCurrentShadowMap();

   // Assign Shadowmap, if it exists
   LightingShaderConstants* lsc = getLightingShaderConstants(shaderConsts);
   if ( !lsc )
      return false;

   if ( lsm && lsm->getLightInfo()->getCastShadows() )
      return lsm->setTextureStage( currTexFlag, lsc );


   if ( currTexFlag == Material::DynamicLight )
   {
      S32 reg = lsc->mShadowMapSC->getSamplerRegister();
   	if ( reg != -1 )
      	GFX->setTexture( reg, GFXTexHandle::ONE );

      return true;
   }
   else if ( currTexFlag == Material::DynamicLightMask )
   {
      S32 reg = lsc->mCookieMapSC->getSamplerRegister();
   	if ( reg != -1 && sgData.lights[0] )
      {
         ShadowMapParams *p = sgData.lights[0]->getExtended<ShadowMapParams>();

         if ( lsc->mCookieMapSC->getType() == GFXSCT_SamplerCube )
            GFX->setCubeTexture( reg, p->getCookieCubeTex() );
         else
      	   GFX->setTexture( reg, p->getCookieTex() );
      }

      return true;
   }

   return false;
}
コード例 #3
0
void AdvancedLightBinManager::addLight( LightInfo *light )
{
   // Get the light type.
   const LightInfo::Type lightType = light->getType();

   AssertFatal(   lightType == LightInfo::Point || 
                  lightType == LightInfo::Spot, "Bogus light type." );

   // Find a shadow map for this light, if it has one
   ShadowMapParams *lsp = light->getExtended<ShadowMapParams>();
   LightShadowMap *lsm = lsp->getShadowMap();

   // Get the right shadow type.
   ShadowType shadowType = ShadowType_None;
   if (  light->getCastShadows() && 
         lsm && lsm->hasShadowTex() &&
         !ShadowMapPass::smDisableShadows )
      shadowType = lsm->getShadowType();

   // Add the entry
   LightBinEntry lEntry;
   lEntry.lightInfo = light;
   lEntry.shadowMap = lsm;
   lEntry.lightMaterial = _getLightMaterial( lightType, shadowType, lsp->hasCookieTex() );

   if( lightType == LightInfo::Spot )
      lEntry.vertBuffer = mLightManager->getConeMesh( lEntry.numPrims, lEntry.primBuffer );
   else
      lEntry.vertBuffer = mLightManager->getSphereMesh( lEntry.numPrims, lEntry.primBuffer );

   // If it's a point light, push front, spot 
   // light, push back. This helps batches.
   Vector<LightBinEntry> &curBin = mLightBin;
   if ( light->getType() == LightInfo::Point )
      curBin.push_front( lEntry );
   else
      curBin.push_back( lEntry );
}