Jump to content

  • Log In with Google      Sign In   
  • Create Account


Simple shadow map antialiasing?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
24 replies to this topic

#21 MJP   Moderators   -  Reputation: 10264

Like
0Likes
Like

Posted 20 May 2013 - 03:00 PM

If you use a sampler state with D3D11_FILTER_COMPARISON_MIN_MAG_MIP_LINEAR, the hardware will automatically perform 2x2 PCF when you call SampleCmp.



Sponsor:

#22 george7378   Members   -  Reputation: 1133

Like
0Likes
Like

Posted 20 May 2013 - 04:41 PM

Hmm, interesting - I'm using DX9 though, would I define this in the shader?



#23 Hodgman   Moderators   -  Reputation: 27879

Like
0Likes
Like

Posted 20 May 2013 - 08:41 PM

In D3D9 the procedure is a bit, hacky...

http://aras-p.info/texts/D3D9GPUHacks.html#shadowmap

http://developer.amd.com/wordpress/media/2012/10/Advanced-DX9-Capabilities-for-ATI-Radeon-Cards_v2.pdf

 

You use CreateTexture to make a depth-stencil usage texture with a regular depth format like D24S8, and then you retrieve the surface from that texture to bind it as your depth-stencil target. After drawing to it, you can then bind the texture that you created to your pixel shader, and sample from it as usual (ensuring that linear filtering is enabled on the sampler), except that you put your depth value in the z coordinate of the tex-coords and the hardware will do the PCF for you.



#24 belfegor   Crossbones+   -  Reputation: 2378

Like
0Likes
Like

Posted 21 May 2013 - 03:20 AM

^ In addition to what Hodgman said. That DS surface must be followed by a proper RT, and since we don't use it in this case you might want to save memory by checking if NULL RT is supported (code chopped from my old projects):

#define D3DFMT_NULL      ((D3DFORMAT)(MAKEFOURCC('N','U','L','L')))
 
hr = d3d9->CheckDeviceFormat(adapter, deviceType, displayMode.Format, D3DUSAGE_RENDERTARGET, D3DRTYPE_SURFACE, D3DFMT_NULL);
    if(SUCCEDDED(hr))
    {
        hr = d3d9device->CreateTexture(SMAP_DIM.cx, SMAP_DIM.cy, 1, D3DUSAGE_RENDERTARGET, D3DFMT_NULL, D3DPOOL_DEFAULT, &nullTex, NULL);
        if(FAILED(hr))
...

 

First check if it is supported and then create DS texture:

// D3DFMT_D24X8 we don't need stencil for this
hr = d3d9device->CreateTexture(SMAP_DIM.cx, SMAP_DIM.cy, 1, D3DUSAGE_DEPTHSTENCIL, D3DFMT_D24X8, D3DPOOL_DEFAULT, &smapTex, NULL);
    if(FAILED(hr))
    {
        ...// handle error
    }
    hr = smapTex->GetSurfaceLevel(0, &smapSurface);


#25 george7378   Members   -  Reputation: 1133

Like
0Likes
Like

Posted 21 May 2013 - 04:51 PM

Interesting, but it looks like it would probably take as much effort, if not more, to implement than the current PCF that I use. Also, I understand how the PCF works, and I can't say I get this other method!






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS