Hi,
I'm having some questions regarding DX9, rendertargets and MSAA for which I cannot really find an answer for. Strangely enough, documentation regarding those subjects is rather sparse.
I have implemented a Light pre-pass renderer (or Deferred Lighting, like most people call it nowadays) for a DX9 platform. No problems there but trying to enable MSAA is giving me a headache, unfortunatly.
My pipeline is build from three steps:
- Render all objects to a rendertarget that stores two component view-space normals.
- Fill a light accumulation buffer, using the normals from the previous step (as a fullscreen stretched texture).
- Render all objects again, using the light accumulation buffer from the previous step (again, as a fullscreen stretched texture).
To be able to support MSAA, those three steps each need to render to an MSAA enabled rendertarget.
Creating an MSAA-enabled DX9Surface is not a problem via DX9Device::CreateRenderTarget, but since I cannot create an MSAA texture (CreateRenderTarget only gives me an MSAA surface) I have to StretchRect my surface to the texture, before I can use my rendertarget data into each of the next pipeline-stages.
Because that texture doesn't have msaa surfaces, doing a StretchRect basically downsamples the MSAA content from the rendertarget.
Ofcourse problems start to arise the moment I want to use that non-msaa texture further in my pipeline: I see a lot of artefacts around the borders of my objects.
I can imagine that while rendering to an MSAA rendertarget while sampling from non-msaa fullscreen stretched texture can give such problems, because of some kind of undersampling going on behind the scenes.
I hope my explanation is clear enough, but I really don't see a solution to this and I fear I simply cannot support MSAA like this on DX9 hardware. Is that correct?
Thanks a lot in advance!
I'm having some questions regarding DX9, rendertargets and MSAA for which I cannot really find an answer for. Strangely enough, documentation regarding those subjects is rather sparse.
I have implemented a Light pre-pass renderer (or Deferred Lighting, like most people call it nowadays) for a DX9 platform. No problems there but trying to enable MSAA is giving me a headache, unfortunatly.
My pipeline is build from three steps:
- Render all objects to a rendertarget that stores two component view-space normals.
- Fill a light accumulation buffer, using the normals from the previous step (as a fullscreen stretched texture).
- Render all objects again, using the light accumulation buffer from the previous step (again, as a fullscreen stretched texture).
To be able to support MSAA, those three steps each need to render to an MSAA enabled rendertarget.
Creating an MSAA-enabled DX9Surface is not a problem via DX9Device::CreateRenderTarget, but since I cannot create an MSAA texture (CreateRenderTarget only gives me an MSAA surface) I have to StretchRect my surface to the texture, before I can use my rendertarget data into each of the next pipeline-stages.
Because that texture doesn't have msaa surfaces, doing a StretchRect basically downsamples the MSAA content from the rendertarget.
Ofcourse problems start to arise the moment I want to use that non-msaa texture further in my pipeline: I see a lot of artefacts around the borders of my objects.
I can imagine that while rendering to an MSAA rendertarget while sampling from non-msaa fullscreen stretched texture can give such problems, because of some kind of undersampling going on behind the scenes.
I hope my explanation is clear enough, but I really don't see a solution to this and I fear I simply cannot support MSAA like this on DX9 hardware. Is that correct?
Thanks a lot in advance!