Archived

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

BlackDragon

Material Color not showing up

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:

stage 0, COLORARG1, TEXTURE
stage 0, COLORARG2, DIFFUSE
stage 0, COLOROP, MODULATE
stage 1, COLOROP, DISABLE

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
www.creative-asylum.com

Share this post


Link to post
Share on other sites