Having just posted a problem of no use to anyone, I thought I'd make amends by posting something useful for the community. A simple working water shader.
The shader comprises two scrolling normal maps to generate waves and two specular maps to generate specular reflections. Or in plain english, it is wavy and sparkly. There are no reflections (which is why it is simple), but it is single pass and thus fast. Best used for RTS water.
The shader and the example media are attached in a zip file. I've commented the HLSL code with simple comments about what each bit does. Try changing the normal maps to get different looking waves. Photos of artex walls are perfect for making normal maps of waves (in fact that is ALL artex walls are good for).
You can add the shader to your code using the following:
make object plain TRN_seaobject, sizeX, sizeY
position object TRN_seaobject, X, Y, Z
xrotate object TRN_seaobject, 90
load image "skytop.png", 7
load image "waternorm1.bmp", 8
load image "waternorm2.bmp", 9
load image "waterspec1.bmp", 10
load image "waterspec2.bmp", 11
texture object TRN_seaobject, 0, 7
texture object TRN_seaobject, 1, 8
texture object TRN_seaobject, 2, 9
texture object TRN_seaobject, 3, 10
texture object TRN_seaobject, 4, 11
if effect exist(2)=1 then delete effect 2
load effect "watershader.fx", 2, 0
set object effect TRN_seaobject, 2
set effect constant float 2, "camx", camera position x()
set effect constant float 2, "camy", camera position y()
set effect constant float 2, "camz", camera position z()
set object transparency TRN_seaobject, 5
set alpha mapping on TRN_seaobject, 50
You may need to use different image numbers and will need to declare the object number for the plane.
If you want the sparkly bits to move with the camera view then each time step update the camx, camy, camz variables like this:
if effect exist(2)
set effect constant float 2, "camx", camera position x()
set effect constant float 2, "camy", camera position y()
set effect constant float 2, "camz", camera position z()
endif
Best, Mr Grumpy
GrumpyOne - the natural state of the programmer