XNA UK User Group
A helping hand for bedroom coders throughout the land.
Generic XNA - Ocean II

Blogs

RandomChaos

Syndication

"Water, Water everywhere and not a drop to drink..."

http://www.youtube.com/v/dp1wC53S4XA <p><a href="http://www.youtube.com/v/dp1wC53S4XA">http://www.youtube.com/v/dp1wC53S4XA</a></p>

Yes more water. This is the fix to my original Ocean class. I found a fair few errors in the class, the shader was fine, just me as usual. As you can see the performance is better and is comparable with Anirudh S Shastry's shader I posted last time.

Not much else to add so you can locate the solution here.


Posted Mon, May 5 2008 9:00 PM by Nemo Krad
Filed under: , ,

Comments

GameDevKicks.com wrote Ocean II
on Mon, May 5 2008 10:23 PM

You've been kicked (a good thing) - Trackback from GameDevKicks.com

brainziziz wrote re: Generic XNA - Ocean II
on Sat, May 10 2008 4:40 PM

Hi! I must tell you the performance boost is very arguable... In fact, I think there is a considerable performance drop. Try scaling it up a bit, like 1024, 1, 1024... Then reset the scale and put Width and Height to 1024x1024... Then do the same with the first shader....

Nemo Krad wrote re: Generic XNA - Ocean II
on Mon, May 12 2008 8:53 AM

Well my test was with the system I have posted, I have not done any extensive perf testing with the two methods.

Thanks for taking the time to check it out.

Steven Linton wrote re: Generic XNA - Ocean II
on Thu, May 15 2008 12:22 PM

Hi,

I really like this shader. I used an earlier version and it would crash out my XBox, this one doesn't.

I was wondering if there is an easy way for me to make the water semi-transparent?

Cheers.

ps. Still eagerly awaiting the cloud volume example code :)

Nemo Krad wrote re: Generic XNA - Ocean II
on Thu, May 15 2008 12:41 PM

The shader it's self is unchanged from the previous post, it's the Ocean class that has been fixed.

I also got the 360 crash when I played it on my XBox, I did fix it at the time, but never got around to posting it.

 If you look at the old version in the Draw method there is the method to make the water transparent.

My CC account has ran out now so I can't test my samples on the 360, so it's good to know this version is fine on the 360 thanks :)

The cloud system I have some performance issues with at the moment, but it may just be my crappy GCard now that I have moved the shader over to use alphas. I am a bit stumped as to why I am getting the perf hit so might end up posting the system anyway and see if the community can help improve it.

JohnK wrote re: Generic XNA - Ocean II
on Mon, May 19 2008 1:54 PM

Hello Nemo! Thanks for sample, it's awesome. But i have some bug, when adding another game component. ( like fps counter )

So, here, ru.ziggyware.com/.../oceanii.zip

If you comment  this:

SkyBox sb = new SkyBox(this, "Models/skybox", "Shaders/skybox", skyBoxTexture);

Components.Add(sb);

- you will see the uncorrect waves. How to fix that? Thank you!

Nemo Krad wrote re: Generic XNA - Ocean II
on Mon, May 19 2008 2:25 PM

Thanks for posting this up. I know exactly what the issue is as I have had it with other samples I have written once I have started to use them with other things.

When I start writing a sample there is nothing else in the scene, I add a skybox (note in the shaders the first few elements of the vert struct a the same) and all looks well, until you do something like this. The fundamental error I am making is leaving my Vertex declaration in the LoadContent of the OceanII class, if you move this to the top of the Draw call it should work fine then.

The reason why the sky box makes it all work is that it is setting the vertex declaration and the vert structure is similar and so the shader (by luck) behaves. But when you remove it or put another object before and/or after it in the draw sequence, then you get odd things happening.

This may be an issue with other samples of mine to. I wont fix them as I intend to put them all together into some sort of engine, that way I will find all the issues like this and with any luck have a nice working engine.

Hope this helps,

See you on IRC ;P

Mike wrote re: Generic XNA - Ocean II
on Fri, Sep 26 2008 8:12 AM

I have a little question about reflection for your ocean class:

currently, you're reflecting the cubemap of the skybox.

But how would you do to reflect an island in the water?

Nemo Krad wrote re: Generic XNA - Ocean II
on Fri, Sep 26 2008 8:47 AM

Hi Mike,

Well, you have a few options, first one is to create the cubemap texture at run time and pass that to the shader.

You could also use the technique that Riemner implements where you draw the reflected scene elements and then use that which you can find here: www.riemers.net/.../Reflection_map.php

Or, and i think this is the what I am going to try and implement in the future, use Dual-Paraboloid Reflections, a great example of which can be found on GraphicsRunners (Kyle's) blog here : graphicsrunner.blogspot.com/.../dual-paraboloid-reflections.html

Mike wrote re: Generic XNA - Ocean II
on Mon, Sep 29 2008 2:29 PM

OK, thanks for your answer, I'll investigate a bit with the paraboloid reflections.

I'va already tried the Riemers' reflection, but I couldn't get something satisfying, so I was looking for something else.

Hannes wrote re: Generic XNA - Ocean II
on Mon, Dec 1 2008 8:39 AM

My long search for a good ocean shader is finally over, I used this in my game and it looks great!

Thanks heaps.

Achilleterzo wrote re: Generic XNA - Ocean II
on Wed, Dec 16 2009 10:04 AM

Hi and great work!

My question is simple, what about fog for that?

Nemo Krad wrote re: Generic XNA - Ocean II
on Wed, Dec 16 2009 11:24 AM

It will be the same implementation as any other fog calculation :)

Quickstick4 wrote re: Generic XNA - Ocean II
on Tue, May 4 2010 6:37 AM

Just in case anyone is using this fantastic class and shader and is playing around with the settings;  the "fBumpHeight" must be a value greater than '0.01f' otherwise you get an interesting 'jump' of the water every 100 gameTime seconds!

Thanks again.