Original Post
I have a texture that is a render target for a reflection and I am having a bit of a problem with projecting it to the water surface. When I use D3DTSS_TCI_CAMERASPACEPOSITION the reflection looks fine if I'm looking at a river bank, but if i look downstream or change the camera x rotation the reflection does not meet up right. Is there an easier or better way to do this? Heres my code for texturing the 2 triangle water: Here is an image of when it looks right
Here is an image of when I adjust the camera angles:
And heres one looking down stream:
g_pD3DDevice->SetTexture( 0, m_pBackgroundTexture);
D3DXMATRIXA16 mat;
mat._11 = 0.8f; mat._12 = 0.0f; mat._13 = 0.0f;
mat._21 = 0.0f; mat._22 = 0.8f; mat._23 = 0.0f;
mat._31 = 0.5f; mat._32 =-0.5f; mat._33 = 1.0f;
mat._41 = 0.0f; mat._42 = 0.0f; mat._43 = 0.0f;
g_pD3DDevice->SetTransform( D3DTS_TEXTURE0, &mat );
g_pD3DDevice->SetTextureStageState( 0, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT3|D3DTTFF_PROJECTED );
g_pD3DDevice->SetTextureStageState( 0, D3DTSS_TEXCOORDINDEX, D3DTSS_TCI_CAMERASPACEPOSITION);