Game Development Community

Slowly move water on Z axis

by Andrew Edmonds · in Torque Game Engine Advanced · 03/26/2007 (11:41 am) · 12 replies

Hi all,

I want to create a crude shoreline effect (just for a proof of concept). From manually testing in the editor it looks like I can create a basic effect by moving the water plane up and down slowly on the Z axis by about 2-3 units. Has anyone tried this or have any tips on how to go about doing it?

I imagine this kind of thing would be best done in engine code rather than in script but if anyone has any ideas please let me know!

Thanks all...

About the author

Formed in 2005, EiKON Games is an indie games development project based in the UK working on the tactical first person shooter "Epoch: Incursion". See the Join Us or Contact Us pages at http://www.eikon-games.com/


#1
03/26/2007 (1:29 pm)
You could add a simple wave motion in the vertex shader if all you want is some movement at the shore..
#2
03/26/2007 (1:31 pm)
Ah, now that sounds like a much better idea.. except I haven't got my head around hlsl yet. any tips? :o)
#3
03/27/2007 (6:06 am)
I'm sure there are a billion and one tutorials out there on shader programming. I'd recommend:

http://www.amazon.co.uk/Programming-Vertex-Shaders-Charles-Graphics/dp/1584503491/ref=sr_1_1/026-6303169-8160468?ie=UTF8&s=books&qid=1175000396&sr=8-1

What you need to do, is get the position of each vertex and change its z value, I'd recommend trying out a simple sin(value) kind of thing first..
#4
03/27/2007 (6:43 am)
Thanks Phil - It's on my to-do list :o)
#5
03/28/2007 (7:12 am)
I dunno... i haven't looked at it yet, or maybe i have a while back, and fogotten... but me doubts that there'll be enough vertices in that there water mesh to really move it around any...

...but again, i'm not up on it, so i may be wrong on this.

what i'd really like to do with TGEA water is something similar to what i did with in Blitz3D...

home.att.net/~subbase1/DiveDive.wmv


--Mike
#6
03/28/2007 (7:57 am)
You can increase the tesselation of the water mesh by decreasing the gridSize.
#7
03/28/2007 (8:33 am)
I did a quick prototype of this a while back, no view based adaptive tessellation or anything just increased the base tessellation of the waterblock and updated the z values in the shader using an assortment of functions, first basic sin() stuff for testing, then interference patterns, FFTs etc.

Was quite quick to implement and the effect of watching it from far above with huge waves made me feel like surfing ;p
#8
03/28/2007 (8:47 am)
All I'm looking for at this stage is to have a slightly less static shoreline. Just a tiny bit of movement up and down the beach gives the effect quite nicely (for a prototype).

The angle the beach is at means that just 2-3 units up and down gives a nice in-and-out motion on the shoreline.
#9
03/28/2007 (8:52 am)
Ah so youre looking more for a sort of gentle lapping at the shore.

Simple is best then and what you are doing will do the trick - perhaps just add a bit of foam or small wavelet texture animation on top to improve the effect.
#10
03/28/2007 (9:45 am)
Eikon: yeah, basically what Neo suggested as his prototype would work for what you want. So basically:

Lower the gridsize of the water so you get more vertices in it.
Modify the shader to slowly animate the Z value of the vertex position (look at the vertex shader for the water, you should see a position value, simply animate the .z of that (possibly as a function of the X and Y vertex position and the time, using a sin(x+y*time) kind of thing. Add a scale factor so you can play with the heights of the waves and you should be golden.
#11
03/28/2007 (10:10 am)
That seems to make a lot of sense!

Thanks Phil & Neo - I'll give that a try.
#12
03/28/2007 (3:39 pm)
Yeah... me too... looks like i'm quite lost on this...

thx

--Mike