🔒 Locked
Rendering seas
Advertisement
Original Post
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!
Hehe! If your card supports PixelShaders, then there's nothing wrong with using them.
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.
It seems like a big problem if that's the case though; the game isn't targetted at top-end platforms.
Software Pixel Shading = hahaa..
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.
For various effects, check out the following:
nVidia developer site
ATI developer site
Both have information on how to efficiently render oceans, among much other stuff [smile]
nVidia developer site
ATI developer site
Both have information on how to efficiently render oceans, among much other stuff [smile]
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
Fractals sounds like an interesting way to do it, I'll look into that, thanks. :)
Back to [google] now then! :D
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...
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.
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.
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 :) )
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?
There's also Yann's water lecture, I can't remember the URL, perhaps someone can provide it?
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.
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.
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.
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.
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement