Hello,
I have been experimenting with shaders, and making shaders.
But I got stuk
.
I have downloaded the dbpro example of The shader pack and I fully converted it to DarkGDK.
Here's the code:
OnCreate(Before Loop):
//Water Test
dbPositionCamera(1100,50,800);
dbSetCameraRange(1,15000);
dbAutoCamOff();
dbColorBackdrop(dbRGB(155,155,155));
dbSetCameraFOV(70);
dbFogOn(); dbFogColor(dbRGB(128,128,128));dbFogDistance(8192);
dbMakeCamera(1);
dbSetCameraRange(1,2,15000);
dbSetCameraFOV(1,70);
dbSetCameraAspect(1,1.33);
dbColorBackdrop(1,0);
dbSetCameraToImage(1,5,512,512);
dbLoadImage("Media/core/water/waves.jpg",6);
dbMakeObjectPlain(2,2500,2500);
dbXRotateObject(2,270);
dbTextureObject(2,0,5);
dbTextureObject(2,1,6);
dbLoadEffect("Media/shaders/water/water.fx",1,0);
dbSetObjectEffect(2,1);
dbSetAlphaMappingOn(2,100);
float OldYpos = dbCameraPositionY();
float WaterHeight=0.0f;
Cycle(InLoop):
//Water Test Update
if(dbKeyState(18)) WaterHeight += 1.0;
if(dbKeyState(19)) WaterHeight -= 1.0;
float Ypos = dbCameraPositionY();
if(Ypos>0)
{
dbPositionCamera(1,dbCameraPositionX(),-Ypos,dbCameraPositionZ());
dbRotateCamera(1,-dbCameraAngleX(),dbCameraAngleY(),dbCameraAngleZ());
}
else
{
dbPositionCamera(1,dbCameraPositionX(),-Ypos,dbCameraPositionZ());
dbRotateCamera(1,-dbCameraAngleX(),dbCameraAngleY(),dbCameraAngleZ());
}
float ro = dbWrapValue(ro+0.5f);
dbPositionObject(2,500+dbSin(ro)*100.0,WaterHeight,500+dbCos(ro)*100.0);
dbHideObject(2);
if(Ypos > WaterHeight)
{
dbSyncMask(0x00000002);
}
Ypos = dbCameraPositionY();
if( (Ypos>WaterHeight) && (OldYpos<WaterHeight) )
{
dbFogOn();dbFogColor(dbRGB(128,128,128)); dbFogDistance(8192);
}
else
{
if( (Ypos>WaterHeight) && (OldYpos>WaterHeight) )
{
dbFogOn();dbFogColor(dbRGB(24,32,48)); dbFogDistance(5,8192);
}
}
OldYpos = Ypos;
dbSync ( );
dbShowObject(2);
if(dbControlKey()==1) dbPasteImage(5,0,0);
dbSyncMask(0x00000001);
Here's a screenshot in a scene of the current water effect.
(I'm sure this has something todo with the camera's.)
I hope somone know's the trick.
Note: I have searched through the forum and I read alot about shader coding and this shader. But didnt work out. I would like to know how I can accomplish the effect, so I can actually learn something from it.
Thanks!
RedEye