Skip to main content
GameDev.net gamedev.net
🔒 Locked

MSAA + render to texture

Started by Groove Oct 3, 2008 at 11:22 AM 1 replies 3.1k views
Original Post
Groove
Groove
Hi, as far as I have understand, D3D9 doesn't support MSAA when rendering in a texture. Well, fair enough, I don't mind! However were it's a problem for me it's when I use MSAA to render in the framebuffer and I get an error when I render in a texture in a two passes process. First pass, I render to a texture and get and error at clear function call: "MultiSampleType between DepthStencil Buffer and RenderTarget must match." Second pass, I render to the framebuffer. If I just apply the second pass I have no error and the anti aliasing works. (but doesn't really looks good enough...) Thanks again!
[size="2"]G-Truc Creation - www.g-truc.net
Groove
Groove
I have actually fixed this problem by by creating a depth texture and using it during the render to texture process as depth texture.

However there is something I don't get...

This is my function to create a Render to surface object.

LPD3DXRENDERTOSURFACE CreateFramebuffer(
unsigned const & Width,
unsigned const & Height,
D3DFORMAT const & Format)
{
LPD3DXRENDERTOSURFACE RenderToSurface = NULL;

HRESULT hr = D3DXCreateRenderToSurface(
g_pd3dDevice,
Width,
Height,
Format,
TRUE,
D3DFMT_D24S8,//D3DFMT_D24FS8,
&RenderToSurface);

if(FAILED(hr))
MessageBox(NULL, "", "Framebuffer loading error", MB_OK | MB_ICONEXCLAMATION);

return RenderToSurface;
}

the parameter TRUE from D3DXCreateRenderToSurface say "the render surface supports a depth-stencil surface". What does it means? I MUST attach a depth texture or I MAY attach a depth texture. Because I wasn't using a depth texture before and I didn't get an error...

Thanks

[size="2"]G-Truc Creation - www.g-truc.net
MJP
MJP
If you want to render to a multi-sampled render target, use IDirect3DDevice9::CreateRenderTarget and specify the size, format, and multisample type you want. Then create a render target texture using IDirect3DDevice9::CreateTexture that has the same size and format as the surface you just created. Render to the multisampled surface, then use IDirect3DDevice9::StretchRect to resolve the multisampled surface to a normal texture that you can sample.

The error message you're getting is because you can't use a multisampled render target with a non-multisampled depth buffer. They need to be created with the same number of samples and quality setting.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.