Water reflections

Started by
4 comments, last by lgcosta 19 years, 4 months ago
Hi, I´ve been trying to create my water using DirectX using render to texture techniques and then projecting the textures onto the water plane. The problem I find is when I'm projecting the texture. I think I´m a bit lost about mapping the projective texture. I´m already rendering to texture. The code i'm using to calculate the mapping matrix: // WHEN RENDERING TO TEXTURE, AFTER SETTING THE VIEWMATRIX // TO THE REFLECTED ONE D3DXMatrixMultiply(&m_pReflectTexMatrix, &matProj, &matView); D3DXMatrixMultiply(&m_pReflectTexMatrix, &remap, &m_pReflectTexMatrix); And when rendering the water surface: // Set texture. device->SetTexture(0, this->m_pReflectTexture); device->SetTransform(D3DTS_TEXTURE0, &m_pReflectTexMatrix); device->SetTextureStageState(0, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT3 | D3DTTFF_PROJECTED); Do i have to calculate the texture vertices coordinates? How many texture coordinates i need? Does the D3DTTFF_COUNT3 param make sense? How to set the texture coordinates? I´ve been searching on google and already readed Yann's article but I can't understand this points. Thanks
Advertisement
Please, anybody?? Help!
Check out this thread on water reflections. It should give you what you're looking for.
I readed it before, but no answers.
I´m confused about seting and mapping the projective texture.

And, at least for instance, I'm not using vertex shaders.
Ive done it using shaders which i think would really be the best way to do it expecially when it comes to distorting the texture coordinates to give a rippling effect to the reflection and the fact that you`ll have to update the texture coordinates each frame. I think it can be done without them but you`ll have to lock/unlock your vertex buffer each frame which will be quite costly.

For the projective texturing you have to multiply your vertex coordinates by a texture matrix. This is made up by:

texture_matrix = matView * matProjection * remap_matrix;

The remapping matrix is described in Yanns article. For DirectX you need to transpose the one Yann gives as matrices are in a different format in OpenGL.

I then use this as my texture coordinates in my shader. I presume in your case you just use them with the D3DTTFF_PROJECTED flag. Ive not done it that way before so not 100% sure.
The point is that the game is target for an academical study wich doesn't allow me to use vertex shaders.

I understand I need to use the D3DTTFF_PROJECTED flag, but do I have to initialize the texture coordinates? By the way, I'm not really shure how my FVF should be.

Thanks!

This topic is closed to new replies.

Advertisement