This is a continuation of
this post. However, since the topic has kind of changed I thought it would be better to start a new thread that better reflects the current state of things.
After reading pretty much everything I could find (and that I could understand, mind you, some of those texts are really far out there to the point where I have no idea if it even is about shadow mapping or even graphic applications a few pages in) on the subject I came up with an idea of how one should be able to implement cascaded shadow mapping.
I may of course be wrong, but I've rewritten this code (originally in DarkGDK) several times and looked it through many times more - as far as I can tell this really
should work.
I've attached a DBPro project that demonstrates the problems as well as shows what I'm doing.
Since I apparently can't seem to solve this myself I would be very grateful if someone with better math skills / general knowledge of this type of problem would take a look at it and share their ideas about what might be wrong, general improvements (I know some parts could be written in a more efficient way, but that would be less readable so I opted for the latter since I'm trying to dinf issues with this) etc.
In order to compile the attached project you will also need to replace your
Compiler\plugins\DBProBasic3DDebug.dll file with the one included in the attached archive. It contains a customly added function
set effect constant matrix array that lets you set a float4x4 array constant in a shader. I would have added this function to its own plugin instead, but I couldn't find any way to access shader data from outside that core library. It is just a straight recompile of the source found on the official google code repository with added functions
set effect constant matrix array and
set effect constant vector array.
Here's the code for those functions if you prefer to add them yourself in case you've already modded your DBProBasic3DDebug.dll file:
DARKSDK_DLL void SetEffectConstantVArray ( int iEffectID, SDK_LPSTR pConstantName, D3DXVECTOR4 *pArray, int elemCount ) {
// get constant ptr
LPD3DXEFFECT pEffectPtr = SetEffectConstantCore ( iEffectID, pConstantName );
if ( pEffectPtr ) {
// apply value to constant
D3DXHANDLE hParam = pEffectPtr->GetParameterByName ( NULL, (char*)pConstantName );
// Push the input array to the shader
pEffectPtr->SetVectorArray ( hParam, pArray, (UINT)elemCount );
}
}
DARKSDK_DLL void SetEffectConstantMArray ( int iEffectID, SDK_LPSTR pConstantName, D3DXMATRIX *pArray, int elemCount ) {
// get constant ptr
LPD3DXEFFECT pEffectPtr = SetEffectConstantCore ( iEffectID, pConstantName );
if ( pEffectPtr ) {
// apply value to constant
D3DXHANDLE hParam = pEffectPtr->GetParameterByName ( NULL, (char*)pConstantName );
// Push the input array to the shader
pEffectPtr->SetMatrixArray ( hParam, pArray, (UINT)elemCount );
}
}
Well... good luck!
"Why do programmers get Halloween and Christmas mixed up?" Because Oct(31) = Dec(25)