It looks like you have an object the is being hidden/shown in there somewhere... The Shadowmapping demo that I posted doesnt require objects to be masked or hidden/shown, just the camera(and objects that you DONT want to cast shadows)
Thats what it looks like from the code you posted, the Jittmermap looks like its being made correctly but I cant tell from what you have posted if the rest would be working correctly or not it looks mostly right except for the hiding of the object...
Here is the full working source code to my shadowmapping demo(using evolved's shader) You can see if you have a look through that the objects in there arent being masked/hidden at all..
#include "DarkGDK.h"
// CHANGE THIS TO 0 TO USE PREMADE MEDIA, CHANGE TO 1 TO GENERATE MASK AND JITTERMAP
const int USE_DYNAMIC_MASK = 1;
// the main entry point for the application is this function
void DarkGDK ( void )
{
int x = 0, z = 0, y = 0;
// turn on sync rate and set maximum rate to 60 fps
dbSyncOn ( );
dbSyncRate ( 60 );
int Sw=1024; int Sh=768;
dbSetDisplayMode(Sw, Sh, 32);
dbSetWindowPosition(0, 0);
dbSetWindowTitle(" -- EVOLVED's Depth Shadow Mapping Shader -- DarkGDK Shader Example ");
//`Set Text
dbSetTextFont("Verdana");
dbSetTextSize(15);
dbSetTextToBold();
dbInk(dbRGB(200,200,0), 0);
//`Setup Camera
dbBackdropOn();
dbColorBackdrop(dbRGB(128, 128, 128));
dbAutoCamOff();
dbPositionCamera(0, 0, -150);
dbSetCameraFOV(100);
dbXRotateCamera(30);
float CamDis = -200;
int shmask = 3;
//shadow mask
if(USE_DYNAMIC_MASK == 0)
{
dbLoadImage("Media/spotlight.bmp", shmask); //- uncomment this to load the normal spotlight image
}
else if(USE_DYNAMIC_MASK == 1)
{
int shmask = 3;
dbMakeMemblock(1, 12 + (1024 * 1024 * 4));
dbWriteMemblockDword(1, 0, 1024);
dbWriteMemblockDword(1, 4, 1024);
dbWriteMemblockDword(1, 8, 32);
int Pos = 0;
for(x = 0; x <= 1023; x++)
{
for(z = 0; z <= 1023; z++)
{
Pos = (12 + (z * (1024 * 4)) + (x * 4));
if(x > 1 && x < 1022 && z > 1 && z < 1022)
{
dbWriteMemblockByte(1, Pos + 2, 255);
dbWriteMemblockByte(1, Pos + 1, 255);
dbWriteMemblockByte(1, Pos + 0, 255);
dbWriteMemblockByte(1, Pos + 3, 255);
}
else
{
dbWriteMemblockByte(1, Pos + 2, 0);
dbWriteMemblockByte(1, Pos + 1, 0);
dbWriteMemblockByte(1, Pos + 0, 0);
dbWriteMemblockByte(1, Pos + 3, 0);
}
}//next z
}//next x
dbMakeImageFromMemblock(shmask, 1);
dbDeleteMemblock(1);
}
int jittermap = 5;
//`Jitter Map
if(USE_DYNAMIC_MASK == 0)
{
dbLoadImage("Media/JitterMap.dds", jittermap); // - normal jittermap image
}
else if(USE_DYNAMIC_MASK == 1)
{
dbMakeMemblock(1, 12 + (64 * 64 * 4));
dbWriteMemblockDword(1, 0, 64);
dbWriteMemblockDword(1, 4, 64);
dbWriteMemblockDword(1, 8, 32);
int Pos = 0;
for(x = 0; x <= 63; x++)
{
for(z = 0; z <= 63; z++)
{
Pos = (12 + (z * (64 * 4)) + (x * 4));
dbWriteMemblockByte(1, Pos + 2, dbRnd(255));
dbWriteMemblockByte(1, Pos + 1, dbRnd(255));
dbWriteMemblockByte(1, Pos + 0, dbRnd(255));
dbWriteMemblockByte(1, Pos + 3, dbRnd(255));
}//next z
}//next x
dbMakeImageFromMemblock(jittermap, 1);
dbDeleteMemblock(1);
}
//`Load Textures
dbLoadImage("Media/Floor05.jpg", 1); int image = 1;
dbLoadImage("Media/Floor05n.jpg", 2);
dbMakeCamera(1);
dbSetCameraToImage(1, 4, 512, 512);
dbSetCameraFOV(1, 80);
dbSetCameraAspect(1, 1.1);
dbBackdropOff(1);
//`Create Object
dbLoadEffect("FX/ShadowMapping.fx", 1, 0);
dbLoadObject("Media/t-pot.x", 1); int object = 1;
dbScaleObject(1, 4500, 4500, 4500);
dbScaleObjectTexture(1, 0, 4, 3);
dbTextureObject(1, 0, 1);
dbTextureObject(1,1,2);
dbTextureObject(1,2,3);
dbTextureObject(1,3,4);
dbTextureObject(1,4,5);
dbSetObjectEffect(1, 1);
//`Create floor
dbMakeObjectBox(2,500,1,500);
dbPositionObject(2,0,-65,0);
dbTextureObject(2,0,1);
dbTextureObject(2,1,2);
dbTextureObject(2,2,3);
dbTextureObject(2,3,4);
dbTextureObject(2,4,5);
dbScaleObjectTexture(2,0,5,5);
dbSetObjectEffect(2,1);
//`Light
float LX = -56; float LY = 200; float LZ = -26;
float LaX = 56; float LaY = 83; float LaZ = 0;
int Null = dbMakeMatrix4(1);
Null = dbMakeMatrix4(2);
Null = dbMakeMatrix4(3);
Null = dbMakeVector4(6);
// scancode checkers and state checkers
int nopress = 0, rotate = 0;
// our main loop
LX = 0;
LY = 350;
LZ = -100;
LaX = 70;
LaY = 0;
LaZ = 0;
dbSetVector4(6, LX, LY, LZ, 0);
dbSetEffectConstantVector(1, "LightPosition", 6);
while ( LoopGDK ( ) )
{
//`Control Camera
dbPositionCamera(0, 0, 0);
if(dbMouseClick() == 0)
{
dbXRotateCamera(dbCameraAngleX() - dbMouseMoveY() * 0.25);
dbYRotateCamera(dbCameraAngleY() - dbMouseMoveX() * 0.25);
if(dbCameraAngleX() > 80) dbXRotateCamera(80);
if(dbCameraAngleX()< -60) dbXRotateCamera(-60);
}
if(dbMouseClick() > 0) CamDis -= dbMouseMoveY() * 0.25;
CamDis += dbMouseMoveZ() * 0.25;
if(dbUpKey() == 1) CamDis += 2.5;
if(dbDownKey() == 1) CamDis -= 2.5;
if(CamDis > -20) CamDis = -20;
if(CamDis < -300) CamDis = -300;
dbMoveCamera(CamDis);
if(dbCameraPositionY() < -60) dbPositionCamera(dbCameraPositionX(), -60, dbCameraPositionZ());
// `Rotate object
if(dbKeyState(19) == 1 && rotate == 1 && nopress == 0)
{
rotate = 0;
nopress = 1;
}
if(dbKeyState(19) == 1 && rotate == 0 && nopress == 0)
{
rotate = 1;
nopress = 1;
}
if(rotate == 0)
{
dbRotateObject(1, 0, dbObjectAngleY(1) + 0.5, 0);
}
//`Change Texture
if(dbKeyState(20) == 1 && nopress == 0)
{
dbDeleteImage(1);
dbDeleteImage(2);
++image;
if(image > 3) image = 1;
if(image == 1)
{
dbLoadImage("Media/Floor05.jpg", 1);
dbLoadImage("Media/Floor05n.jpg", 2);
}
if(image == 2)
{
dbLoadImage("Media/Floor29.jpg",1);
dbLoadImage("Media/Floor29n.jpg",2);
}
if(image == 3)
{
dbLoadImage("Media/Mud.jpg",1);
dbLoadImage("Media/Mudn.jpg",2);
}
dbTextureObject(1, 0, 1);
dbTextureObject(1, 1, 2);
dbTextureObject(2, 0, 1);
dbTextureObject(2, 1, 2);
nopress = 1;
}
//`Change Object
if(dbSpaceKey() == 1 && nopress == 0)
{
dbDeleteObject(1);
++object;
if(object > 5) object = 1;
if(object == 1) {dbLoadObject("Media/t-pot.x", 1);dbScaleObject(1,4500,4500,4500);dbScaleObjectTexture(1,0,4,3);}
if(object == 2) {dbLoadObject("Media/Tosus.x",1); dbScaleObjectTexture(1,0,1.5,1);}
if(object == 3) {dbMakeObjectBox(1, 75,75,75);}
if(object == 4) {dbMakeObjectSphere(1,75,40,40);dbScaleObjectTexture(1,0,2,1);}
if(object == 5) {dbMakeObjectCylinder(1,75);dbScaleObjectTexture(1,0,3,1);}
dbTextureObject(1,0,1);dbTextureObject(1,1,2);dbTextureObject(1,2,3);
dbTextureObject(1,3,4);dbTextureObject(1,4,5);
dbSetObjectEffect(1,1);
nopress = 1;
}
if(dbScanCode() == 0) nopress = 0;
//`Set spot Light to camera position
if(dbShiftKey() == 1)
{
LX = dbCameraPositionX();
LY = dbCameraPositionY();
LZ = dbCameraPositionZ();
LaX = dbCameraAngleX();
LaY = dbCameraAngleY();
LaZ = dbCameraAngleZ();
}
dbSetVector4(6, LX, LY, LZ, 0);
dbSetEffectConstantVector(1, "LightPosition", 6);
//`Text
dbCenterText(Sw/2, 15, "1 - Show Depth Texture Shift - Set Spot Light To Camera Space - Change Object T - Change Texture R - Rotate Object");
char* buf = new char[56];
strcpy(buf, "Screen FPS : ");
strcpy(buf, dbStr(dbScreenFPS()));
dbCenterText(Sw/2, 40, buf);
//`Set effects projection Matrix
dbSetCurrentCamera(1);
dbPositionCamera(1, LX, LY, LZ);
dbRotateCamera(1, LaX, LaY, LaZ);
dbViewMatrix4(1);
dbProjectionMatrix4(2);
dbMultiplyMatrix4(3, 1, 2);
dbSetEffectConstantMatrix(1, "ProjMatrix", 3);
dbSetCurrentCamera(0);
dbSetEffectTechnique(1, "DepthMap");
dbSyncMask(1<<1);
dbFastSync();
if(dbKeyState(2) == 1) dbPasteImage(4, 0, 0);
// `Main Scene
dbSetEffectTechnique(1, "ShadowMapping");
dbSyncMask(1<<0);
// update the screen
dbSync ( );
delete []buf;
}
// return back to windows
return;
}
EDIT : Ignore the weird indentations.... copy/paste doesnt like me sometimes lol good 'ol Visual Studio and it's tabs
If it ain't broke.... DONT FIX IT !!!