if anybody is having trouble adding the water shader in their own projects, here is an easy way.
Rem ***** Main Source File *****
Autocam OFf
Sync On
Set Camera Range 0, 0.1, 50000
`Make Skybox
load object "data/skybox.x",6
set object light 6,0
scale object 6,20000,15000,20000
set object texture 6,2,1
set object cull 6,0
cameraCreateClipping(15000, 128)
shdrWater = freeEffect() : Load Effect "FX/Fresnel Water.fx", shdrWater, 0
Set Effect Constant Float shdrWater, "WaterBump", 0.01
Set Effect Constant Float shdrWater, "FresnelBias", 0.1
Set Effect Constant Float shdrWater, "FresnelScale", 2.5
null = Make Vector4(1)
Set Vector4 1, 10.0, 10.0, 0.0, 0.0 : Set Effect Constant Vector shdrWater, "WaterScale", 1
Set Vector4 1, -0.05, 0.0, 0.0, 0.0 : Set Effect Constant Vector shdrWater, "Speed1", 1
Set Vector4 1, 0.2, -0.02, 0.0, 0.0 : Set Effect Constant Vector shdrWater, "Speed2", 1
Set Vector4 1, 0.01, 0.01, 0.0, 0.0 : Set Effect Constant Vector shdrWater, "Speed3", 1
water = shdrCreateWaterPlain(5000, 5000, 270, shdrWater)
obj = freeObject()
Make Object Sphere obj, 50
Position Object obj, 0, 100, 100
Do
ax# = WrapValue(ax# + mouseMoveY())
ay# = WrapValue(ay# + mouseMoveX())
Rotate Camera ax#, ay#, 0.0
If MouseClick()=1 Then Move Camera 1
If MouseClick()=2 Then Move Camera -1
`Show Textures
if shiftkey()=1 then paste image imgClipCam1,0,0
if controlkey()=1 then paste image imgClipCam2,0,0
shdrUpdateWaterPlain(shdrWater, water, 0, 0, 0)
Sync
Loop
Function cameraCreateClipping(camRange As Integer, camImgSize As Byte)
For cam = 30 To 31
Make Camera cam
Set Camera Range cam, 1, camRange
Set Camera Aspect cam, 1.325
Set Camera Fov cam, 65
Backdrop Off cam
Next cam
GLOBAL imgClipCam1
GLOBAL imgClipCam2
imgClipCam1 = freeImage()
imgClipCam2 = imgClipCam1+1
Set Camera To Image 30, imgClipCam1, camImgSize, camImgSize
Set Camera To Image 31, imgClipCam2, camImgSize, camImgSize
EndFunction
Function shdrCreateWaterPlain(w As Integer, h As Integer, ang As Word, effect As Integer)
img = freeImage() : Load Image "FX/waves.dds", img
obj = freeObject() : Make Object Plain obj, w, h
Texture Object obj, 0, img
Texture Object obj, 1, imgClipCam1
Texture Object obj, 2, imgClipCam2
xRotate Object obj, ang
Set Object Effect obj, effect
Set Object Transparency obj, 1
`Ghost Object On obj, 0
EndFunction obj
Function shdrUpdateWaterPlain(shdrWater As Integer, obj As Integer, x As Float, y As Float, z As Float)
Position Object obj, x, y, z
camWaterY# = Camera Position Y() - y
Set Effect Technique shdrWater, "Reflect"
Hide Object obj
Position Camera 31, Camera Position X(), y-camWaterY#, Camera Position Z()
Rotate Camera 31, -Camera Angle X(), Camera Angle Y(), Camera Angle Z()
`Clip Camera
clipY# = camWaterY#
If clipY# > 100 Then clipY# = 100
If camWaterY# => 0.0 Then clipIt = 1
If camWaterY# < 0.0 Then clipIt = -1
Set Camera Clip 31, 1, 0, y-(1+(clipY#/25)), 0, 0, clipIt, 0
Set Camera Clip 30,0,0,0,0,0,0,0
`Only sync Camera 31
Sync Mask 0x80000000
FastSync
Show Object obj
Sync Mask 0x3fffffff
EndFunction
`>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Function freeImage()
Repeat
Inc i
Until Image Exist(i) = 0
EndFunction i
`<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
`>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Function freeObject()
Repeat
Inc i
Until Object Exist(i) = 0
EndFunction i
`<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
`>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Function freeEffect()
Repeat
Inc i
Until Effect Exist(i) = 0
EndFunction i
`<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<