Sign in to follow this  

Both my triangles render red when i use effects!

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

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 [i] > 0)
	{
		pEffect->SetValue ("material_diffuse_color", &m_pMaterials [i].cDiffuse, sizeof (COLOR));
		pGraphics->RenderPolys (VERTEX_FVF, m_VB, m_pIB [i], 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)

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

This topic is 4340 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.

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