Both my triangles render red when i use effects!

Started by
1 comment, last by cppcdr 18 years, 3 months ago
For some reason, when I try to render with effects my triangles all come out the same color. Does anyone know why? Here is the source:

pEffect->SetTechnique ("Technique0");

pEffect->Begin (&nPasses);
pEffect->BeginPass (0);

for (UINT i = 0; i < m_NumMaterials; i++)
{	
	if (m_pTempNumFaces  > 0)
	{
		pEffect->SetValue ("material_diffuse_color", &m_pMaterials .cDiffuse, sizeof (COLOR));
		pGraphics->RenderPolys (VERTEX_FVF, m_VB, m_pIB , m_NumVerts, sizeof (VERTEX), m_NumFaces, NULL);
	}
}

pEffect->EndPass ();
pEffect->End ();

m_NumMaterials = 2. TempNumFaces contains the number of faces for each material (in this case 1 each). The index buffers (i have 2) contain each one triangle. All of the 4 vertices are in the single vertex buffer. Material [0].diffuse = grey and Material [1].diffuse = red. When I try to render the triangles, both come out red. Anyone know why? (The effect file contains a vertex and pixel shader that output triangles that are the color specified by "material_diffuse_color". It has been tested and works fine)
Advertisement
You need to call ID3DXEffect::CommitChanges() after SetValue() in order for it to update itself mid-pass [smile]

Quote:If the application changes any effect state using any of the ID3DXEffect::Setx methods inside of an BeginPass/EndPass matching pair, the application must call CommitChanges before any DrawxPrimitive call to propagate state changes to the device before rendering. If no state changes occur within a BeginPass and EndPass matching pair, it is not necessary to call CommitChanges.


hth
Jack

<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ]</small>

It works! I have been fighting to get this program to work for the last 6 days and I can now continue!
Thank you VERY much!

This topic is closed to new replies.

Advertisement