Sign in to follow this  

Rendering seas

This topic is 4812 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm working on a game that will be using a lot of 'on the high seas' kind of scenes. We're hoping to render 'stormy seas' and 'calm seas'. Most of the action will be in the middle of the ocean rather than coastal, so think larger, smoother waves - but of course, the sea isn't that simple by any means, unless it's really flat and calm. Anyway. So far I have an undulating mesh, where the y (height) values of each vertex are deformed according to a sin function. It's a pretty good start, but is nowhere near as nice looking as I want it to be. Basically I'm aiming for graphics like Far Cry (though less emphasis on reflection and more on wave shapes/patterns), or Pirates XXI Century. I've tried experimenting with pixel shaders, with the intention to implement specular lighting on the waves from the sun. Unfortunately, I got a horrible frame rate when I rendered with a really simple pixel shader; definitely partly because my graphics card is a crappy laptop onboard, but also I'm theorising, because the fill rate is prohibitive. Does that sound right - is using pixel shaders on a really large area of the screen a bad idea? Are they better suited to small details here and there? Finally, does anyone have any suggestions or links I could look at regarding rendering real-time waves - preferably not the transparency/reflectivity of land features side of things, since that's not really what I'm focusing on. :) Thanks a lot!

Share this post


Link to post
Share on other sites
Do you mean, if my card supports pixel shaders in the hardware, the fill rate won't slow them down much? So it's just because I'm using software emulation that they're horribly slow?

It seems like a big problem if that's the case though; the game isn't targetted at top-end platforms.

Share this post


Link to post
Share on other sites
I don't know pixel shaders (that is, I've never worked with them), but I think that a such powerful feature should be targeted to only those cards that support it. Perhaps it would be better to provide a simple sea version for older cards, and an advanced one for newer ones.

Share this post


Link to post
Share on other sites
A shadow map blur algorithm I coded did like 20 fullscreen passes per frame with fairly complicated (50-60 instructions, lots of dependent texture reads) ps2.0 pixel shaders and still got something like 5fps on Radeon9700pro. So yeah, pixel shader to render a sea surface would be fine.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
As for the geometry - fractals can be a very good choice if you're looking for realism.

Share this post


Link to post
Share on other sites
Maybe I'm just going blind, but I spent the last half hour browsing both sites and couldn't find anything on rendering oceans. Not helped by the fact ATI's search engine keeps timing out, grumble.

Fractals sounds like an interesting way to do it, I'll look into that, thanks. :)

Back to [google] now then! :D

Share this post


Link to post
Share on other sites
Damn, so many implementations I've found rely on programmable shaders.

Is it possible to do specular lighting without pixel shaders in DirectX?

Sometimes I miss the days of direct video memory access :/

Share this post


Link to post
Share on other sites
I don't know about DirectX, but at least in OpenGL using ordinary per-vertex specular lighting is simple and can be done without any kind of shaders. Though, if you want to implement per-pixel specular, Phong shading, for instance, then you need pixel shaders...

Share this post


Link to post
Share on other sites
I'm looking at generating an infinite sea/ocean, but have some questions concerning which method to use.

I want there to be real-time waves, which can be adjusted for calm and stormy seas. I need to be able to quickly get the surface position and normal for any given point for my boat physics queries. Can FFT or Perlin Noise wave methods give me that information quickly and efficiently?

Also I really want something that can do that AND be up and running in a short amount of time. What is a quick method to program for generating the waves basically?

Thanks! I'd appreciate any info.

Share this post


Link to post
Share on other sites
Quote:
Also I really want something that can do that AND be up and running in a short amount of time. What is a quick method to program for generating the waves basically?


I'd suggest perlin noise, it's not very hard to implement, and the result is pretty good, althogh u may not be able to have much control on it.

FFT water is not too hard to code(but still much harder than noise), the hardest part is to understand it and to translate those formulars to codes. In addition, it's very realistic and fast.(as long as you use FFTW or sth like that)

But both techniques are unable to have feedback on them, meaning u can't change the pos/normal yourself, and getting physically correct result. In that case, you might want to use Navier-Stoke solver, or combine them with above methods.(not recommended)

Generally speaking, for ocean, use either Perlin Noise or FFT, if u really wanna have feedback, simply put another map on top of them.(eg. put ripple height map on top of the water height map)

Quote:
I need to be able to quickly get the surface position and normal for any given point for my boat physics queries.


Althogh you can't get pos/normal for any given point directly from those water solvers, u can use bi-linear interpolation over the heightmap/normalmap generated by the solvers to get them.(lerp will do as well, but expect bad result :) )

Share this post


Link to post
Share on other sites
There's an article on gamasutra on ocean rendering that's pretty good for beginners. I suggest you check it out.

There's also Yann's water lecture, I can't remember the URL, perhaps someone can provide it?

Share this post


Link to post
Share on other sites
Thanks for the replies to my questions. I've read over the Yann lecture, but I think that NSE is outta question for my needs, so I'll probably go with perlin noise to get the heightmap up and running asap.

Though I have a further question, based on perlin noise, the heightmap and LOD. If I have a high-res heightmap near the camera and getting lower towards the distance, can I just translate that mesh with the camera and still calculate the heights from the perlin noise okay, without any dodgy movements? e.g. when the heightmap moves with the camera, the wave shapes don't alter weirdly with the new samples? Thanks.

Share this post


Link to post
Share on other sites
You could build a ocean mesh that moves along the camera, and the vertices' heights and UVs simply change as the camera moves to represent the water heigth under their positions.

That would save you from re-building the mesh everytime the camera moves, and thus you wouldn't have to worry that much about having a fast LOD algorithm, and the mesh resolution could be much, much higher closer to the camera. You should also scale the mesh up when the camera gets further from the sea level.

There are some tricks to get pleasant looking water without pixel shaders. Instead of using per-vertex specular, you can use a texture as specular (like a deep blue rectangle with a flare in the middle) and adjust the UV coords for each vertex based on the dot product between the vertex normal and the sun direction.

Share this post


Link to post
Share on other sites

This topic is 4812 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this