... sure guys, after all... i'd be nowhere whithout the generous code sharing of so many others here who are really making the advanced capabilities of the engine accessible.

the code is based on the 'Realistic Water' article from the AUM compilation (AUM 34)...

ok... here it is... for better or worse (sorry for the mixed styles and messy commenting)

basically, all i did was merge the moving water code and Steempipe's water shader code and watershader.fx

you are going to need to make a simple terrain as outlined in the AUM34 Realistic Water article... and you should have Steempipe's demo for the shader file and environment bitmaps... the code simply assigns the material to whatever entity calls the WaterShader action, so assing this action to your water terrain.

also, i am using the version 6 templates, so if you are using the older templates, just pick and choose what you need.



Code:
 



path "C:\\Program Files\\GStudio\\template_6"; // Path to A6 templates directory
path "C:\\Program Files\\GStudio\\template_6\\code"; // Path to A6 template code subdirectory
path "C:\\Program Files\\GStudio\\template_6\\images"; // Path to A6 template image subdirectory
path "C:\\Program Files\\GStudio\\template_6\\sounds"; // Path to A6 template sound subdirectory
path "C:\\Program Files\\GStudio\\template_6\\models"; // Path to A6 template model subdirectory
path "C:\\program files\\gstudio\\work\\text_src";
path "C:\\program files\\gstudio\\work";
path "C:\\program files\\virtuqal sailor\boats\ohio";


include <gid01.wdl>; // global ids
include <display00.wdl>; // basic display settings
include <plSelect.wdl>;
include <cameraTarget.wdl>;
include <miscInput01.wdl>;
include <plBipedInput01.wdl>;
include <bipedPhy01.wdl>;
include <bipedAnim01.wdl>;
include <bipedSnd01.wdl>;
include <plBiped01.wdl>;
include <cameraSelect.wdl>;
include <camera1stPerson01.wdl>;
include <shader_light.wdl>;



bind <watershader.fx>;


string level_str=<movingwatershader.wmb>; // **** THIS IS THE NAME OF THE LEVEL


var video_mode=7;
var video_depth=32;
var video_screen=1;


var index;
var counter;
define amplitude skill1;
define water_speed skill25;
define number_of_vertices 1089;
var vertex_array [1089];

var d3d_automaterial=1;




function init_detail_mapping(){
bmap_to_mipmap(mtl.skin1);
d3d_automaterial=1;
}


sky skycube {
type = <montskya+6.tga>;
flags = cube,visible,overlay;
layer = 1;
}



bmap water_cube=<montskysma+6.tga>;
bmap water_bump=<waterbump5.tga>;


function mtl_water_init()
{

bmap_to_cubemap(bmap_to_mipmap(mtl.skin2));
bmap_to_mipmap(mtl.Skin1);

}

/////////////////////////////////////////////////////////////////////////////////
// The material definition used in the watershader
//
material wave1 {

skin1=water_bump;
skin2=water_cube;

flags=tangent;

event = mtl_water_init;

}



var ShaderCount;

//////////////////////////////////////////////////////////////////////////////////
// The action to assign to the water terrain, basically it is the wave code with
// the material used in the shader assigned to the water terrain
//
Action WaterShader
{
my.material = wave1; /// **** THIS MAKES THE TERRAIN USE STEEMPIPE'S
/// WATER SHADER CODE, THAT'S ALL THERE WAS TO IT

my.scale_x=40; /// **** RESIZE THE WATER TERRRAIN MATRIX IF YOU DESIRE
my.scale_y=40;

my.transparent=on; /// **** SEE THRU IT OR NOT WHATEVER
my.nofog = on; /// **** FOG SEEMS TO WORK WITH THIS SHADER IF U WANT IT... COOL


// **** SETTING UP FOR THE WAVES

if (my.amplitude == 0)
{
my.amplitude = 2.84; // default wave amplitude value
}
if (my.water_speed == 0)
{
my.water_speed =7.4; // default wave speed value
}
while (counter < number_of_vertices)
{
vertex_array[counter] = random(360); // set random values in vertex_array
counter += 1;
}


while(1) // **** MAKE WAVES ALL THE TIME
{
my.skill41=float(ShaderCount);
my.skill42=float(0);
my.skill43=float(0);
my.skill44=float(0);

ShaderCount += 0.00287; // ******* AFFECT SPEED OF WAVE MOVEMENT HERE



index = 0;

my.u += .25*time;
my.v += .25*time;
wait (1);



while (index < number_of_vertices)
{
vec_for_mesh(temp, my, index); // store the vertex coordinates in temp
temp.z = sin(counter + vertex_array[index]) * my.amplitude; // change the z component
vec_to_mesh(temp, my, index); // deform the terrain entity
index += 1;
}
counter += my.water_speed * time;
//wait(1);



wait(1);}


}


//////////////////////////////////////////////////////////////////////////////////////
// **** Load the effect file if pixelshader version
// is better then 1.1.
// If not, then exit the Engine.

function load_water_fx() {

if (d3d_shaderversion >= 1111)
{
effect_load(wave1,"watershader.fx");
wait(5);
return;
}
else
{
wait(5);
exit;
}

}


/////////////////////////////////////////////////////////////////
// Desc: The main() function is started at game start
function main()
{
// set some common flags and variables
// freeze all entity functions
freeze_mode = 1;
// no level has been loaded yet...
gid01_level_state = gid01_level_not_loaded;

// entry: Warning Level (0,1, or 2)
// entry_help: Sets sensitivity to warnings (0 = none, 1 = some, 2 = all).
warn_level = 2; // announce bad texture sizes and bad wdl code


// entry: Starting Mouse Mode (0, 1, or 2)
mouse_mode = 0;

// wait 3 frames (for triple buffering) until it is flipped to the foreground
wait(3);

// now load the level
level_load(level_str); // **** LOADS THE LEVEL YOU SET ABOVE


wait(2); // let level load
// level should be loaded at this point...
gid01_level_state = gid01_level_loaded;

load_water_fx(); // **** CALLS THE FUNCTION THAT LOADS THE WATER SHADER


wait(5);




//
// **** MAIN GAME LOOP
while(1)
{
if(gid01_level_state != gid01_level_loaded)
{
// pause the game
freeze_mode = 1;
}
else
{
// un-freeze the game
freeze_mode = 0;
}
wait(1);
}
}


// Desc: this is the function used to restart the game.
function main_restart_game()
{
// wait 3 frames (for triple buffering) until it is flipped to the foreground
wait(3);

// now load the level
level_load(level_str);
// freeze the game
freeze_mode = 1;

load_water_fx();
// fog_color = 1; // use the first fog color
// d3d_fogcolor1.red = 133; // your values here
// d3d_fogcolor1.green =175; // your values here
// d3d_fogcolor1.blue = 255; // your values here
// camera.fog_start = 100; // your values here
// camera.fog_end = 1500; // your values here

wait(2); // 1-level loads, 2-entities load

//+++ load starting values

// un-freeze the game
freeze_mode = 0;
}


// Desc: this is the function used to quit the game.
function main_quit()
{
//+++ // save global skills & strings
exit;
}

/////////////////////////////////////////////////////////////////
// The following definitions are for the pro edition window composer
// to define the start and exit window of the application.
WINDOW WINSTART
{
TITLE "3D GameStudio";
SIZE 480,320;
MODE IMAGE; //STANDARD;
BG_COLOR RGB(240,240,240);
FRAME FTYP1,0,0,480,320;
// BUTTON BUTTON_START,SYS_DEFAULT,"Start",400,288,72,24;
BUTTON BUTTON_QUIT,SYS_DEFAULT,"Abort",400,288,72,24;
TEXT_STDOUT "Arial",RGB(0,0,0),10,10,460,280;
}

/* no exit window at all..
WINDOW WINEND
{
TITLE "Finished";
SIZE 540,320;
MODE STANDARD;
BG_COLOR RGB(0,0,0);
TEXT_STDOUT "",RGB(255,40,40),10,20,520,270;

SET FONT "",RGB(0,255,255);
TEXT "Any key to exit",10,270;
}*/


/////////////////////////////////////////////////////////////////
//INCLUDE <debug.wdl>;








--Mike