I Just Noticed - Flat Water
by Michael Hense · in Torque Game Engine Advanced · 09/10/2006 (4:42 pm) · 28 replies
Is there an option for undulating waves... like in tge and the tge water mod... as opposed to the flat surface waves in the TSE demo...
i only just got the license yesterday, and have been reading everything i can get my hands on, and experimenting with the new render stuff, so i might have missed this... i sure hope so...
i need to simulate a stormy sea in my game, and flat waves just aint gonna cut it...
Ben... are ya out there... can you hear me :)
--Mike
i only just got the license yesterday, and have been reading everything i can get my hands on, and experimenting with the new render stuff, so i might have missed this... i sure hope so...
i need to simulate a stormy sea in my game, and flat waves just aint gonna cut it...
Ben... are ya out there... can you hear me :)
--Mike
#2
i'll look for the code, hope it hasn't been removed...
if it has, i hope that you guys will consider putting
it back in as an optional comment block, or offering
a moving water shader along with the default shader...
i'm sure that a few 'waterbabys' like myself would be willing
to live with the performance penalties for the sake of realistic
moving water effects... even if it's just of the 'cheesy sin/cos'
variety :)
anyway... i'm glad to hear that it is doable...
--Mike
09/11/2006 (3:46 am)
Thx Ben... i knew you'd come through *thumbs up*i'll look for the code, hope it hasn't been removed...
if it has, i hope that you guys will consider putting
it back in as an optional comment block, or offering
a moving water shader along with the default shader...
i'm sure that a few 'waterbabys' like myself would be willing
to live with the performance penalties for the sake of realistic
moving water effects... even if it's just of the 'cheesy sin/cos'
variety :)
anyway... i'm glad to hear that it is doable...
--Mike
#3
09/12/2006 (10:24 am)
If you can locate the vertex shader hlsl file, it's fairly straightforward to change the vertex z axis using a sin() function, using the x and y coordinates as inputs, plus some scaling. The sin() and cos() functions are avaliable in all vertex shader profiles.
#4
It's a difficult problem. Like Ben says, there are lots of ways to simulate ocean waves, and in fact even the simple sin/cos ones can be very convincing with a bit of mathematical tweaking and some judicious particle effects. However, I can't think of a way of implementing *any* such algorithm without having some nice small triangles to make curves out of, and the problem with nice small triangles is that you need a goshdarned lot of them to render a sea...
Which leads to this: you need an LOD system to render realistic waves, just like you need an LOD system to render realistic landscapes; the same conflict between detail and scale exists, and it's actualy much harder to resolve for seas, because the bloody things are in constant motion...
I'm with you, Mike - I'd sacrifice some performance for a beautiful sea, and I'm working on it right now. But I'd just like to say that it's a much harder thing to achieve than you might think - and that's not down to TSE, it's just the nature of the problem.
Wayne
09/12/2006 (4:45 pm)
Be aware, though, that TSE's waterblocks don't contain much geometry by default (they don't need it, being flat), so you'll need to make the mesh a lot finer if you want any joy out of a solution based on vertex shaders. This will quickly get out of hand if you try to just brute-force the whole thing. For example, tesselating a body of water a mere 100 metres square at metre intervals would give you 10,000 vertices to render - that's a lot of crunch for such a small area. Moreover, it still only gives you control points a metre apart, which isn't going to be enough when the camera is close - water undulates in smooth curves, you can't fake it like you can with terrain.It's a difficult problem. Like Ben says, there are lots of ways to simulate ocean waves, and in fact even the simple sin/cos ones can be very convincing with a bit of mathematical tweaking and some judicious particle effects. However, I can't think of a way of implementing *any* such algorithm without having some nice small triangles to make curves out of, and the problem with nice small triangles is that you need a goshdarned lot of them to render a sea...
Which leads to this: you need an LOD system to render realistic waves, just like you need an LOD system to render realistic landscapes; the same conflict between detail and scale exists, and it's actualy much harder to resolve for seas, because the bloody things are in constant motion...
I'm with you, Mike - I'd sacrifice some performance for a beautiful sea, and I'm working on it right now. But I'd just like to say that it's a much harder thing to achieve than you might think - and that's not down to TSE, it's just the nature of the problem.
Wayne
#5
thx Manoel... i've looked at your Cg implementation over on TGE... great stuff...
i been poking around blindly in the vertex shader files, but like Wayne pointed out, the first thing that came to mind was that the current geometry is gonna be way too devoid of points to grab onto... and the LOD issue never even entered my rose colored imagination...
to be honest, this may wind up being a bit more than i can handle... i'm preparing my most pitiful whining voice, in preparation to send up a telephone message to Ben, and the other movers and shakers up there, to implore them to include a second waterblock option... one with moving waves...
i'm gonna really need to get this working for my project...
plus... why should TGE get it and not TSE :)
thx again guys for your insights...
--Mike
09/13/2006 (4:43 am)
Thx guys for the follow-up discussion... i'm really kinda dissapointed on this state of affairs... but hey, i'll hold off on the whining 'till i've tried a few possibilities out :)thx Manoel... i've looked at your Cg implementation over on TGE... great stuff...
i been poking around blindly in the vertex shader files, but like Wayne pointed out, the first thing that came to mind was that the current geometry is gonna be way too devoid of points to grab onto... and the LOD issue never even entered my rose colored imagination...
to be honest, this may wind up being a bit more than i can handle... i'm preparing my most pitiful whining voice, in preparation to send up a telephone message to Ben, and the other movers and shakers up there, to implore them to include a second waterblock option... one with moving waves...
i'm gonna really need to get this working for my project...
plus... why should TGE get it and not TSE :)
thx again guys for your insights...
--Mike
#6
-Matt
09/13/2006 (6:41 am)
In all honesty if you want waves I'd probably rewrite the water code from the ground up. It really doesn't seem meant for it. Also, you can have a look at how TGE does waves. It's nothing light or easy. In a chat with Ben last night he said it would probably be at least a few months work of learning. However, there's a popular shader called relief mapping. I've actually tried to integrate it into TSE a few times. It obviously wouldn't look as amazing as vertex waves, but much less expensive. -Matt
#7
It gives you a working LOD without the need to re-generate the geometry.
09/13/2006 (7:17 am)
Since the water surface is far less complex and unique than terrain surface, maybe you can pre-generate a water mesh that is more tesselated closer to it's centre, then, when rendering water, always put it's center under the camera, making the water always very detailed closer to the camera, and offset all geometry/texture wave/scrolling code based on the camera position so the water won't look like it's following the view. It gives you a working LOD without the need to re-generate the geometry.
#8
With the method of translating the position of the water surface in the post above you would need to consider how you're going to translate those changes in wave positions as the view moves, maintaining realistic coherency seems like it would be a nightmare.
09/13/2006 (2:59 pm)
Or you could very carefully use TESSELATE[n] based on view position and even the orientation of the view. No need for fine vertical detail when you're looking straight down (or up).With the method of translating the position of the water surface in the post above you would need to consider how you're going to translate those changes in wave positions as the view moves, maintaining realistic coherency seems like it would be a nightmare.
#9
placing that slightly over the water, and in close proximity of the view should work...
i did something like this in another engine... the mesh moves only when the view cam is a certain distance away... this way the 'moving' water part stays around the view... and gives the illusion of real waves...
am i explaining this clear enough :)
--Mike
09/20/2006 (9:46 am)
Ok Ben... no need to change the water, but could you add a second, smaller, tesselated mesh with a translucent bumpmapped texture... and use a simple sin wave to move it's vertices directly...placing that slightly over the water, and in close proximity of the view should work...
i did something like this in another engine... the mesh moves only when the view cam is a certain distance away... this way the 'moving' water part stays around the view... and gives the illusion of real waves...
am i explaining this clear enough :)
--Mike
#10
09/20/2006 (2:40 pm)
Michael, you could always try using vertex textures.
#11
While it doesnt have really much in the way of code, and is more focused like a thesis paper it's an excellent paper on realtime ocean rendering:
www-evasion.imag.fr/Publications/2002/HNC02/wavesSCA.pdf
09/20/2006 (3:14 pm)
Problem is vertex texture reads require 3.0 in hlsl, which instantly nulls anyone not toting the hardware. There are a *ton* of ways to approach this stuff, and if you do a bit of digging online, you can find a metric ton of research papers dealing with rendering of realistic water in games, how to tesselate it, dynamic LOD's, how to simulate different waves and displacement types, interaction, lighting, you name it. It's all about how much effort you want to dedicate at it.While it doesnt have really much in the way of code, and is more focused like a thesis paper it's an excellent paper on realtime ocean rendering:
www-evasion.imag.fr/Publications/2002/HNC02/wavesSCA.pdf
#12
I can see how this could give a local swell effect, but I can't see how it could be used to create a stormy-looking sea. It also seems like you'd run into all manner of problems keeping this kind of illusion realistic as the camera moves around (especially when it's close to the sea surface).
Sorry, I really don't mean to slap your idea down, particularly since you've already had it working in another engine - if you've already made it work, then what the hell do I know? It just sounds like it presents more problems than it solves. To me, if you want a simple, calm, deep-water wave simulation then the best thing to do is port TGE's waterblock features to TSE - keep the rendering from TSE, and the mesh LOD and wave features from TGE. OK, that involves some work, but when it's done you have a water system with LOD-based geometry and shader-based rendering. This is the basis for ANY ocean, shore, lake or river effect you might desire - the only question (other than the work involved) is how much performance you're prepared to give up...
That's the direction I'm currently going, at any rate.
Good luck,
Wayne
09/20/2006 (3:58 pm)
Mike,I can see how this could give a local swell effect, but I can't see how it could be used to create a stormy-looking sea. It also seems like you'd run into all manner of problems keeping this kind of illusion realistic as the camera moves around (especially when it's close to the sea surface).
Sorry, I really don't mean to slap your idea down, particularly since you've already had it working in another engine - if you've already made it work, then what the hell do I know? It just sounds like it presents more problems than it solves. To me, if you want a simple, calm, deep-water wave simulation then the best thing to do is port TGE's waterblock features to TSE - keep the rendering from TSE, and the mesh LOD and wave features from TGE. OK, that involves some work, but when it's done you have a water system with LOD-based geometry and shader-based rendering. This is the basis for ANY ocean, shore, lake or river effect you might desire - the only question (other than the work involved) is how much performance you're prepared to give up...
That's the direction I'm currently going, at any rate.
Good luck,
Wayne
#13
please keep us updated with your progress... this is of great interest to me...
as far as my 'local waves' approach, due to the translucency of the mesh that moves, when it does move, there is almost no sensation of it repositioning... and it only moves at certain intervals... and the motion and texture animation makes this movement imperceptible (although, not entirely unnoticeable)...

if you look closely, you can see the swells near the hull of the sub... also, you might be able to make out the area of the only moving (undulating and camera following) mesh... but surprisingly enough, maybe due to it's general translucency (only the 'reflective' parts of the image are visible), it is very hard to see where it ends...
sorry about the poor quality of the pic, a video of the movement might be a lot better to illustrate the effect... while i was trying to move the whole ocean scene i accidentally stumbled upon this solution, and noone was more surprised than i how well it seemed to work... so i kept it...
now i'd like to see if it would work in TSE... actually, i'd like the water in TSE to undulate like the water in TGE... but since that doesn't appear to be the case...
there are no shaders used in the scene above... it was done in something called 3Impact (a physics oriented game 'engine') with bumpmapping, texture blending, and a lil cubemapping... seeing as TSE gives us bumpmapping, i thought i might be able to recreate something like this here... and easy solution :)
you may be right as far as being able to provide a seamless illusion... it might be a bit more difficult in TSE...
--Mike
09/23/2006 (7:37 am)
Hey Wayne... that sounds like a plan as well, but, like you said, it's gonna require a lil work, and me being the lazy personality i am, would rather spend twice as much time and effort trying to find an easier solution :)please keep us updated with your progress... this is of great interest to me...
as far as my 'local waves' approach, due to the translucency of the mesh that moves, when it does move, there is almost no sensation of it repositioning... and it only moves at certain intervals... and the motion and texture animation makes this movement imperceptible (although, not entirely unnoticeable)...

if you look closely, you can see the swells near the hull of the sub... also, you might be able to make out the area of the only moving (undulating and camera following) mesh... but surprisingly enough, maybe due to it's general translucency (only the 'reflective' parts of the image are visible), it is very hard to see where it ends...
sorry about the poor quality of the pic, a video of the movement might be a lot better to illustrate the effect... while i was trying to move the whole ocean scene i accidentally stumbled upon this solution, and noone was more surprised than i how well it seemed to work... so i kept it...
now i'd like to see if it would work in TSE... actually, i'd like the water in TSE to undulate like the water in TGE... but since that doesn't appear to be the case...
there are no shaders used in the scene above... it was done in something called 3Impact (a physics oriented game 'engine') with bumpmapping, texture blending, and a lil cubemapping... seeing as TSE gives us bumpmapping, i thought i might be able to recreate something like this here... and easy solution :)
you may be right as far as being able to provide a seamless illusion... it might be a bit more difficult in TSE...
--Mike
#14
If anyone is interested on some common wave approaches such as VTF have a look at:
Nvidia's Vertex Texture Article
Gamasutra's Article
Nvidia's VTF Demo
Hope this helps!
-Matt Vitelli
09/23/2006 (11:46 am)
Personally, I want to try vertex texture fetch (VTF) on the water. It sounds extremely expensive but sounds like a logical way to do waves. The major problem with wave approaches is that the most logical ones require shader model 3.0 cards.If anyone is interested on some common wave approaches such as VTF have a look at:
Nvidia's Vertex Texture Article
Gamasutra's Article
Nvidia's VTF Demo
Hope this helps!
-Matt Vitelli
#15
09/23/2006 (2:26 pm)
VTF is so amazingly expensive that I think in the long run it won't be worth it. It's especially expensive on 360, for what it's worth. Might not be as bad on normal PC cards, but on the 360 it's basically shooting yourself in teh foot.
#16
09/23/2006 (4:03 pm)
What would you propose instead of VTF? I can see performance as a huge problem. I just can't think of anything in terms of 3D waves that wouldn't be expensive.
#17
A Navier Stokes mesh deformer, or even a simplier FFT deformer , running on CPU.
VTF is indeed way too slow.
09/24/2006 (7:23 am)
>> What would you propose instead of VTF?A Navier Stokes mesh deformer, or even a simplier FFT deformer , running on CPU.
VTF is indeed way too slow.
#18
But even if you can, it's unnecessary. The FFT-based solutions have already been used extensively in Hollywood films - is there really any need to strive for more visual realism than Hollywood is prepared to accept?
For a game, I don't think even the FFT approach is necessary. The 1986 paper by Fournier and Reeves describes a fast and simple way to simulate waves, based on Gerstner's waves, that gives really impressive results and copes with deep-water waves as well as breaking waves, shores, spray and foam. The sea effects you can create with this approach match or exceed anything I've ever seen in a game; so that's the way I'll be going, once I've ported the basic TGE stuff.
09/24/2006 (4:46 pm)
I'll take others' word for it that VTF is too slow, for I know nothing about it, and the obvious alternative is a CPU-based mesh deformer. But, seriously, Navier-Stokes? To simulate large bodies of water, in realtime, in a game engine that has lots of things to do other than calculate fluid dynamics? Dan, if you can make that work then all credit to you - I'm sure I couldn't.But even if you can, it's unnecessary. The FFT-based solutions have already been used extensively in Hollywood films - is there really any need to strive for more visual realism than Hollywood is prepared to accept?
For a game, I don't think even the FFT approach is necessary. The 1986 paper by Fournier and Reeves describes a fast and simple way to simulate waves, based on Gerstner's waves, that gives really impressive results and copes with deep-water waves as well as breaking waves, shores, spray and foam. The sea effects you can create with this approach match or exceed anything I've ever seen in a game; so that's the way I'll be going, once I've ported the basic TGE stuff.
#19
I'm no programmer:) I'm hoping someone else will push some effort into getting this done. For reference, there are a couple of ocean models I have been using for projects:
1. DXStudio www.dxstudio.com - a simple tool that generates interactive scenes for a Web based player. It's kind of a pain in the arse to develop in. But it does have cool features. One of these is an Ocean plug-in with vertex displacement and the ability to get the z @x/y world position. We have put in some pretty nifty boat simulation stuff really quickly with this at work. It looks pretty nice and has lots of features for making choppy waves, swells, etc.. Here's our application in DXS (it isn't pushing the water model very far, but we are getting some wave motion - can't tell in these shots). These are shrunk from the full size. It's running in the browser, pretty fast on a laptop, and mixes a lot of browser tech.




2. Virtual Sailor - At my day job, we are working with these guys on a simulation project. They seem to have figured out the whole ocean thing:) Download their game demo version at www.hangsim.com/vs. It really is a simple and keen system for putting stuff into the program. All content is driven from text files and X files with textures tagged on. Limited, but effective for what it is. Here is an image taken from within the program. My wife modeled and textured the ship and the characters and other models in the shots above (she's a viz genius IMHO:))
**If you download VS, the shaders won't work unless you return the DXSDK control panel back to retail (in debug it makes the ocean disappear:))

These two show the variety (although the sea state can be pushed a lot farther than this) and the way they are using surface shaders:


I really expected to see ocean surface effects in TSE. I'm sure we are a minority of folks, but it would really open up a few things for serious applications. It's a plus for immersion and visuals as well. Hope to see some type of solution in the future:)
10/10/2006 (4:01 am)
Hrm... Just bought TSE expecting I would have some control over ocean waves, etc.. Read in a MS post that this was going to be possible. I'm no programmer:) I'm hoping someone else will push some effort into getting this done. For reference, there are a couple of ocean models I have been using for projects:
1. DXStudio www.dxstudio.com - a simple tool that generates interactive scenes for a Web based player. It's kind of a pain in the arse to develop in. But it does have cool features. One of these is an Ocean plug-in with vertex displacement and the ability to get the z @x/y world position. We have put in some pretty nifty boat simulation stuff really quickly with this at work. It looks pretty nice and has lots of features for making choppy waves, swells, etc.. Here's our application in DXS (it isn't pushing the water model very far, but we are getting some wave motion - can't tell in these shots). These are shrunk from the full size. It's running in the browser, pretty fast on a laptop, and mixes a lot of browser tech.




2. Virtual Sailor - At my day job, we are working with these guys on a simulation project. They seem to have figured out the whole ocean thing:) Download their game demo version at www.hangsim.com/vs. It really is a simple and keen system for putting stuff into the program. All content is driven from text files and X files with textures tagged on. Limited, but effective for what it is. Here is an image taken from within the program. My wife modeled and textured the ship and the characters and other models in the shots above (she's a viz genius IMHO:))
**If you download VS, the shaders won't work unless you return the DXSDK control panel back to retail (in debug it makes the ocean disappear:))

These two show the variety (although the sea state can be pushed a lot farther than this) and the way they are using surface shaders:


I really expected to see ocean surface effects in TSE. I'm sure we are a minority of folks, but it would really open up a few things for serious applications. It's a plus for immersion and visuals as well. Hope to see some type of solution in the future:)
#20
The problem is that it was never promised anywhere. Those are very game specific. I do agree though that the effects shown above does look awesome!
10/10/2006 (4:51 am)
Quote:
I really expected to see ocean surface effects in TSE.
The problem is that it was never promised anywhere. Those are very game specific. I do agree though that the effects shown above does look awesome!
Associate Kyle Carter
(There are a _ton_ of ways to do ocean effects, all the way from cheesy sin/cos stuff up to complex stochastic models.)