Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

jeppa

Display Shadow Map

This topic is 5747 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

hi!in my engine,i would want diplay the texture used for shadow map as 2d poligon.in this time if i display my "texture shadow map",the final result is white poligon..why?? what is the right way to diplay the "texture" used for shadow-map?? Thanks in advance

Share this post


Link to post
Share on other sites
Advertisement
I guess you mean you want to render a shadowmap just like projected shadows right?!
In that case you render a primitive with the shadowmap on top of the rendered geometry.
you should use alpha blending for this and make sure the colors of your shadow map are multiplied with the destination color.

If your polygons are brightwhite then there is something wrong. The texture should be white with the (black) shadow rendered in it. Check if your texture coordinates are right. Or try rendering the texture to screen in a rectangle so that you can check if the texture realy contains a shadow

Share this post


Link to post
Share on other sites
Are you saying that your shadow mapping algorithm currently works but that you''re just having trouble displaying the shadow map or are you saying that your shadow mapping doesn''t work yet?

For now, I''ll assume that your shadow mapping algorithm works and that you''re just having trouble displaying the shadow map. One thing you can do is when your app is about to exit, save the shadow map to a .bmp file using D3DXSaveTextureToFile and see if the output looks good.

If you''re having problems with the shadow mapping algorithm, I would suggest you take a look at the nVidia and ATI developer websites. nVidia has a white paper that explains how to do shadow mapping. You can find this at http://developer.nvidia.com/object/shadow_mapping.html

ATI has a DX9 sample app that implements shadow mapping using shaders. You can find this at http://www.ati.com/developer/samples/dx9/ShadowMap.html

Hope this helps,
neneboricua

Share this post


Link to post
Share on other sites
my shadow-map routine doesn''t work yet.i''m trying to diplay shadow-map for find my errors.but it''s white!!!
D3DXSaveTextureToFile doesn''t work with depth-stencil texture...

which will the final looks of my shadow-map??

in my engine,projective texture work fine(it''s used fo projective texture and projective shadow).

Share this post


Link to post
Share on other sites
Have you looked at the two links I posted above? They really do give you all the information you need to do shadow mapping.

By the way, if your app is running on Nvidia hardware then you can keep using the depth stencil directly. But if your app is going to run on an ATI card as well, you''re gonna have to use a specific render target instead of the depth stencil. Check out this thread as well http://www.gamedev.net/community/forums/topic.asp?topic_id=180969

There could be a couple of different things wrong with your code. There''s not really much the people on the board can do if all you say is "my shadow map is white." Do you have any idea as to where the problem might be? Perhaps there are some steps of the algorithm that aren''t totaly clear to you? One thing that gave me a few problems when I implemented this was getting the view matrix for the light to be correct. Could that be your problem?

If you''re haivng a hard time conceptually with part of the algorithm we can try and help out but you''re gonna have to give some more details and list the things you''ve tried, what you understand and what you don''t. A good starting place is the white paper from Nvidia. That will help you understand all the steps. Then the sample app from ATI should fill in all the details as to how to do it with DirectX9.

neneboricua

Share this post


Link to post
Share on other sites
ok.sorry for my short question.my first problem is:

i would save in a file my depth map,costructed by render to texture.but D3DXSaveTextureToFile doesn''t work

Share this post


Link to post
Share on other sites
quote:
Original post by neneboricua19
Have you looked at the other thread that I posted? Have you looked at the Nvidia white paper and the ATI sample?



yes,I looked at Nvidia and Ati white paper...

but in this papers doens''t find the way to save shadow depth map


Share this post


Link to post
Share on other sites
If you''re creating the shadow map as a texture, then you should be able to call D3DXSaveTextureToFile. Here is how you are supposed to create the shadow map:

// Create shadow mapping texture as a render target

if( FAILED( hr = D3DXCreateTexture( m_pd3dDevice, m_iShadowMapWidth, m_iShadowMapHeight, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8B8G8R8, D3DPOOL_DEFAULT, &m_pShadowTexture ) ) )
return DXTRACE_ERR_MSGBOX( "D3DXCreateTexture", hr );

// Get a pointer to the "surface" of the shadow mapping texture

if( FAILED( hr = m_pShadowTexture->GetSurfaceLevel( 0, &m_pShadowTextureSurface ) ) )
return DXTRACE_ERR_MSGBOX( "GetSurfaceLevel", hr );

// Create a depth buffer (Z-buffer) for the shadow mapping surface

if( FAILED( hr = m_pd3dDevice->CreateDepthStencilSurface( m_iShadowMapWidth, m_iShadowMapHeight, D3DFMT_D24S8, D3DMULTISAMPLE_NONE, 0, TRUE, &m_pShadowZBuffer, NULL ) ) )
return DXTRACE_ERR_MSGBOX( "CreateDepthStencilSurface", hr );

If you create your shadow map this way, and set your render target to be "m_pShadowTextureSurface" and your depth stencil to be "m_pShadowZBuffer", then you shouldn''t have any problems. Remember that the depth information you are going to use is in the shadow TEXTURE (i.e. the render target) not the actual z-buffer. Using the actual Z-Buffer directly to get your depth information will only work on Nvidia cards. But if you do it the way I''m describing, it will work on any DX9 (and DX8 as well) card.

If you do this, then you shouldn''t have any problems saving the shadow texture to a file. The code above was cut-n-pasted from an app that I''m currently writing that runs on both Nvidia and ATI hardware.

neneboricua

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!