Sign in to follow this  
akira32

generate a shadow map and modify the viewport

Recommended Posts

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();

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this