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

## Recommended Posts

Hellow! When try to implement the demo done by Humus on "http://www.humus.ca/3D/Water.zip",I got some trouble. In his demo, it loads the environment map(cube texture) from 6 pictures.For simplicity,I just create a cube texture with the texture tools provided by dx9 sdk. Things go quite good until the computation of reflection on the water surface,the result is quite different from what I expected.I try many ways to find out the reason,but I failed to do so. How cubetexture is addressed? This is the definition of the vertices from my program: //Room vertices CUSTOMVERTEX3D vertices[]= {// x y z texture_coord {-5, 5, 5, -5, 5, 5}, { 5, 5, 5, 5, 5, 5}, {-5, -5, 5, -5, -5, 5}, { 5, -5, 5, 5, -5, 5}, {-5, 5, -5, -5, 5, -5}, { 5, 5, -5, 5, 5, -5}, {-5, -5, -5, -5, -5, -5}, { 5, -5, -5, 5, -5, -5} }; //water surface CUSTOMVERTEX2D vert[] = {// x y z texture_coord for bump map {-5, 0.0f, 5, 0, 1 },//0 { 5, 0.0f, 5, 1, 1 },//1 { 5, 0.0f, -5, 1, 0 },//2 {-5, 0.0f, -5, 0, 0 },//3 }; The camera position is: m_Eye = D3DXVECTOR3(2.0f, 2.0f, -2.0f); so in the shaders the view vector is computed as: view_vec = position - camera_pos; then: normal = normalize(normal); view_vec = normalize(vie_vec); float3 reflVec = reflect(view_vec, normal); float4 refl = texCUBE(Env, reflVec); But the result is incorrect.

##### Share on other sites
I finally find out the reason.
It is the function "ID3DXConstantTable::SetFloatArray" that causes the issue.
I used it to set the value in my shader program which is of float3 type,maybe the tpye flaot3 just is not the same as a float array with 3 elements.
So I changed to "IDirect3DDevice9::SetVertexShaderConstantF",then result is very good!
What annoyed type conversion!

• ### Game Developer Survey

We are looking for qualified game developers to participate in a 10-minute online survey. Qualified participants will be offered a \$15 incentive for your time and insights. Click here to start!

• 13
• 14
• 40
• 63