Jump to content
  • Advertisement
Sign in to follow this  
lgcosta

Water reflections

This topic is 4946 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
Advertisement
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!