Game Development Community

Roll up, Roll up ... come get your fluid ...

by Melv May · in Torque Game Engine · 03/16/2002 (7:33 am) · 17 replies

I've spent the last few days modifying the fluid rendering system. I've attempted to improve the overall control of fluid blocks so you can achieve a more realistic fluid surface.

As always, I've modified from the latest stable build (RELEASE_1_1_1).

Please find it here:-

www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=2356

The new features are:-

- Multi-texture support for two-pass surface rendering.
- Multi-texture support for environment mapping.
- Surfaces can now have different environment map for each surface-face e.g under/over.
- Multi-texture submerged textures with distortion, colour and alpha control.
- Drift Mode. You can control the surface disturbance to produce realistic eddies and currents.
- Flow Mode. You can control the surface flow to produce a running river/stream.
- Backface Culling Mode for improved performance.
- Better Colourisation/Alpha control.
- Ability to turn on/off surface/environment passes.

... features to come ...

- Surface collision detection to produce waves/ripples.
- Underwater->surface disturbence.
- Linkeage to precipitation (rain collision).


I hope you enjoy.

#1
03/16/2002 (7:59 am)
Nice work Melv. The underwater blending gave me vertigo =) Bit of a frame rate hit but probably worth it in some situations. Reminds me of a question I had about another thread you started on procedural textures - are you doing static render to texture snapshots of the procedural or are you adding animation as well? Just curious what mechanism you plan on using to advance time. Thanks for the nice contribution, I'm off to play with it a bit more!
#2
03/16/2002 (8:25 am)
This is nothing short of impressive. GREAT work.
#3
03/16/2002 (10:01 am)
That is awesome, man!!
May I suggest Melv for president?? Or at least Associate? :-)
Keep up the great work! By the way, do you work 24 hrs a day, Melv ...? ;)
#4
03/16/2002 (11:05 am)
This is fabulous. I have one question, though: do the water blocks still repeat ? This is a fundamental problem for me that I intend to address when I get the time. I want to have multiple lakes & rivers at different elevations, but repeating water block tiles prevent this ... does that still hold, given the modifications you've made ?
#5
03/16/2002 (11:13 am)
The waterblock system in essentially the same.

I would like to seriously hack the fluid rendering stuff but without knowing what changes are in the pipeline, I might make the situation worse rather than better.

I understand the new v1.2 demo is nearly all scripted so I could be forgiven for assuming that fluid rendering has changed little?

If there is enough interest in expanding this part of the engine then I would be glad to give it a go.

p.s. Stefan: I would never dream of working 24 hours a day, 22 is more than enough!
#6
03/16/2002 (11:45 am)
Fabulous! That effect looks great. Thanks for sharing this work.
#7
03/16/2002 (12:55 pm)
Anyone tried this with the head build?
#8
03/16/2002 (1:05 pm)
Yep, works great!! :-)
#9
03/16/2002 (3:11 pm)
IT WORKED WITH HEAD?!?
WTF?... crashes for me :(
#10
03/16/2002 (3:26 pm)
I'll have a look on the head release on Sunday to see if anything has changed. Sorry for any probs though, I'm on it. :)

p.s.

Could one of you guys dispense or recommend someone with a little knowledge on NetObjects? I'm trying to get a TSStatic working on the client-side only.
#11
03/17/2002 (3:44 am)
Xavier,

I just downloaded the head this morning (I probably should have phrased that better) and hey presto, after I compile, on a mission with a waterblock .... booom .... crash. I inspected the call-stack on error and it was blurting on around the audio stuff which seemed bizarre.

I thought ... enough of this ... clean ... build ... make coffee .... run ...

No problems now at all. Have you done a completely clean build my friend?

Also, I did a file-by-file inspection and there seems to have been no relevant changes to the files I have modified. To be safe though, I simply made the changes to "game.cc" manually as per my instructions.

Hope this helps.
#12
03/17/2002 (4:01 am)
Yeah, as I said, I'm using HEAD, too, and it just works fine... one thing I've noticed, though, if you turn on the World Editor, then go underwater, all the submerge stuff isn't visible/rendered, so you can't see the changes your making texture- or color-wise, you have to turn off the Editor to see them ... all the other parameters are fine, though... bug or feature ;-) ?
Anyhow, GREAT stuff!
#13
03/17/2002 (4:23 am)
Yeah Stefan,

The submersion textures are applied in a special section in "game.cc" which is designed to show 'camera fx'. The function is "GameRenderFilters" and is used to show damage flashes, white/black outs etc. The cameraFX are removed when in the editor.

This is probably a good thing, especially if you're trying to select something!

If this is a problem then it is very simple to relocate the submersion rendering.

If you remove the line from "game.cc" function "GameRenderFilters" ...
if (WaterBlock::mCameraSubmerged) gLavaFX.render();
WaterBlock::mCameraSubmerged = false;
WaterBlock::mSubmergedType   = 0;
... replace it with ...
if (WaterBlock::mCameraSubmerged)
{
	WaterBlock::mCameraSubmerged = false;
	WaterBlock::mSubmergedType   = 0;
}
Insert in "waterBlock.cc" function "WaterBlock::renderObject" (line 479) like so ...
// And RENDER!
{
	mFluid.Render( CameraSubmergedFlag );
	if (CameraSubmergedFlag) mFluidFX.render();   <---- CODE ADDED HERE
}
... then it will render always.

NOTE:- Notice that the submerged flag is different!

This was one of the changes I referred to when I posted the resource. I was trying to be careful not to break existing functionality.

Hope this works for you. :)
#14
03/17/2002 (8:11 am)
Thanx, that does the trick!! Guess I will use it this way, it's easier to get the right "underwater color" then... :-)
One strange thing I've experienced is the frame rate of the provided test map... I only get about 17 fps, whereas if I put the new fluid effects in the other example levels, I reach the "normal" 55-60 fps and everything's fine - and I've got no idea what may cause this (since there aren't very much objects in your test mission)...? Do you know what may be the reason?
Anyone else experienced this?
Thanks again for this great improvement!
#15
03/17/2002 (8:16 am)
Yeah,

I turned up my visible distance on that mission. You may want to turn it back down for yourself.

Go into the editor, select the Sky object and reduce the "visibleDistance" field to around "500".

Hope this helps.
#16
03/17/2002 (8:19 am)
Thanx, I should have checked that... :)
#17
03/17/2002 (12:40 pm)
thanks melv, i guess a clean build is gonna make it work gonna try now and ill get u some feedback later :)