XNA Creators Club Online
Page 1 of 1 (2 items)
Sort Posts: Previous Next

Problems with Distortion kit

Last post 21/05/2009 0:22 by Wipeless. 1 replies.
  • 16/09/2008 22:26

    Problems with Distortion kit

    Hello, I'm trying to use distortion for my game. However I can't seem to draw objects in front of the distortion section:



    As you can see, the cube started off the same size as my distortion box. But when I move it in front, the distortion effect still occurs.
    Any suggestions? Also, I wanted to quickly throw in anti aliasing into the distortion sample kit by simply putting:

    graphics.PreferMultiSampling = true;

    in my constructor. But if you try doing this, all the distorted parts have a very annoying outline. I was looking at this link (http://forums.xna.com/forums/t/12392.aspx) to throw anti aliasing on my models and not on my distorted parts, but if anyone has any other suggestions I'd really appreciate it.
  • 21/05/2009 0:22 In reply to

    Re: Problems with Distortion kit

    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.
Page 1 of 1 (2 items) Previous Next