Fluid Improvements
by Melv May · 07/11/2002 (10:29 am) · 78 comments
Download Code File
If you've not already seen it then you can see it here:
Shoreline#1
Shoreline#2
Shoreline#3
Shoreline#4
Shoreline#5
Dev Snapshot
Forum Thread
Some major improvements are:-
- Takes advantage of multiple texturing units on cards. Will reconfigure surface/environment/fog rendering for 2 TMU's or 4 TMU's automagically.
- No longer need to exit editor to change waterblock textures for surface/environment.
- Can move waterblock and apply alpha-map on the fly using the editor.
- Shallow/Depth alpha configurable.
- Water Surface Distortion function.
- Surface Parallax.
- Fluid Flow control.
- Seperate fluid Environment map for over/under surface
Please note that this superceeds the previous code snipit Improved Fluid Rendering and includes all of it's functionality except the underwater distortion texture.
You can also find some textures which I used in the "Dev Snapshot" here:
Wash#1
Wash#2
Enjoy everyone,
- Melv.
[EDIT] 27/08/2002
Completely revamped engine to include features listed above.
[EDIT] 31/08/2002
Removed some WIP code that was left in and was causing a texture manager error. Thanks to Chris Wilson for kindly pointing it out.
[EDIT] 8/9/2002
Fixed bug causing disconnect when *any* texture resources are not found.
[EDIT] 1/2/2003
Moved hosting web-site.
If you've not already seen it then you can see it here:
Shoreline#1
Shoreline#2
Shoreline#3
Shoreline#4
Shoreline#5
Dev Snapshot
Forum Thread
Some major improvements are:-
- Takes advantage of multiple texturing units on cards. Will reconfigure surface/environment/fog rendering for 2 TMU's or 4 TMU's automagically.
- No longer need to exit editor to change waterblock textures for surface/environment.
- Can move waterblock and apply alpha-map on the fly using the editor.
- Shallow/Depth alpha configurable.
- Water Surface Distortion function.
- Surface Parallax.
- Fluid Flow control.
- Seperate fluid Environment map for over/under surface
Please note that this superceeds the previous code snipit Improved Fluid Rendering and includes all of it's functionality except the underwater distortion texture.
You can also find some textures which I used in the "Dev Snapshot" here:
Wash#1
Wash#2
Enjoy everyone,
- Melv.
[EDIT] 27/08/2002
Completely revamped engine to include features listed above.
[EDIT] 31/08/2002
Removed some WIP code that was left in and was causing a texture manager error. Thanks to Chris Wilson for kindly pointing it out.
[EDIT] 8/9/2002
Fixed bug causing disconnect when *any* texture resources are not found.
[EDIT] 1/2/2003
Moved hosting web-site.
About the author
#42
I think my reputation has got a bit *bloated* of late. I'm just a programmer that works hard and doesn't mind doing stuff just for the fun of it and the community in general.
I do take pride in seeing others using my work and I guess that's the ultimate compliment anyone can give but nothing I have done so far is really that good (in my opinion).
I think there's a lot of cool things that can be done with this engine and I'm just looking forward to the chance to be one of those making it happen. ;)
- Melv.
08/26/2002 (11:11 am)
Eric,I think my reputation has got a bit *bloated* of late. I'm just a programmer that works hard and doesn't mind doing stuff just for the fun of it and the community in general.
I do take pride in seeing others using my work and I guess that's the ultimate compliment anyone can give but nothing I have done so far is really that good (in my opinion).
I think there's a lot of cool things that can be done with this engine and I'm just looking forward to the chance to be one of those making it happen. ;)
- Melv.
#43
Not exactly difficult to do but there's only so much time available to do stuff. ;)
- Melv.
08/26/2002 (11:13 am)
@Trevor: Yes, a method to achieve this is to use a finite element mesh (FEM), basically a posh way of saying "create a mesh that follows the objects that is interacting with the surface".Not exactly difficult to do but there's only so much time available to do stuff. ;)
- Melv.
#44
I was kind of good-naturedly kidding you when I wrote that earlier. TGE is, IMHO, an excellent product... and you've helped to make it better. I'm sure you would even admit that no amount of programming is going to make a bad game good... or bad graphics look good. I kind of think some people would rather blame the engine. ;-)
I can't wait to see some of these games... I only wish I DID have the techical know how to do alot of that stuff. Until then, I'll stick with the artsy side of it...for whatever THAT is worth! ;-) LOL
08/26/2002 (12:57 pm)
LOL Melv! The higher the pedestal, the further the fall? ;-)I was kind of good-naturedly kidding you when I wrote that earlier. TGE is, IMHO, an excellent product... and you've helped to make it better. I'm sure you would even admit that no amount of programming is going to make a bad game good... or bad graphics look good. I kind of think some people would rather blame the engine. ;-)
I can't wait to see some of these games... I only wish I DID have the techical know how to do alot of that stuff. Until then, I'll stick with the artsy side of it...for whatever THAT is worth! ;-) LOL
#45
I have uploaded the new fluid engine for you to play with.
I have included waterBlock example files for levels included in the SDK to get you started. Also, please read the attached file on configuring the waterblock otherwise you may find that you get distorted surfaces out-of-the-box as I can only specify one set of defaults and these may not suit your waterblock sizes etc.
I would ask that if you have a problem getting up and running that you send me an email rather than post here. I have found that 99% of problems are person specific and are related to compiler/linker problems rather than bugs in the code.
I will of course post any known problems/resolutions with the code here so that people are aware but most folks are not interested in person-specific problems.
Please send emails to melv.may@btinternet.com.
I hope you find it useful. 8)
- Melv.
08/27/2002 (5:35 am)
Okay,I have uploaded the new fluid engine for you to play with.
I have included waterBlock example files for levels included in the SDK to get you started. Also, please read the attached file on configuring the waterblock otherwise you may find that you get distorted surfaces out-of-the-box as I can only specify one set of defaults and these may not suit your waterblock sizes etc.
I would ask that if you have a problem getting up and running that you send me an email rather than post here. I have found that 99% of problems are person specific and are related to compiler/linker problems rather than bugs in the code.
I will of course post any known problems/resolutions with the code here so that people are aware but most folks are not interested in person-specific problems.
Please send emails to melv.may@btinternet.com.
I hope you find it useful. 8)
- Melv.
#46
08/27/2002 (5:47 am)
Hot damn! I'm droppin' this sucka in tonight :)
#47
08/27/2002 (5:54 am)
/ME wants to go home immediately and drop that stuff in!!! :/ Doh! Still 2 hrs work left here... Thanks a lot Melv, I'll try this tonite!! :))
#48
Any more work on the fluid rendering will have to be using shaders because there is only so much you can do without getting a serious CPU hit.
The improvements I've made are not fantastic but they do allow you to easily create a nice edge to the water. Turning the depth-map on/off shows you the old-style as compared to the new one which highlights the improvements.
I think this version should rest for a while so that I can get on with other projects. ;)
- Melv.
08/27/2002 (6:11 am)
I hope you guys like it. ;)Any more work on the fluid rendering will have to be using shaders because there is only so much you can do without getting a serious CPU hit.
The improvements I've made are not fantastic but they do allow you to easily create a nice edge to the water. Turning the depth-map on/off shows you the old-style as compared to the new one which highlights the improvements.
I think this version should rest for a while so that I can get on with other projects. ;)
- Melv.
#49
is there any way that the waves one the waterblocks could be smaller- so that they are not gigantice swells, but more like actual waves. not neccessarily whitecapes, but a bit smaller.....
and mabye a sbudivision in polygon count for a smoother look. your work is awsome- how do you honestly feel about your work in retail games?
08/27/2002 (11:09 am)
melv-is there any way that the waves one the waterblocks could be smaller- so that they are not gigantice swells, but more like actual waves. not neccessarily whitecapes, but a bit smaller.....
and mabye a sbudivision in polygon count for a smoother look. your work is awsome- how do you honestly feel about your work in retail games?
#50
The real problem with the standard waterblocks is that the mesh is completely dynamic and does not contain a heightmap at all. It's achieved by using a simple 2D height function that can be applied to the vertices wherever they appear.
The surface could certainly do with more vertices and there is alot of things that I could do with it so that we get much better surface pertubation.
The thing about the waterblocks are that they are scalable. It's great for a horse-trough of water to have a dynamic heightmap that the cpu can calculate but when it's scaled-up to an ocean like on waterWorld then you've got troubles.
I guess it would depend on the game itself but I think the next improvement would be to use shaders to create a dynamic environment bump-map but that means we need a shader system in there and that's a whole different story.
As to your other query, I don't know what to say really. I would like to think that games being developed on this site would classify and therefore I will have my work in there hopefully.
Using my work is the highest form of compliment. ;)
- Melv.
08/27/2002 (11:24 am)
Alexander,The real problem with the standard waterblocks is that the mesh is completely dynamic and does not contain a heightmap at all. It's achieved by using a simple 2D height function that can be applied to the vertices wherever they appear.
The surface could certainly do with more vertices and there is alot of things that I could do with it so that we get much better surface pertubation.
The thing about the waterblocks are that they are scalable. It's great for a horse-trough of water to have a dynamic heightmap that the cpu can calculate but when it's scaled-up to an ocean like on waterWorld then you've got troubles.
I guess it would depend on the game itself but I think the next improvement would be to use shaders to create a dynamic environment bump-map but that means we need a shader system in there and that's a whole different story.
As to your other query, I don't know what to say really. I would like to think that games being developed on this site would classify and therefore I will have my work in there hopefully.
Using my work is the highest form of compliment. ;)
- Melv.
#51
thanx for the reply.
in the game morrow wind they use an animation to simulate ripples so i suppose that that'd be the easiest way to do some ripples then........
08/27/2002 (1:53 pm)
wow. great-thanx for the reply.
in the game morrow wind they use an animation to simulate ripples so i suppose that that'd be the easiest way to do some ripples then........
#52
I'm not sure if you are planing to do this and i would do it if i had the animation software. it would be cool to do this.
If one has a bridge or something over the water, it'd look weird without a reflection. I was thinking, maybe there would be a way to place a 2d plane that would consist of an environment map to "reflect" the bridge. BTW is there a procudure to making the env maps other than painting a circular distorted texture?
I don't know how it would work with waves on the water but it may look nice.
the other one is this, i noticed that there were places in maybe waterworld that didn't look right like the water would go into the corner of the bridge. other than placing a particle texture there and in other places, perhaps we could find a way to creat 2d flat plans, with animations--ripples for example . maybe scaleabble too.
that sound good?
I'll try to do it when i can get some animation software, anyone know some simple software for animations. does torque take 2d anims? or even one's with alpha textures...?
also would you know why my environment map (clouds) seems to circle ? very small wiggly ones.
also i dunno if it's my computer, but when i set my Flowrate, it will flow very sllow then speed up to the specified rate then back to slow.
the last one is about the way the rendering works, when the water is distorted it tends to kinda gradiently flash to white then back and then again after a delay. whats that for? is it supposed to be there?
LOVE the work melv- keep it up
-Alex
08/27/2002 (6:08 pm)
ok here's another oneI'm not sure if you are planing to do this and i would do it if i had the animation software. it would be cool to do this.
If one has a bridge or something over the water, it'd look weird without a reflection. I was thinking, maybe there would be a way to place a 2d plane that would consist of an environment map to "reflect" the bridge. BTW is there a procudure to making the env maps other than painting a circular distorted texture?
I don't know how it would work with waves on the water but it may look nice.
the other one is this, i noticed that there were places in maybe waterworld that didn't look right like the water would go into the corner of the bridge. other than placing a particle texture there and in other places, perhaps we could find a way to creat 2d flat plans, with animations--ripples for example . maybe scaleabble too.
that sound good?
I'll try to do it when i can get some animation software, anyone know some simple software for animations. does torque take 2d anims? or even one's with alpha textures...?
also would you know why my environment map (clouds) seems to circle ? very small wiggly ones.
also i dunno if it's my computer, but when i set my Flowrate, it will flow very sllow then speed up to the specified rate then back to slow.
the last one is about the way the rendering works, when the water is distorted it tends to kinda gradiently flash to white then back and then again after a delay. whats that for? is it supposed to be there?
LOVE the work melv- keep it up
-Alex
#54
Thanks to Chris Wilson for the heads up.
- Melv.
08/31/2002 (9:04 am)
Resolved a bug that was causing a texture manager error when doing texture zombies when task switching.Thanks to Chris Wilson for the heads up.
- Melv.
#55
Thanks to Desmond Fletcher and Eric Hartman for the heads up on this, thanks guys.
Note, that you do not need any "addField" entries in "ObjectBuilderGui.gui" (buildWater) now. This is mine...
I would seriously recommend that you upgrade to this version. Please note that field grouping is available in this file by removing the group comment-outs in the "initPersistFields" function.
- Melv.
09/08/2002 (7:22 am)
Resolved a bug that was causing a client disconnect if *any* of the water texture resources were not found.Thanks to Desmond Fletcher and Eric Hartman for the heads up on this, thanks guys.
Note, that you do not need any "addField" entries in "ObjectBuilderGui.gui" (buildWater) now. This is mine...
function ObjectBuilderGui::buildWater(%this)
{
%this.className = "WaterBlock";
%this.process();
}I would seriously recommend that you upgrade to this version. Please note that field grouping is available in this file by removing the group comment-outs in the "initPersistFields" function.
- Melv.
#56
-fa
09/13/2002 (10:26 pm)
Looks great, much better than your last fluid rendering, but i miss the underwater distortion texture, using it with smooth textures you could get that feeling of a not so clean but neither dirty water, i guess i will pull back that. =P-fa
#57
10/04/2002 (11:47 am)
Great water, it is a big improvement. I just have one concern. It seems like the water is constantly accelerating. When I leave it on overnight (or even for just a little while) it starts to get really fast. After looking at the source code, it looks like the speed is based on time? Maybe I'm wrong, or misunderstaning it, but it looks like the flow rate is increasing every time fluid::Render() is called.
#58
Cheers,
- Melv.
10/04/2002 (11:53 am)
I didn't think that was the case but I will have a look at it soon to double-check it out.Cheers,
- Melv.
#59
10/18/2002 (8:47 pm)
Dude, unreal job with this one. Can't believe how good the water looks now. I actually laughed when I turned off Use Depth Mask for the first time, the difference was so drastic.
#60
11/01/2002 (9:30 am)
is it planned that this is going to be integrated into the main CVS tree anytime? 
Torque 3D Owner Eric Forhan
I've got QuakeIII but havent played it much since it seems a bit dated (prolly get some flames, here. ;-) ). Shaders are that good?