Jump to content
  • Advertisement
Sign in to follow this  
akira32

generate a shadow map and modify the viewport

This topic is 3600 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
When you set a render target, the viewport automatically gets set to fit the surface dimensions. You only need to modify the viewport if you need to render to a portion of the target.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!