Archived

This topic is now archived and is closed to further replies.

Combine Reflections and vertex shaders not working

This topic is 5012 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

I have created a cG shader for my water waves(simple sin functions). Now i want add reflections to the water and I use a cubemap and these texture stages g_pd3dDevice->SetTextureStageState( 1, D3DTSS_TEXCOORDINDEX, D3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR|1 ); g_pd3dDevice->SetTextureStageState( 1, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT4 ); The thing is that my water dissapears completely when i activate the cG shader and the reflections together, they both work perfectly sepparated. thanks

Share this post


Link to post
Share on other sites
If I remember correctly, you cannot use D3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR when using shaders. This sampler setting requires you to use the fixed function pipeline because it has to play with the matrices you set as your World, View, and Projection.

I think you''re going to have to generate your own texture coordinates to use with your cubemap. If you''re using 2.0 shaders, that shouldn''t be too hard since you can pretty much type in the formulas straight into the shader.

neneboricua

Share this post


Link to post
Share on other sites
If you''re using HLSL there is an intristic function you can use: reflect. I don''t remember the parameters but I think you have to pass the eye to vertex vector and the normal.
Another thing you have to keep in mind is that the fixed function texture pipeline uses the texture coordinates with the index of the current stage. So if your enviroment map is set in stage 1 your vertex shader must output it''s coordinates as TEXCOORD0, stage 2 - TEXCOORD1 and so on. Do I remember correctly that there is no stage 0?
HTH
Radek

Share this post


Link to post
Share on other sites