Sign in to follow this  
belfegor

[DX9][C++] HW ShadowMaps

Recommended Posts

belfegor    2834
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
belfegor    2834
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this