Exemple #1
0
 void LightManager::addLight(const LightSourcePtr& light) {
     switch(light->type()) {
     case LS_Directional: mDirectionalLights.push_back(light); break;
     case LS_Spot:        mSpotLights.push_back(light); break;
     case LS_Point:       mPointLights.push_back(light); break;
     }
 }
Exemple #2
0
    void LightManager::renderShadowMap(GraphicDevice& gd, SceneManager& scene, const LightSourcePtr& ls) {
        const RenderTargetPtr& rt = ls->getShadowMap();
        EffectTechniquePtr techniuqe;
        if(ls->type() == LS_Directional)
            techniuqe = mDepthMapTechnique;
        else
            techniuqe = mEXPDepthMapTechnique;

        mShadowMapRT->attach(ATT_Color0, ls->getShadowMap());
        mShadowMapRT->attach(ATT_DepthStencil, 
                             ls->getDSView());

        mShadowMapRT->attachToRender();

        gd.clear(CM_Color | CM_Depth, color::Transparent, 1.0f, 0);

        Shader* fragmentShader = mDepthMapTechnique->getPass(0)->getFragmentShader().get();
        fragmentShader->setFloatVectorVariable("lightPosition", ls->getPosition());
        
        const CameraPtr& cam = ls->getCamera(0);
        fragmentShader->setFloatVariable("depthPrecision", cam->getFarPlane());

        scene.render(techniuqe, cam->getViewMatrix(), cam->getProjMatrix(), ~SOA_NotCastShadow);

        mShadowMapRT->detachFromRender();
    }
Exemple #3
0
 void LightManager::removeLight(const LightSourcePtr& light) {
     switch(light->type()) {
     case LS_Directional: mDirectionalLights.erase(std::remove(mDirectionalLights.begin(),
                                                               mDirectionalLights.end(),
                                                               light),
                                                   mDirectionalLights.end()); break;
     case LS_Spot:        mSpotLights.erase(std::remove(mSpotLights.begin(),
                                                        mSpotLights.end(),
                                                        light),
                                            mSpotLights.end()); break;
     case LS_Point:       mPointLights.erase(std::remove(mPointLights.begin(),
                                                         mPointLights.end(),
                                                         light),
                                             mPointLights.end());
     }
 }