@ Matt:

Your code snippet would work on level geometry like HeelX mentioned but that doesn't solve the clipping issue.

@ HeelX:

I think I know a way to solve the clipping issue. Matt his code snippet doens't work on stencil shadows combined with alphablending on models so it's just a matter of finding the right balance and mix between zbuffer and stencil buffer shadows
I did some tests and it seems that when using stencil shadows, the model with alpha blending doens't clip the model's mesh behind it's own. There for, you need to set the stencil shadow variable at a global scope in your script and only enable the cast flag for your warlock itself and not for the box. The warlock has got stencil shadows so they will still contour with the level geometry but the box had got z buffer shadows because the cast flag isn't set so there will be a depth test and the result is writin to the z buffer via z write. Now combining the z buffer with alpha blending, it makes sure that the model will not be visible behind the box's mesh, voila the sorting issue is solved.
I'll show it in the practical way:
Code:
 

var shadow_stencil = on;
var shadow_lod = 3; // increasing the shadows quality

material box // apply this to your box which you knew already, set the shadow flag but don't set the cast flag to avoid stencil shadows.
{
effect =
"technique test
{
pass p0
{
AlphaBlendEnable = True;
SrcBlend = Zero;
DestBlend = One;
}
};";
}

material geometry // Matt his code snippet
{
effect =
"technique test
{
pass p0
{
AlphaBlendEnable = True;
SrcBlend = Zero;
DestBlend = One;
zwriteenable = true;
zenable = true;
colorwriteenable=alpha;
colorwriteenable1=alpha;
colorwriteenable2=alpha;
colorwriteenable3=alpha;
}
};";
}

// Set the cast flag and the shadow flag for the warlock to enable stencil shadow which allows the shadow to contour with the level geometry.



This is the result but mind that I didn't applied any material towards the level geometry which wasn't neccesairy in these images:




Btw, the problem HeelX had, could also be solved via a sprite which should match the geomety of the scene. This is the methode OB original wanted ^^

Cheers

Frazzle


Antec® Case
Intel® X58 Chipset
Intel® i7 975 Quad Core
8 GB RAM DDR3
SSD OCZ®-VERTEX2 3.5 x4 ; HD 600 GB
NVIDIA® GeForce GTX 295 Memory 1795GB