XNA Creators Club Online
Page 1 of 1 (1 items)
Sort Posts: Previous Next

generate a shadow map and modify the viewport

Last post 11/11/2008 12:02 PM by akira32. 0 replies.
  • 11/11/2008 12:02 PM

    generate a shadow map and modify the viewport

    Should I modify the viewport's size as the shadow map'size when I render scene into a shadow map?

    void RenderTexture::EnableRendering(void)  
    {  
      // Store original values  
      //  
      GetApp()->GetDevice()->GetViewport(&m_OldViewport);  
      GetApp()->GetDevice()->GetRenderTarget(0,&m_pOldRenderTarget);  
      GetApp()->GetDevice()->GetDepthStencilSurface(&m_pOldDSSurface);  
     
      // Set new values  
      //  
      GetApp()->GetDevice()->SetViewport(&m_Viewport);  
      GetApp()->GetDevice()->SetRenderTarget(0,m_pSurface);  
      GetApp()->GetDevice()->SetDepthStencilSurface(m_pDSSurface);  
    }  
     
        // Enable rendering to shadowmap  
        //  
        _ShadowMapTexture.EnableRendering();  
     
     
        // Clear the shadowmap  
        //  
        GetApp()->GetDevice()->Clear(0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER, 0xFFFFFFFF, 1.0f, 0);  
     
     
        // Set up shaders  
        //  
        // To hide artifacts, only render back faces of the scene  
        //  
        _pEffect->SetTechnique("RenderShadowMap");  
     
     
        // Render the scene to the shadowmap  
        //  
        RenderScene(_mLightView,_mLightProj);  
     
     
        // Go back to normal rendering  
        //  
        _ShadowMapTexture.DisableRendering(); 
Page 1 of 1 (1 items) Previous Next