Skip to main content
gamedev.net
🔒 Locked

Projective textures problem

Started by Etus 0 replies 350+ views
Original Post
Etus
Etus
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
Etus
Etus
Please, anyone?
I tried using the Search option but it doesn''t work correctly.

- Etus

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.