Hey CoffeeGrunt, take a look at the ultimate shader pack and fiddle with the parallax mapping and water in there. Thats where I get quite alot of my code ideas!
Example for a small water demo with movable camera etc.
`--------------------
` Fresnel Water
`--------------------
` Evolved shaders
`
`--------------------
`Set Up Display
set window on
set window title "Fresnel Water"
load dll "user32.dll",1
Sw=call dll(1,"GetSystemMetrics",0)
Sh=call dll(1,"GetSystemMetrics",1)
delete dll 1
set display mode Sw,Sh,32,1
maximize window
sync on : sync rate 0
`Set Text
set text font "Verdana"
set text size 13
set text to bold
ink rgb(175,175,175),0
`Setup Camera 0
autocam off
position camera 0,250,0
set camera range 1,100000
set camera fov 65
backdrop off
`Make world
MakeWorld()
`Make Water
MakeWater()
`--------------------
`Start loop
do
`Control Camera
cr#=0:cf#=0
if rightkey()=1 or KEYSTATE(32)=1 then cr#=-5
if leftkey()=1 or KEYSTATE(30)=1 then cr#=5
if upkey()=1 or KEYSTATE(17)=1 then cf#=5
if downkey()=1 or KEYSTATE(31)=1 then cf#=-5
ncr#=curvevalue(cr#,ncr#,5)
ncf#=curvevalue(cf#,ncf#,5)
cx#=cx#+mousemovey()*0.2
cy#=cy#+mousemovex()*0.2
if cx#>80 then cx#=80
if cx#<-80 then cx#=-80
ncx#=curveangle(cx#,ncx#,2)
ncy#=curveangle(cy#,ncy#,2)
move camera ncf#
rotate camera 0,wrapvalue(ncy#-90),0
move camera ncr#
rotate camera 0,wrapvalue(ncy#+90),0
rotate camera ncx#,ncy#,0
`Position sky box to camera
position object 6,camera position x(),camera position y()+100,camera position z()
`Show Textures
if shiftkey()=1 then paste image ImgNum,0,0
if controlkey()=1 then paste image ImgNum+1,0,0
`Change Water Techniques
if KEYSTATE(2)=1
set effect technique FXNum,"FresnelRefractReflect"
Refract=1
Reflect=1
endif
if KEYSTATE(3)=1
set effect technique FXNum,"RefractReflect"
Refract=1
Reflect=1
endif
if KEYSTATE(4)=1
set effect technique FXNum,"Reflect"
Refract=0
Reflect=1
endif
if KEYSTATE(5)=1
set effect technique FXNum,"Refract"
Refract=1
Reflect=0
endif
`Text
center text 400,15,"W/A/S/D - Movement 1 - Fresnel 2 - Reflect/Refract 3 - Reflect 4 - Refract Ctrl/shf - Show Textures"
center text 400,40,"FPS "+str$(screen fps())
`Update Water
UpDateWater()
`Sync/loop
sync
loop
`------------------
` Create World
`------------------
function MakeWorld()
`Make floor
load image "Data/Rocky_cliff_T.BMP",1
make object box 1,5000,1,5000
texture object 1,1
position object 1,0,-10,0
scale object texture 1,60,60
`Make pool walls
load image "Data/lead.BMP",2
make object box 2,20,80,5000:position object 2,2500,0,0
texture object 2,2:SetUVMapping(2, 256/2,256/2,36 )
make object box 3,20,80,5000:position object 3,-2500,0,0
texture object 3,2:SetUVMapping(3, 256/2,256/2,36 )
make object box 4,5000,80,20:position object 4,0,0,2500
texture object 4,2:SetUVMapping(4, 256/2,256/2,36 )
make object box 5,5000,80,20:position object 5,0,0,-2500
texture object 5,2:SetUVMapping(5, 256/2,256/2,36 )
`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
`Make Random objects
for t=10 to 260
make object box t,5+Rnd(80),25+Rnd(150),5+Rnd(80)
position object t,-1000+Rnd(2000),Rnd(400),-1000+Rnd(2000)
rotate object t,Rnd(360),Rnd(360),Rnd(360)
texture object t,2
SetUVMapping(t, 256/2,256/2,36 )
next t
endfunction
`------------------
`------------------
` Create Water
`------------------
function MakeWater()
`Globals
global ObjNum=500
global ImgNum=500
global FXNum=500
global WaterHeight#=10.0
global WaterCamY#
global Refract=1
global Reflect=1
`Setup Refraction Camera
make camera 30
set camera range 30,1,15000
set camera aspect 30,1.325
backdrop off 30
set camera to image 30,ImgNum,512,512 ` set to 256 to speed things up
set camera fov 30,65
`Setup Reflection Camera
make camera 31
set camera range 31,1,15000
set camera aspect 31,1.325
backdrop off 31
set camera to image 31,ImgNum+1,512,512
set camera fov 31,65
`Make Water plain
load image "Data/Waves2.dds",ImgNum+2
make object plain ObjNum,5000,5000
texture object ObjNum,0,ImgNum+2
texture object ObjNum,1,ImgNum
texture object ObjNum,2,ImgNum+1
load effect "FX/Fresnel Water.fx",FXNum,0
set object effect ObjNum,FXNum
xrotate object ObjNum,270
set object transparency ObjNum,1
endfunction
`------------------
`------------------
` UpDate Water
`------------------
function UpDateWater()
`UpDate Water plain
position object ObjNum,object position x(ObjNum),WaterHeight#,object position z(ObjNum)
WaterCamY#=camera position y()-WaterHeight#
Hide object ObjNum
`Upade Refract/Reflect cameras
if Refract=1 then UpDateRefraction()
if Reflect=1 then UpDateReflection()
`Show Water
show object ObjNum
`Mask
sync mask 0x3fffffff
endfunction
`------------------
`------------------
` Refraction Update
`------------------
function UpDateRefraction()
`UpDate Refraction camera
position camera 30,camera position x(),camera position y(),camera position z()
rotate camera 30,camera angle x(),camera angle y(),camera angle z()
`Clip Camera
set camera clip 30,1,0,WaterHeight#+(5+WaterCamY#/25),0,0,-1,0
set camera clip 31,0,0,0,0,0,0,0
`Only sync Camera 30
sync mask 0x40000000
fastsync
fog off
endfunction
`------------------
`------------------
` Reflection Update
`------------------
function UpDateReflection()
`UpDate Reflection camera
position camera 31,camera position x(),WaterHeight#-WaterCamY#,camera position z()
rotate camera 31,-camera angle x(),camera angle y(),camera angle z()
`Clip Camera
ClipY#=WaterCamY#
if ClipY#>100 then ClipY#=100
set camera clip 31,1,0,WaterHeight#-(1+(ClipY#/25)),0,0,1,0
set camera clip 30,0,0,0,0,0,0,0
`Only sync Camera 31
sync mask 0x80000000
fastsync
endfunction
`------------------
`------------------
` UV Texture Mappping
`------------------
function SetUVMapping( O , TSizex# , TSizeY# , Pos )
objpx#=object position x(O)
objpy#=object position y(O)
objpz#=object position z(O)
objax#=object angle x(O)
objay#=object angle y(O)
objaz#=object angle z(O)
objsx#=100*(object size x(O,1)/object size x(O))
objsy#=100*(object size y(O,1)/object size y(O))
objsz#=100*(object size z(O,1)/object size z(O))
position object O,0,0,0
make mesh from object 1,O
make memblock from mesh 1,1
delete mesh 1
rotate object O,0,0,0
scale object O,100,100,100
make mesh from object 1,O
make memblock from mesh 2,1
delete mesh 1
Vertexes=memblock dword(1,8)
VertexSize=memblock dword(1,4)
dim Vx#(3)
dim Vy#(3)
dim Vz#(3)
dim Vindex(3)
for v=0 to Vertexes-3
Vx#(1)=memblock float(1,12+(VertexSize*v)+0)+objpx#
Vy#(1)=memblock float(1,12+(VertexSize*v)+4)+objpy#
Vz#(1)=memblock float(1,12+(VertexSize*v)+8)+objpz#
Vindex(1)=v
v=v+1
Vx#(2)=memblock float(1,12+(VertexSize*v)+0)+objpx#
Vy#(2)=memblock float(1,12+(VertexSize*v)+4)+objpy#
Vz#(2)=memblock float(1,12+(VertexSize*v)+8)+objpz#
Vindex(2)=v
v=v+1
Vx#(3)=memblock float(1,12+(VertexSize*v)+0)+objpx#
Vy#(3)=memblock float(1,12+(VertexSize*v)+4)+objpy#
Vz#(3)=memblock float(1,12+(VertexSize*v)+8)+objpz#
Vindex(3)=v
xn#=(Vy#(2)-Vy#(1))*(Vz#(3)-Vz#(1))-(Vz#(2)-Vz#(1))*(Vy#(3)-Vy#(1))
yn#=(Vz#(2)-Vz#(1))*(Vx#(3)-Vx#(1))-(Vx#(2)-Vx#(1))*(Vz#(3)-Vz#(1))
zn#=(Vx#(2)-Vx#(1))*(Vy#(3)-Vy#(1))-(Vy#(2)-Vy#(1))*(Vx#(3)-Vx#(1))
position object O,0,0,0
point object O,xn#,yn#,zn#
if object angle y(O)<46 and object angle y(O)>-1 then polyangle=1
if object angle y(O)>314 and object angle y(O)<361 then polyangle=1
if object angle y(O)>44 and object angle y(O)<136 then polyangle=2
if object angle y(O)>134 and object angle y(O)<226 then polyangle=4
if object angle y(O)>224 and object angle y(O)<316 then polyangle=5
if object angle x(O)>224 and object angle x(O)<316 then polyangle=6
if object angle x(O)>44 and object angle x(O)<136 then polyangle=3
select polyangle
case 1
u1#=(Vx#(1)/TSizex#):v1#=(Vy#(1)/TSizey#)
u2#=(Vx#(2)/TSizex#):v2#=(Vy#(2)/TSizey#)
u3#=(Vx#(3)/TSizex#):v3#=(Vy#(3)/TSizey#)
endcase
case 2
u1#=-(Vz#(1)/TSizex#):v1#=(Vy#(1)/TSizey#)
u2#=-(Vz#(2)/TSizex#):v2#=(Vy#(2)/TSizey#)
u3#=-(Vz#(3)/TSizex#):v3#=(Vy#(3)/TSizey#)
endcase
case 3
u1#=-(Vx#(1)/TSizex#):v1#=(Vz#(1)/TSizey#)
u2#=-(Vx#(2)/TSizex#):v2#=(Vz#(2)/TSizey#)
u3#=-(Vx#(3)/TSizex#):v3#=(Vz#(3)/TSizey#)
endcase
case 4
u1#=-(Vx#(1)/TSizex#):v1#=(Vy#(1)/TSizey#)
u2#=-(Vx#(2)/TSizex#):v2#=(Vy#(2)/TSizey#)
u3#=-(Vx#(3)/TSizex#):v3#=(Vy#(3)/TSizey#)
endcase
case 5
u1#=(Vz#(1)/TSizex#):v1#=(Vy#(1)/TSizey#)
u2#=(Vz#(2)/TSizex#):v2#=(Vy#(2)/TSizey#)
u3#=(Vz#(3)/TSizex#):v3#=(Vy#(3)/TSizey#)
endcase
case 6
u1#=(Vx#(1)/TSizex#):v1#=(Vz#(1)/TSizey#)
u2#=(Vx#(2)/TSizex#):v2#=(Vz#(2)/TSizey#)
u3#=(Vx#(3)/TSizex#):v3#=(Vz#(3)/TSizey#)
endcase
endselect
write memblock float 2,Pos+(VertexSize*Vindex(1))+0,-u1#
write memblock float 2,Pos+(VertexSize*Vindex(1))+4,-v1#
write memblock float 2,Pos+(VertexSize*Vindex(2))+0,-u2#
write memblock float 2,Pos+(VertexSize*Vindex(2))+4,-v2#
write memblock float 2,Pos+(VertexSize*Vindex(3))+0,-u3#
write memblock float 2,Pos+(VertexSize*Vindex(3))+4,-v3#
next v
undim Vx#(3)
undim Vy#(3)
undim Vz#(3)
undim Vindex(3)
make mesh from memblock 1,2
change mesh O,0,1
delete mesh 1
position object O,objpx#,objpy#,objpz#
rotate object O,objax#,objay#,objaz#
scale object O,objsx#,objsy#,objsz#
delete memblock 1
delete memblock 2
endfunction
`------------------
Features refract and reflection etc, I'm pretty sure this is the method Nighthawk uses...
[url=]
[/url][href]http://www.rampagemod.webs.com[\href]