Sign in to follow this  

Texture RT with Multisampling

This topic is 4339 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 wondering if it is possible to render to a texture with multisampling enabled. I would like to do so because my post-processing scheme requires that I render the scene to a texture so that it can be passed to an HLSL pixel shader, but I still want the scene to be anti-aliased. Unfortunately, there is no Texture constructor to set up multisampling, and Device.CreateRenderTarget only returns a generic Surface. Alternatively, if it is possible to sample a generic Surface in HLSL, this will also serve my intentions. I would love to hear any other possible solutions to this issue (I hope I am explaining it sufficiently). Thanks in advance.

Share this post


Link to post
Share on other sites
IIRC, it is not possible to multi-sample an RT-texture. I'm not quite sure of the specifics of why not, but perhaps it has to do with you being able to feed the same surface back in as shader input.

Here is a self-antialiasing pixel shader I found though.

Share this post


Link to post
Share on other sites
Thanks for the reply (not what I was hoping to hear, but what can you do...). In light of this new info, does anyone know how to copy the contents of a generic Surface onto the top-level surface of a Texture?

My thought is that I can render my scene with a normal RT (multisampling enabled) then copy the contents onto the Surface of my Texture and pass to the post processor. Is this a reasonable idea in terms of performance to achieve post processing with anti-aliasing?

janoside

Share this post


Link to post
Share on other sites
I've been rendering to a multisampled backbuffer and then copying to a rendertarget using StretchRect(), which is hardware accelerated on DX9 cards, and filters the image if it's not a straight copy. For most post processing effects you work with a downsampled copy anyway (bloom, blur etc) so it works very well. Also the original is still on the backbuffer for combination at the end of an effect with alpha blending. The nvidia sdk has a sample called 'Antialiasing with Postprocessing'. I didn't do any tests on the performance but the nvidia docs claim it's very fast(if supported in hardware). Here's the function call:

hr = g_pd3dDevice->StretchRect( pBackBuffer, &sourceRect, RT1Surface, &destRect, D3DTEXF_LINEAR );


Check the docs on that one, there's a ton of special cases and caps that you have to check.

Note that the effect circlesoft linked to requires ps2a because of the ddx and ddy functions.

Share this post


Link to post
Share on other sites

This topic is 4339 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.

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