🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Rendering two uv texture on mesh DirectX 9

Started by
1 comment, last by Euthyphro 2 years, 3 months ago

Hi everyone,

Im new in directx gpu programming , im trying to render two texture onto a mesh but last texture getting the color of first texture so i dont get what i want.

this is my first texture ;

First Texture

This is my second texture,

This is how its look like after rendering,

But i want to see textures with their original color , but now it looks like mixed color with texture-1

My render states;

s_lpD3DDev->SetTransform(D3DTS_WORLD, &mtx);
	DWORD dwCull, dwLight;
	bool bUseTwoUV = false;

	s_lpD3DDev->GetRenderState(D3DRS_LIGHTING, &dwLight);
	s_lpD3DDev->GetRenderState(D3DRS_CULLMODE, &dwCull);

	// 
	//s_lpD3DDev->SetRenderState( D3DRS_LIGHTING, FALSE);
	if (dwCull != D3DCULL_NONE)
		s_lpD3DDev->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);

	s_lpD3DDev->SetTexture(0, m_pTex->Get());
	//s_lpD3DDev->SetTexture(1, NULL);

	s_lpD3DDev->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE);
	s_lpD3DDev->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_DIFFUSE);
	s_lpD3DDev->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_TEXTURE);
	//s_lpD3DDev->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
	//s_lpD3DDev->SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
	//	s_lpD3DDev->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE);


	if (m_pOverlapTex) {
		bUseTwoUV = true;

		s_lpD3DDev->SetTexture(1, m_pOverlapTex->Get());

		s_lpD3DDev->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_MODULATE);
		s_lpD3DDev->SetTextureStageState(1, D3DTSS_COLORARG1, D3DTA_CURRENT);
		s_lpD3DDev->SetTextureStageState(1, D3DTSS_COLORARG2, D3DTA_TEXTURE);

		m_pOverlapTex->UpdateRenderInfo();



		

	}



	if (bUseTwoUV) {
		m_PMeshInst->RenderTwoUV();
		if(NULL == m_pPMesh) return;
	if(NULL == m_pPMesh->GetVertices2())
	{
		m_pPMesh->GenerateSecondUV(); 
	}
	if(NULL == m_pPMesh->GetVertices2()) return;
	
	s_lpD3DDev->SetFVF(FVF_VNT2);

	const int iPCToRender = 1000;	// primitive count to render


	if(m_iNumIndices > 3)
	{
		int iPC = m_iNumIndices / 3;

		int iLC = iPC / iPCToRender;
		int i;
		for (i=0; i<iLC; ++i)
		{
			s_lpD3DDev->DrawIndexedPrimitiveUP(D3DPT_TRIANGLELIST, 0, m_iNumVertices, iPCToRender, m_pIndices + i*iPCToRender*3, D3DFMT_INDEX16, m_pPMesh->m_pVertices2, sizeof(__VertexT2));
		}

		int iRPC = iPC%iPCToRender;
		if(iRPC > 0) s_lpD3DDev->DrawIndexedPrimitiveUP(D3DPT_TRIANGLELIST, 0, m_iNumVertices, iRPC, m_pIndices + i*iPCToRender*3, D3DFMT_INDEX16, m_pPMesh->m_pVertices2, sizeof(__VertexT2));
	}

		}
		
		const uint32_t FVF_VNT2 = D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_TEX2;

Can anyone help about this issue ?

Advertisement

It looks like a shader problem. As you haven't posted the shader, it is difficult to help.

But i want to see textures with their original color , but now it looks like mixed color with texture-1

Mixing is exactly what it sounds like you want to do. But it appears that the second texture is being used as a normal map rather than a diffuse texture.

This topic is closed to new replies.

Advertisement