DirectX9 ShadowMap problem

Job ID: 34562621

Budget: $200 – $300 USD

Hello,

I am using DirectX9 and C++ to create shadows for my game. (without shaders)
Currently, I have a problem with my shadow: will be casted backwards. (see images for examples)

How I am creating the shadow ?
You can see the shadow-part code here (DirectX8 version) -> https://github.com/NakiuS/Metin2Client/blob/master/source/GameLib/MapOutdoorCharacterShadow.cpp

How I am placing the shadow on my textures ?
I'm placing the shadow with: (Where the object/terrain/etc is rendered)

STATEMANAGER.SaveTextureStageState(1, D3DTSS_TEXCOORDINDEX, D3DTSS_TCI_CAMERASPACEPOSITION);
STATEMANAGER.SaveTextureStageState(1, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT2);
STATEMANAGER.SetTransform(D3DTS_TEXTURE1, &m_matDynamicShadow);
STATEMANAGER.SetTexture(1, m_lpCharacterShadowMapTexture);

where:
m_lpCharacterShadowMapTexture = my ShadowMapTexture
m_matDynamicShadow = m_matViewInverse * m_matLightView * m_matDynamicShadowScale;

To cast the shadow for my entities/object/etc, I'm rendering the scene between "BeginRenderCharacterShadowToTexture()" and "EndRenderCharacterShadowToTexture()"

I want to fix that problem, to cast the shadow only in the front of the objects.
If you are interested, contact me.