i finally got the shadow shader code working... seems as if there's some issues with the ambient shader and the shadow shader...
i had to use based cpu shadows, and substitued the code that caled for the ambient shader effect to dbSetObjectAmbience()...
anyways, here's the code... just substitue it in the source file for the project you already have working...
//====================================================
//Normal Mapping + Soft Shadows
//
//By EVOLVED
// http://www.vector3r.com/
//====================================================
#include "stdafx.h"
#include "DarkGDK.h"
int Sw,Sh;
double CamDist,ShadowSize,CamDis;
int image,object,lz,lzx,lzSwitch;
int vec,mat,myvec,t;
double ang,ang2;
//void SetUpObject(int obj);
int MoveLight, nopress;
void SetUpObject(int obj){
//
//Light Object 1
dbCloneObject( obj+100,obj);
//dbLoadObject("c:\\program files\\3impact4\\3impactwork\\mygame_res\\typexxiii\\type232.dbo",obj+100 );
if (obj==1){
dbTextureObject( obj+100,0,11);
dbTextureObject( obj+100,1,12);
}
if (obj==2){
dbTextureObject( obj+100,0,1);
dbTextureObject( obj+100,1,2);
}
dbTextureObject( obj+100,3,4);
dbSetObjectEffect (obj+100,2);
//
// //Light Object 2
dbCloneObject( obj+200,obj);
//dbLoadObject("c:\\program files\\3impact4\\3impactwork\\mygame_res\\typexxiii\\type232.dbo",obj+200 );
if (obj==1){
dbTextureObject( obj+200,0,11);
dbTextureObject( obj+200,1,12);
}
if (obj==2){
dbTextureObject( obj+200,0,1);
dbTextureObject( obj+200,1,2);
}
dbTextureObject( obj+200,2,3);
dbTextureObject( obj+200,3,5);
dbSetObjectEffect (obj+200,3);
//dbHideObject(obj+200); // for no cubic reflects just hide it
//
// //Shadow Object
dbCloneObject (obj+300,obj);
dbTextureObject( obj+300,0);
dbSetObjectEffect( obj+300,0);
dbSetObjectLight (obj+300,0);
if (obj==1)dbSetShadowShadingOn( obj+300,-1,1400,0);
//
}
void DarkGDK ( void )
{
//dbSet Up Display
dbSetWindowOn();
dbSetWindowTitle ("Normal Mapping + Soft Shadows");
dbLoadDLL ("user32.dll",1);
Sw=dbCallDLL(1,"GetSystemMetrics",0);
Sh=dbCallDLL(1,"GetSystemMetrics",1);
dbDeleteDLL( 1);
dbSetDisplayMode( Sw,Sh,32);
//dbMaximizeWindow();
dbSyncOn();
dbSyncRate (60);
dbBackdropOn();
dbBackdropColor(dbRGB(0,0,0));
//dbdbSet Text
dbSetTextFont ("Verdana");
dbSetTextSize (12);
dbSetTextToBold();
dbInk(dbRGB(200,200,0),0);
//dbdbSetup Camera
CamDis=-100;
dbAutoCamOff();
dbPositionCamera (0,0,-150);
dbSetCameraFOV(100);
dbXRotateCamera (30);
//Load Textures
dbLoadImage( "c:\\downloads\\Media\\wood.tga",1);
//dbLoadImage( "c:\\program files\\3impact5\\3impactwork\\mygame_res\\lift.bmp",1);
image=1;
dbLoadImage( "c:\\downloads\\Media\\Wood_n.dds",2);
dbLoadImage( "c:\\downloads\\Media\\DiscoLight.dds",3,2);
dbLoadImage( "c:\\program files\\3impact5\\3impactwork\\mygame_res\\lift.bmp",11);
dbLoadImage( "c:\\program files\\3impact5\\3impactwork\\mygame_res\\liftnormalmap.dds",12);
//
// //Ambient
dbLoadEffect( "c:\\downloads\\FX\\Ambient.fx",1,0);
dbSetGlobalShadowColor( 0,0,0,255);
ShadowSize=1.5;
//
// //Light 1
dbLoadEffect( "c:\\downloads\\FX\\NormalMapping.fx",2,0);
dbSetEffectConstantFloat( 2,"ViewScaleX",100.0/(Sw/ShadowSize));
dbSetEffectConstantFloat(2,"ViewScaleY",100.0/(Sh/ShadowSize));
dbMakeCamera(1);
dbSetCameraToImage( 1,4,Sw/ShadowSize,Sh/ShadowSize);
dbSetCameraFOV(1,100);
dbBackdropOff (1);
// //Light 2
dbLoadEffect( "c:\\downloads\\FX\\NormalMapping.fx",3,0);
dbSetEffectConstantFloat( 3,"ViewScaleX",100.0/(Sw/ShadowSize));
dbSetEffectConstantFloat(3,"ViewScaleY",100.0/(Sh/ShadowSize));
dbSetEffectConstantFloat( 2,"LightRange",1475.0f);
dbSetEffectConstantFloat( 3,"LightRange",1475.0f);
dbMakeCamera(2);
dbSetCameraToImage( 2,5,Sw/ShadowSize,Sh/ShadowSize);
dbSetCameraFOV(2,100);
dbBackdropOff (2);
// //Create Object
//dbMakeObjectBox( 1,75,75,75) ;
dbLoadObject("c:\\program files\\3impact4\\3impactwork\\mygame_res\\typexxiii\\type23.x",1 );
object=1;
dbTextureObject( 1,0,11);
dbScaleObject(1,420.5,420.5,420.5);
//dbSetObjectEffect(1,1);
dbSetObjectAmbience(1,dbRGB(122,122,122));
//
// //Create floor
dbMakeObjectBox( 2,500,1,500);
dbPositionObject( 2,0,-165,0);
dbScaleObject(2,500.0,100.0,500.0);
dbScaleObjectTexture( 2,0,5,5);
dbTextureObject( 2,0,1);
dbSetObjectEffect (2,1);
//
// //Glue Floor To Cyl
//dbMakeObjectCube( 1003,10);
//dbHideObject( 1003);
//dbMakeMeshFromObject( 1,1003);
//dbAddLimb(1,2,1);
//dbHideLimb(1,2);
//dbOffsetLimb(1,2,0,-14,0);
//dbGlueObjectToLimb( 2,1,2);
SetUpObject(1);
SetUpObject(2);
//
// //Create Sky
dbLoadImage( "c:\\downloads\\Media\\SkyBox.dds",8,2);
dbMakeObjectSphere( 3,2000,5,5);
dbSetObjectCull (3,0);
dbTextureObject( 3,0,8);
dbLoadEffect( "c:\\downloads\\FX\\SkyBox.fx",4,0);
dbSetObjectEffect (3,4);
//
// //Make Light objects
dbLoadImage( "c:\\downloads\\Media\\Flare.JPG",20);
dbMakeObjectPlain( 20,50,50);
dbTextureObject( 20,20);
dbGhostObjectOn(20);
dbSetObjectAmbient( 20,0);
dbMakeObjectPlain( 21,50,50);
dbTextureObject( 21,20);
dbGhostObjectOn( 21);
dbSetObjectAmbient( 21,0);
vec = dbMakeVector4(1);
mat = dbMakeMatrix4(2);
mat = dbMakeMatrix4(3);
mat = dbMakeMatrix4(4);
mat = dbMakeMatrix4(5);
myvec=dbMakeVector4(6);
//
////----------------------------------------------------
// //Start loop
while ( LoopGDK ( ) )
{
//
//dbOffsetLimb( 1,2,0,-164,lzx);
if ((lzSwitch==0) && ( lzx>60)) lzSwitch= 1;
if ((lzSwitch==1) && ( lzx<1)) lzSwitch= 0;
if (lzSwitch==1) lzx=lzx-1;
if (lzSwitch==0) lzx=lzx+1;
// //Control Camera
dbPositionCamera (0,0.0,0.0,0.0);
// if mouseclick()=1
// xrotate camera camera angle x()-mousemovey()*0.25
// yrotate camera camera angle y()+mousemovex()*0.25
// if camera angle x()>80 then xrotate camera 80
// if camera angle x()<-60 then xrotate camera -60
// endif
// if mouseclick()=2 then CamDis#=CamDis#-mousemovey()*0.25
CamDis=CamDis+dbMouseMoveZ()*0.25;
// if upkey()=1 then CamDis#=CamDis#+2.5
// if downkey()=1 then CamDis#=CamDis#-2.5
// if CamDis#>-20 then CamDis#=-20
// if CamDis#<-300 then CamDis#=-300
dbMoveCamera (0,CamDis);
if (dbCameraPositionY(0)<-60) dbPositionCamera( dbCameraPositionX(0),-60, dbCameraPositionZ(0));
//dbMouseMoveX()=0;
//dbMouseMoveY()=0;
dbPositionCamera(1,dbCameraPositionX(0),dbCameraPositionY(0),dbCameraPositionZ(0));
dbRotateCamera( 1,dbCameraAngleX(0),dbCameraAngleY(0),dbCameraAngleZ(0));
dbPositionCamera(2,dbCameraPositionX(0),dbCameraPositionY(0),dbCameraPositionZ(0));
dbRotateCamera( 2,dbCameraAngleX(0),dbCameraAngleY(0),dbCameraAngleZ(0));
//
// //Move Lights
if ((dbKeyState(38)==1)&&( MoveLight==1)&&( nopress==0)) MoveLight=0;
nopress=1;
if ((dbKeyState(38)==1)&&( MoveLight==0)&&( nopress==0)) MoveLight=1;
nopress=1;
if (MoveLight==0){
//Light 1
ang=dbWrapValue(ang+0.025);
dbPositionObject( 20,cos(ang)*190,400+sin(ang)*2,sin(ang)*190);
dbSetVector4( 1,dbObjectPositionX(20),dbObjectPositionY(20),dbObjectPositionZ(20),0);
dbSetEffectConstantVector( 2,"LightPosition",1);
// //Light 2
ang2=dbWrapValue(ang2-0.025);
dbPositionObject( 21,cos(ang2)*190,400+sin(ang2)*2,sin(ang2)*190);
dbSetVector4( 1,dbObjectPositionX(21),dbObjectPositionY(21),dbObjectPositionZ(21),0);
dbSetEffectConstantVector( 3,"LightPosition",1);
dbRotateXMatrix4(2,(ang2*4)/57.3); dbRotateYMatrix4(3,(ang2*4)/57.3);dbRotateZMatrix4(4,(ang2*4)/57.3);
dbMultiplyMatrix4( 5,2,3); dbMultiplyMatrix4( 5,5,4);
dbSetEffectConstantMatrix( 3,"LightAngle",5);
}
dbPointObject( 20,dbCameraPositionX(0),dbCameraPositionY(0),dbCameraPositionZ(0));
dbPointObject( 21,dbCameraPositionX(0),dbCameraPositionY(0),dbCameraPositionZ(0));
//
// //Rotate object
// if KEYSTATE(19)=1 and rotate=1 and nopress=0 then rotate=0:nopress=1
// if KEYSTATE(19)=1 and rotate=0 and nopress=0 then rotate=1:nopress=1
// if rotate=0
// rotate object 1,object angle x(1)+0.25,object angle y(1)+0.25,object angle z(1)+0.25
// rotate object 1+100,object angle x(1),object angle y(1),object angle z(1)
// rotate object 1+200,object angle x(1),object angle y(1),object angle z(1)
// rotate object 1+300,object angle x(1),object angle y(1),object angle z(1)
// endif
//
// //Change Texture
// if KEYSTATE(20)=1 and nopress=0
// delete image 1:delete image 2
// inc image
// if image>3 then image=1
// if image=1 then dbLoadImage( "Media\\Wood.tga",1 :dbLoadImage( "Media\\Wood_n.tga",2
// if image=2 then dbLoadImage( "Media\\Tile.jpg",1 :dbLoadImage( "Media\\Tile_n.bmp",2
// if image=3 then dbLoadImage( "Media\\Fieldstone.tga",1 :dbLoadImage( "Media\\Fieldstone_n.tga",2
// dbTextureObject( 1,0,1
// dbTextureObject( 1+100,0,1:dbTextureObject( 1+100,1,2
// dbTextureObject( 1+200,0,1:dbTextureObject( 1+200,1,2
// dbTextureObject( 2,0,1
// dbTextureObject( 2+100,0,1:dbTextureObject( 2+100,1,2
// dbTextureObject( 2+200,0,1:dbTextureObject( 2+200,1,2
// nopress=1
// endif
//
// //Change Object
if ((dbSpaceKey()==1) &&( nopress==0)){
dbDeleteObject( 1); dbDeleteObject(1 +100);
dbDeleteObject( 1+200); dbDeleteObject(1 +300);
object++;
if (object>3) object=1;
if (object==1) dbMakeObjectBox( 1,75,75,75);
if (object==2) dbMakeObjectSphere(1,75,40,40); dbScaleObjectTexture( 1,0,2,1);
if (object==3) dbMakeObjectCylinder(1,75); dbScaleObjectTexture( 1,0,3,1);
dbTextureObject( 1,0,1); dbSetObjectEffect( 1,1);
SetUpObject(1);
nopress=1;
}
if (dbScanCode()==0)nopress=0;
//
// //Text
// center text sw/2,20,"1/2 - Show Shadow Textures T - Change Texture Space - Change Object R - Rotate Object L - Move Light"
// center text sw/2,50,"FPS "+str$(screen fps())
//
// //Hide objects
for (int t=1;t<3;t++){
dbExcludeObjectOn( t); dbExcludeObjectOn( t+100);
dbExcludeObjectOn( t+200);dbExcludeObjectOff( t+300);
}
dbExcludeObjectOn( 3);dbExcludeObjectOn(20);dbExcludeObjectOn( 21);
//
////Render Light 1 Shadows
dbSetShadowPosition( -1,dbObjectPositionX(20),dbObjectPositionY(20),dbObjectPositionZ(20));
dbSyncMask(0x00000002); dbFastSync();
if (dbKeyState(2)==1) dbPasteImage( 4,0,0);
//Render Light 2 Shadows
dbSetShadowPosition( -1,dbObjectPositionX(21),dbObjectPositionY(21),dbObjectPositionZ(21));
dbSyncMask(0x00000004); dbFastSync();
if (dbKeyState(3)==1) dbPasteImage( 5,0,0);
//
// //Show objects
for (t=1;t<3;t++){
dbExcludeObjectOff( t); dbExcludeObjectOff( t+100);
dbExcludeObjectOff( t+200); dbExcludeObjectOn( t+300);
}
dbExcludeObjectOff( 3);dbExcludeObjectOff(20);dbExcludeObjectOff( 21);
//
//
// // Play with some lighting effects and Shader Variables
// randomize timer()
// rndX#=rnd(10.0)/10.0
// rndY#=rnd(10.0)/10.0
// rndZ#=rnd(10.0)/10.0
// rndQ#=rnd(255.0)/255.0
//dbSetVector4 (6,random(X+.2,rndY#+.2,rndZ#+.2,0.0
dbSetVector4 (6,0.6f,0.6f,0.6f,0.0f);
dbSetEffectConstantVector( 2,"LightColor",6);
dbSetEffectConstantFloat( 2,"LightRange",1475.0f);
//
//dbSetVector4(6,0.1f,0.1f,0.1f,0);
// dbSetEffectConstantVector (1,"Ambient",6);
//
// dbPerformChecklistForEffectValues( 2);
////for n=1 to checklist quantity()
//// text 44,12*n,checklist string$(n)
////next
////text 44,700,str$(rndQ#)
//
//
dbSyncMask(0x00000001);
dbSync();
}
}
//
and thanks for all the help...
--Mike