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

Material Color not showing up

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

I want to be able to have a texture on a billboard, and by using the mtrl i want to change the color of the billboard, but when i apply the texture the mtrl color doesnt show up. CMyD3DApplication::p().Getd3dDevice()->SetRenderState( D3DRS_ALPHABLENDENABLE, TRUE ); CMyD3DApplication::p().Getd3dDevice()->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_SRCALPHA ); CMyD3DApplication::p().Getd3dDevice()->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA ); // Enable alpha testing CMyD3DApplication::p().Getd3dDevice()->SetRenderState( D3DRS_ALPHATESTENABLE, TRUE ); CMyD3DApplication::p().Getd3dDevice()->SetRenderState( D3DRS_ALPHAREF, (DWORD)0xff000000 ); CMyD3DApplication::p().Getd3dDevice()->SetRenderState( D3DRS_ALPHAFUNC, D3DCMP_GREATEREQUAL ); // Loop through and render all billboards CMyD3DApplication::p().Getd3dDevice()->SetStreamSource( 0, m_pBillboardVB, sizeof(BILLBOARDVERTEX) ); CMyD3DApplication::p().Getd3dDevice()->SetVertexShader( D3DFVF_BILLBOARDVERTEX ); // Set the texture CMyD3DApplication::p().Getd3dDevice()->SetTexture( 0, m_pBillboardTextures ); D3DUtil_InitMaterial( mtrl, 1.0f,0.0f,1.0f ); CMyD3DApplication::p().Getd3dDevice()->SetMaterial( &mtrl ); // Render the billboard CMyD3DApplication::p().Getd3dDevice()->DrawPrimitive( D3DPT_TRIANGLESTRIP, m_boarddata.dwOffset, 2 );

Share this post

Link to post
Share on other sites
1. What are your texture stage states set to ?
You should have something like:


That modulates (multiplies/mixes) the texture colour with the diffuse colour (which comes from the lighting engine if your vertex format etc is set correctly)

2. Materials are part of the D3D lighting engine (check the docs for more info). To use them you must have lighting enabled, valid ambient, and depending on which part of the material you''re wanting to control the vertex colour, a valid light in the scene (could be as simple as a directional light pointing in the same direction as the camera with it''s R,G and B set to 1 [the material colour is multiplied by the light colour before being applied to the vertices]).

3. What are you trying to set your alpha test value to ? - valid values for ALPHAREF range from 0x00000000 to 0x000000FF. Also do you actually need the alpha test ? As you have it at the moment (a value of 0 [because you''re outside the documented range]), every test always passes!

Simon O''''Connor
Creative Asylum Ltd

Share this post

Link to post
Share on other sites