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

2D Refraction in Xna 2.0

Last post 04-11-2008 11:02 AM by Nick Gravelyn. 3 replies.
  • 04-10-2008 8:29 PM

    2D Refraction in Xna 2.0

    Hi, what I'm trying to do is to follow the sample on ziggyware.com by Nick Gravelyn posted here.

    It's in Xna 1.0 and I want to use refraction for a water technique in 2.0, except I'm kinda a newbie with effects so I can't convert or use the code.  I was wondering how I might do that or possibly just get a better way to do refraction.  The code is all on the link.

    Thanks in advance.
  • 04-10-2008 8:41 PM In reply to

    Re: 2D Refraction in Xna 2.0

    Answer
    It's actually a pretty easy upgrade. Here are the changes that need to be made:

    1) Remove the ContentManager content; instance in the Game1 class.
    2) Add this line to the Game1 constructor:

    Content.RootDirectory = "Content";

    3) Remove "Content/" from all of the load calls.
    4) Make sure all the load calls use the Content (upper case C) property.
    5) Move all of the stuff in the LoadGraphicsContent method (all of the stuff inside the if statement) into the LoadContent method.
    6) Remove all the calls to GraphicsDevice.ResolveRenderTarget.
    7) Remove the UnloadGraphicsContent method entirely.

    All the theory (the important part) still applies. I've also uploaded a new version with all these changes if you want. There are comments in the source: Refraction2D.zip.


    Nick Gravelyn -- Microsoft XNA MVP
    Blog | Metacreature Games | Super Gravelyn Bros | Bloc | Next-Gen
  • 04-11-2008 5:28 AM In reply to

    Re: 2D Refraction in Xna 2.0

    I've never seen this tutorial ! really nice done ! Is it especially for 2d model or can we extend it like the xna sample ?

    cheers
  • 04-11-2008 11:02 AM In reply to

    Re: 2D Refraction in Xna 2.0

    Sueds:
    I've never seen this tutorial ! really nice done ! Is it especially for 2d model or can we extend it like the xna sample ?

    cheers


    Not entirely sure what you're asking. If you mean is this effect only for 2D stuff then the answer is "kind of". My particular implementation only works in 2D, however it's a similar concept in 3D. So with a little work it shouldn't be too hard to get working in 3D.


    Nick Gravelyn -- Microsoft XNA MVP
    Blog | Metacreature Games | Super Gravelyn Bros | Bloc | Next-Gen
Page 1 of 1 (4 items) Previous Next
var gDomain='m.webtrends.com'; var gDcsId='dcschd84w10000w4lw9hcqmsz_8n3x'; var gTrackEvents=1; var gFpc='WT_FPC'; /*<\/scr"+"ipt>");} /*]]>*/
DCSIMG