How to create a new render target with antialiasing (FSAA)?

Started by
3 comments, last by Mezz 18 years, 8 months ago
Hi, Some effect I am doing in DirectX9 (HDR lighting but doesn't really matter for this issue) requires a second render target. But I need to keep antialising/FSAA (MULTISAMPLE_xx) support. If I create the second render target with CreateTexture, I cannot specify any multisample type. If I create it with CreateRenderTarget it is possible but I only get a D3Dsurface, not a D3DTexture which I need.. Surely this is pretty simple and possible? I mean a lot of effects require a second render target? (I just need to render the scene to the custom render target first with FSAA, apply some effects and render it to the backbuffer.) Thanks for any ideas, Mark
Advertisement
To be honest I can't remember the finer points of which combinations do work... but there are general issues with having multisample/AA'd render targets - in some cases it's just plain not allowed, and in other cases it's driver dependent (and I don't think theres good support across the board).

You might well find that it's just not possible to do what you want [sad]

hth
Jack

<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ]</small>

Thanks. But having a render target is really, really common for fx. And FSAA is mandatory nowadays. There must be a way to do both.

If you create a render target with ->CreateRenderTarget(), this returns a surface for which you can enable FSAA; but how can you use it as a texture? I mean, set it in texture stage 0, set some special fx texture in stage 1, etc.

Does anyone know?
I believe this is posible, first you have to create the render surface how you said, so then you have a D3DSurface, then you also must create a texture using:

Deivce->CreateTexture(width, height, usage, format, pool, IDirect3DTexture9 **ppTexture, HANDLE *pSharedHandle)


this will give you a texture but after creating the texture you have to add this

Texture->GetSurfaceLevel(0, &your suface)


then when you render

Device->SetRenderTarget(0, your surface);

then clear and render whatever you want, after that

Device->SetRenderTarget(0, backbuffer);

and just render your texture to the backbuffer, it will contain what you rendered to your surface

just to let you know, i have done this beore and it does work, but i don't know if it works with your shader
This is the only way I know of doing it.

1) Create your render target using CreateRenderTarget() with FSAA and render to it as you would expect.

2) Create a texture using CreateTexture() specifying the D3DUSAGE_RENDERTARGET flag.

3) StretchRect() your render target from (1) to your texture created in (2).

-Mezz

This topic is closed to new replies.

Advertisement