Jump to content
  • Advertisement
Sign in to follow this  
belfegor

[DX9][C++] HW ShadowMaps

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

How to check wheter device/driver supports hardware shadow maps? I do this on my nvidia 9800gt:
D3DFORMAT smFormat = D3DFMT_R32F;
	D3DFORMAT zFormat  = D3DFMT_D24X8;
	hr = gD3D9->CheckDeviceFormat(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL,  DisplayMode.Format, D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_TEXTURE, zFormat);
	if(FAILED(hr))
	{
		MessageBox(0, L"error message", 0, 0);
		return false;
	}
	hr = gD3D9->CheckDepthStencilMatch(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, DisplayMode.Format, smFormat, zFormat);
	if(FAILED(hr))
	{
		MessageBox(0, L"error message", 0, 0);
		return false;
	}

And if this passes i pass zBuffer as texture to shader and use tex2Dproj(ssamp, tc.xyzw) Is this correct way? Is this valid for ATI cards or there is something else, and if how?

Share this post


Link to post
Share on other sites
Advertisement
That sounds right for Nvidia. It's a bit different on ATI GPU's...but it's all documented here.

Share this post


Link to post
Share on other sites
Thanks for the link. I have tried (from the paper) dummy/null
rt on nvidia (to save mem) and it works:


#define FOURCC_NULL ((D3DFORMAT)(MAKEFOURCC('N','U','L','L')))

hr = gD3D9->CheckDeviceFormat(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, DisplayMode.Format, D3DUSAGE_RENDERTARGET, D3DRTYPE_SURFACE, FOURCC_NULL);
if(FAILED(hr))
{
MessageBox(0, L"error message", 0, 0);
}

hr = gD3D9->CheckDepthStencilMatch(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, DisplayMode.Format, FOURCC_NULL, zFormat);
if(FAILED(hr))
{
MessageBox(0, L"error message", 0, 0);
return false;
}

hr = gD3D9Device->CreateRenderTarget(SMAP_SIZE, SMAP_SIZE, FOURCC_NULL, D3DMULTISAMPLE_NONE, 0, FALSE, &gDummySurf, 0);
if(FAILED(hr))
{
MessageBox(0, L"error message!!!", 0, 0);
return false;
}

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!