Jump to content
  • Advertisement

Archived

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

Etus

Projective textures problem

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

Hello, While trying to add water simulation to my engine, I stumbled in a problem regarding projective texturing. I''m trying to project the water reflection(that was rendered to a texture) to the water surface. This is how it looks like: http://demons.org.il/etus/sn1.jpg Here''s the function I''m using:
void Water :: StartTexturedRendering() {

	D3DXMATRIXA16 matFinal;
	D3DXMATRIXA16 matCamera;
	D3DXMATRIXA16 matWorld;
	D3DXMATRIXA16 matView;
	D3DXMATRIXA16 matProj;
	D3DXMATRIXA16 tempMat;
	D3DXMATRIXA16 tempMat2;

	D3DXMatrixIdentity(&matFinal);

	D3DXMatrixScaling(&tempMat, 0.5f, 0.5f, 1.0f);
	D3DXMatrixMultiply(&tempMat2, &matFinal, &tempMat);
	matFinal = tempMat2;
	D3DXMatrixTranslation(&tempMat, 1.0f, 1.0f, 0.0f);
	D3DXMatrixMultiply(&tempMat2, &matFinal, &tempMat);
	matFinal = tempMat2;	

	Device->GetTransform(D3DTS_WORLD, &matWorld);
	Device->GetTransform(D3DTS_VIEW, &matView);
	Device->GetTransform(D3DTS_PROJECTION, &matProj);

    D3DXMatrixMultiply(&matCamera, &matWorld, &matView);
    D3DXMatrixMultiply(&matFinal, &matCamera, &matProj);
	
	textureMatrixStack->Push();
	textureMatrixStack->LoadIdentity();
	textureMatrixStack->LoadMatrix(&matFinal);
	
	Device->SetTransform(D3DTS_TEXTURE0, textureMatrixStack->GetTop());	
	Device->SetTextureStageState(0, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT3 | D3DTTFF_PROJECTED);
	Device->SetTextureStageState(0, D3DTSS_TEXCOORDINDEX, D3DTSS_TCI_CAMERASPACEPOSITION | 1);
	
	return;

}
What am I doing wrong? Thanks! Etus

Share this post


Link to post
Share on other sites
Advertisement
Please, anyone?
I tried using the Search option but it doesn''t work correctly.

- Etus

Share this post


Link to post
Share on other sites

  • 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!