Sign in to follow this  

3D Projected texture problem

Recommended Posts

Hello, I implemented reflections in water by rendering terrain to offscreen and projecting it on water plane with this: // tu = (0.8x + 0.5z) / z // tv = (0.8y - 0.5z) / z mat._11 = 0.8; mat._12 = 0.0f; mat._13 = 0.0; mat._21 = 0.0f; mat._22 = 0.8; mat._23 = 0.0; mat._31 = 0.5; mat._32 = -0.5; mat._33 = 1.0; mat._41 = 0.0f; mat._42 = 0.0; mat._43 = 0.0; SetTransform( D3DTS_TEXTURE1, &mat ); SetTextureStageState( 1, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT3 |D3DTTFF_PROJECTED ); SetTextureStageState( 1, D3DTSS_TEXCOORDINDEX, D3DTSS_TCI_CAMERASPACEPOSITION ); Problem appears when moving up, because reflections move also up but too fast. Here are screenshots: or If I set mat._22 to zero than this would mean same Y for all points, but it is wrong, because camera-related matrix makes different Y values for individual vertices, depending on current view angle. Same view matrix is being used for rendering offscreen and onscreen. I already tried to translate Y of terrain, that is being taken to texture and it works fine if I move it just a little, otherwise this causes weird image (cannot compensate with adjusting Y) Is there anyway to solve this without shaders and also without cubemaps (they are too expensive)? I would be very grateful for informations.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this