Skip to main content
gamedev.net
🔒 Locked

Shadowmapping render order

Started by sipickles 0 replies 250+ views
Original Post
sipickles
sipickles
Hi I am battling against a non functional shadow mapping routine! I havent even got as far as the shadow, I'm still trying to get the render target to work! I think I am a bit confused about the order of things. Is this right?

g_device->BeginScene();
g_device->GetRenderTarget( 0, &m_backBuffer );  // save the back buffer
g_device->GetDepthStencilSurface( &m_zBuffer );  // save the depth buffer
g_device->SetRenderTarget(0, m_shadowSurface );  // switch to shadow render target
g_device->SetDepthStencilSurface( m_shadowZBuffer ); // switch to shadow depth buffer

// clear the rendertarget ( the shadow map render target )
g_device->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xFFFFFFFF, 1.0f, 0);
// Set the technique
g_shadowEffect->SetTechnique( "techShadow" );  // from softshadows article on gamedev.net
g_shadowEffect->SetMatrix( "g_matLightViewProj", &m_lightViewProjMatrix );

// Render the effect
UINT uPasses = 0;
g_shadowEffect->Begin( &uPasses, 0 );

g_shadowEffect->BeginPass( 0 );

//RENDER OBJECTS using g_shadowEffect

g_shadowEffect->EndPass();

// End the effect
g_shadowEffect->End();
	
g_device->SetRenderTarget(0, m_backBuffer );  // switch back
g_device->SetDepthStencilSurface( m_zBuffer );

g_device->SetTransform( D3DTS_VIEW, &m_normalViewMatrix );

// clear the back buffer
g_device->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER | D3DCLEAR_STENCIL, D3DCOLOR_ARGB(255, 255, 255, 255), 1.0f, 0);
g_simulation->Render();  // render the objects properly
g_guiManager->Render();  // render the GUI

g_device->EndScene();			
g_device->Present( NULL, NULL, NULL, NULL );

Is this right, only having a single beginscene/endscene/present, even tho one half is to the shadowmap rendertarget and the other to the back buffer? My shadow map remains plain white.... nothing is being rendered to it! Thanks for you advice Simon

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.