Jump to content
  • Advertisement
Sign in to follow this  
GMano

Hardware Shadow Mapping Question

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

I am using the Hardware Shadow Mapping using NVidia graphics card on my project, and it works fine. However, I am using quite a large shadow map, and I am forced to create a render target texture in addition to the depth texture in order to render to the depth buffer. The memory for this texture is just wasted, as I am only rendering the depth (calling SetRenderState(D3DRS_COLORWRITEENABLE, 0)) before rendering to the shadow map). Is there any way around this, or do you have to create a render target texture that you do not use in order for the hardware shadow mapping to work?

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by GMano
I am using the Hardware Shadow Mapping using NVidia graphics card on my project, and it works fine. However, I am using quite a large shadow map, and I am forced to create a render target texture in addition to the depth texture in order to render to the depth buffer. The memory for this texture is just wasted, as I am only rendering the depth (calling SetRenderState(D3DRS_COLORWRITEENABLE, 0)) before rendering to the shadow map). Is there any way around this, or do you have to create a render target texture that you do not use in order for the hardware shadow mapping to work?


You can create a NULL rendertarget.

First you check that the device currently supports the NULL format for rendertargets (make sure to check return value and fall back to regular format if that's not supported !):

HRESULT hr = pD3D->CheckDeviceFormat( D3DADAPTER_DEFAULT, 
D3DDEVTYPE_HAL,
AdapterFormat,
D3DUSAGE_RENDERTARGET,
D3DRTYPE_SURFACE,
(D3DFORMAT)MAKEFOURCC('N','U','L','L') );


Then if supported, you create the NULL RT :

HRESULT hr = pD3dDevice->CreateRenderTarget(sizex,
sizey,
(D3DFORMAT)MAKEFOURCC('N','U','L','L'),
D3DMULTISAMPLE_NONE /* use the DepthStencil buffer multisampling type here*/,
0 /* use the DepthStencil buffer multisample quality here */,
false /* certainly not lockable */,
&pNullSurface /* pointer to the surface you're creating */,
NULL /* HANDLE);


You should use the depth buffer sizex and sizey, it doesn't matter to the driver but it may matter to the runtime (especially debug), so choose the right dimension to be on the safe size. In practice it will not take any significant video memory.

Then you set it as you would any rendertarget.

HRESULT hr = pD3dDevice->SetRenderTarget(0, pNullSurface);


Also if you use a NULL RT you don't need to set the color write enable mask to 0 because it is implied.

LeGreg

[Edited by - LeGreg on July 23, 2008 11:07:26 PM]

Share this post


Link to post
Share on other sites
Quote:
Original post by LeGreg

You can create a NULL rendertarget.

First you check that the device currently supports the NULL format for rendertargets (make sure to check return value and fall back to regular format if that's not supported !):

*** Source Snippet Removed ***
Then if supported, you create the NULL RT :

*** Source Snippet Removed ***
You should use the depth buffer sizex and sizey, it doesn't matter to the driver but it may matter to the runtime (especially debug), so choose the right dimension to be on the safe size. In practice it will not take any significant video memory.

Then you set it as you would any rendertarget.

*** Source Snippet Removed ***
Also if you use a NULL RT you don't need to set the color write enable mask to 0 because it is implied.

LeGreg


Thank you! This worked like a charm.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!