Hi there,
I am trying to implement a full screen shader but I keep getting the dark screen, I look at the code and can't find the problem right now.
Here's the code:
// Variables Declaration
// Game Setup
// Display and Graphics
IF CHECK DISPLAY MODE(1024,768,32)=1
SET DISPLAY MODE 1024,768,32,1,1,0
sw=1024:sh=768
ENDIF
SYNC ON : SYNC RATE 60 // Max 60 fps
GOSUB _createTerrain // OBJ 300
GOSUB _createSkybox // OBJ 400
`Make Water(Objnum , Fxnum ,Imgnum ,Imgsize, Water Height)
MakeWater(500,500,500,512,95)
`Setup Camera 0
AUTOCAM OFF
POSITION CAMERA 0,250,0
SET CAMERA RANGE 1,100000
SET CAMERA FOV 85
BACKDROP OFF
`Shader Effects
LOAD CAMERA EFFECT "shaders/dof.dbs", 1, 0 // file, effect_id, load textures
SET CAMERA EFFECT 0, 1, 1 // camera_id, effect_id, render to image
`Quad Object
MAKE OBJECT PLAIN 2, 2, 2, 1
LOAD EFFECT "shaders/quad.fx", 1, 0
SET OBJECT EFFECT 2,1
`Texture Quad
TEXTURE OBJECT 2,0,1
`EFX
SET EFFECT CONSTANT FLOAT 1,"blur",1
// MAIN 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 400,camera position x(),camera position y()+100,camera position z()
UpDateWater() // Update Water
`Render
HIDE OBJECT 2
SHOW OBJECT 1
SYNC CAMERA 0
`Sync
SHOW OBJECT 2
HIDE OBJECT 1
SYNC MASK %00
SYNC
loop // Loop final
// SUBROUTINES
_createTerrain:
`Make terrain
load image "Media/terrain/texture.bmp", 301
load image "Media/terrain/detail.tga", 302
make object terrain 1
set terrain heightmap 1, "Media/terrain/map.bmp"
set terrain scale 1,19.535, 3.5,19.535
set terrain split 1, 16
set terrain tiling 1, 4
set terrain light 1, 1, -0.25, 0, 1, 1, 0.78, 0.5
set terrain texture 1, 301, 302
build terrain 1
position object 1,-2500,0,-2500
RETURN
_createSkybox:
skyname$ = "media/skies/default/"
`Make Skybox
load object skyname$ + "skybox.x",400
set object light 400,0
scale object 400,20000,15000,20000
set object texture 400,2,0
set object cull 400,0
return
// FUNCTIONS
`----------------------------------------------------
` Create Water
`----------------------------------------------------
function MakeWater(Obj,Shader,Img,ImgSize,Height#)
`Globals
global WaterObj=Obj
global WaterHeight#=Height#
global Fx=Shader
`Setup Cameras
Sw#=screen width():Sh#=screen height()
for c=1 to 2
make camera c
set camera range c,1,15000
set camera aspect c,Sw#/Sh#
backdrop off c
set camera to image c,Img+(c-1),ImgSize,ImgSize
set camera fov c,85
next c
`Make Water plain
load image "media/water/Waves.dds",Img+2
load image "media/water/Fresnel.bmp",Img+3
load image "media/water/WaterMask.bmp",Img+4
make object plain WaterObj,5000,5000
texture object WaterObj,0,Img
texture object WaterObj,1,Img+1
texture object WaterObj,2,Img+2
texture object WaterObj,3,Img+3
texture object WaterObj,4,Img+4
xrotate object WaterObj,270
load effect "fx/Water.fx",Fx,0
set object effect WaterObj,Fx
set object transparency WaterObj,1
endfunction
`----------------------------------------------------
` Update Water
`----------------------------------------------------
function UpDateWater()
`UpDate Water plain
position object WaterObj,object position x(WaterObj),WaterHeight#,object position z(WaterObj)
Hide object WaterObj
`Upade Refract/Reflect cameras
set effect technique Fx,"Refract"
UpDateRefraction()
if camera position y()>WaterHeight#
set effect technique Fx,"ReflectRefract"
UpDateReflection()
else
fog on:fog color rgb(55,65,75)
fog distance 2000
endif
`Show Water
show object WaterObj
sync mask 2^0
endfunction
`----------------------------------------------------
` Refraction Update
`----------------------------------------------------
function UpDateRefraction()
position camera 1,camera position x(),camera position y(),camera position z()
rotate camera 1,camera angle x(),camera angle y(),camera angle z()
if camera position y()>WaterHeight#
set camera clip 1,1,0,WaterHeight#+30,0,0,-1,0
fog on:fog color rgb(55,65,75)
fog distance 250+(camera position y()-WaterHeight#)*10
endif
if camera position y()<WaterHeight#
set camera clip 1,1,0,WaterHeight#-30,0,0,1,0
fog on:fog color rgb(55,65,75)
fog distance 2000
endif
set camera clip 2,0,0,0,0,0,0,0
sync mask 2^1
fastsync
fog off
endfunction
`----------------------------------------------------
` Reflection Update
`----------------------------------------------------
function UpDateReflection()
position camera 2,camera position x(),WaterHeight#-(camera position y()-WaterHeight#),camera position z()
rotate camera 2,-camera angle x(),camera angle y(),camera angle z()
set camera clip 1,0,0,0,0,0,0,0
set camera clip 2,1,0,WaterHeight#-15,0,0,1,0
sync mask 2^2
fastsync
endfunction