Certainly, they do not work.
I'm thinking about posting this in the bug forum...
This is the code for the pic above:
/*
###########################################################
# DGDK 2008 - SET SHADOW SHADING ON EXAMPLE #
# #
# Shadows cannot be seen at certain distances #
# Shadows cause artifacts from certain angles #
# Command parameters are obsolete for DBPro migrations #
# #
###########################################################
*/
#include "DarkGDK.h"
void DarkGDK ( void )
{
char text_line[256];
strcpy(text_line, "SET SHADOW SHADING ON - DGDK NOV08");
//Make two objects that will cast shadow
dbMakeObjectSphere(1, 10.0f);
dbPositionObject (1, 0.0f, 0.0f, 0.0f);
dbMakeObjectCube(2, 50.0f);
dbPositionObject(2, 0.0f, 0.0f, 35.0f);
//Make a 'ground' plane, just to see shadow result
dbMakeObjectPlane (3, 1000.0f, 1000.0f);
dbRotateObject (3, 90.0f, 0.0f, 0.0f);
dbPositionObject (3, 0.0f, -100.0f, 0.0f);
//Set up light 0 for shadow casting
dbSetPointLight(0, 10, 10, -10);
dbSetLightRange(0, 50000);
//Position camera
dbPositionCamera(-75, 0, -50);
dbPointCamera (0, 0, 30);
//Turn on shadows
dbSetShadowShadingOn(1);
dbSetShadowShadingOn(2);
//dbSetShadowShadingOn RAISES AN ERROR WHEN USING ADDITIONAL PARAMETERS
//dbSetShadowShadingOn(2,2,0.1f,1);
while (LoopGDK() )
{
dbSetCursor(0,0);
dbPrint(text_line);
dbPrint(dbStr(dbScreenFPS()));
dbRotateObject(1, dbObjectAngleX(1)+0.1f, 0.0f, 0.0f);
dbControlCameraUsingArrowKeys(0, 5, 5);
dbSync();
}
}
Well I have to say that the current DGDK shadows are from the 2003 version, as they behaved exactly the same.
Mike Johnson fixed them for DGDK 2005, and they were working solid.
What I don't understand is why we have again the 2003 shadows for DGDK 2008.
It should be quite simple to bring in Mike's 2005 fixing, uh
djbneben, a couple of comments about your code:
- You must position light 0 in the sun position. Light 0 is the only one that can cast shadows, do something like this:
//Position the sun object.
dbPositionObject (2, 0, YPos, 0.0);
//Position light 0 for shadow casting (same position as the sun)
dbSetPointLight (0, 0, YPos, 0.0);
- I don't understand why you set the dbSetShadowShadingOn mesh parameter to -1:
dbSetShadowShadingOn (5, -1, 128, 1);
Are you sure that's right?