I solved the draw order of my objects with the distortion effect (played around with draw order and depth buffer).
Going back and trying to finally work this out the anti aliasing problem I was having.
Here's the concept I'm working at:
1. Create a default RenderTarget2D and DepthStencilBuffer which has Anti Aliasing.
2. Create a second RenderTarget2D and DepthStencilBuffer which has no Anti Aliasing.
3. Render the distortions with the no Anti Aliasing rendertarget and DepthStencilBuffer .
4. Return to the default rendertarget and DepthStencilBuffer .
5. Render the rest of my scene.
Does this sound like a good strategy?
Right now, I'm banging my head on just getting a simple model to render using different render targets.
Here is how I declare my variables:
| noAADepthStencilBuffer = new DepthStencilBuffer(device, |
| graphics.PreferredBackBufferWidth, |
| graphics.PreferredBackBufferHeight, |
| device.DepthStencilBuffer.Format, |
| MultiSampleType.None, 0); |
| DefaultDepthStencilBuffer = device.DepthStencilBuffer; |
| |
| noAARenderTarget = new RenderTarget2D( device, |
| graphics.PreferredBackBufferWidth, |
| graphics.PreferredBackBufferHeight, |
| 1, device.DisplayMode.Format, MultiSampleType.None, 0); |
| DefaultRenderTarget = new RenderTarget2D( device, |
| graphics.PreferredBackBufferWidth, |
| graphics.PreferredBackBufferHeight, |
| 1, device.DisplayMode.Format); |
Here is how my Draw looks like:
| device.Clear(ClearOptions.Target | ClearOptions.DepthBuffer, Color.CornflowerBlue, 1.0f, 0); |
| |
| device.DepthStencilBuffer = noAADepthStencilBuffer; |
| device.SetRenderTarget(0, noAARenderTarget); |
| device.Clear(ClearOptions.Target | ClearOptions.DepthBuffer, Color.CornflowerBlue, 1.0f, 0); |
| |
DrawModel(ground, groundMat); //Trying to Draw this model without anti aliasing.
|
| |
| device.SetRenderTarget(0, null); |
| device.DepthStencilBuffer = DefaultDepthStencilBuffer; |
The problem I'm running into is that I'm just getting a purple screen. I thought I was changing rendertargets correctly but I've been stuck on this all day. Not quite sure what I'm doing wrong since most tutorials look similar to this. Any help would be greatly appreciated.