Archived

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

Changing Colors of an Imported Transparent Texture

This topic is 5145 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 have been able to get my texture to map over the object I am creating, and have been able to create it transparently with alpha blending. My question is, how do I get the color to change? I have tried to use something like this: DWORD color=D3DCOLOR_ARGB(0xFF,255,0,0); g_device->SetRenderState(D3DRS_TEXTUREFACTOR,color); But this has not worked as of yet. Can anyone tell me the basics of changing the color, so I can figure out what I might have done incorrectly? Thanks!

Share this post


Link to post
Share on other sites
If you want to change the texture to a specific color you will have to do lock the texture as Nik is suggesting. However, if you are looking to alter the texture output color through blending the Texture Factor you might have a problem in the way that your texture stages are setup.

Can you post the section of code where your setup your texture stages?


_______________________________________
Understanding is a three edged sword...

Share this post


Link to post
Share on other sites

I have these lines after I read the texture in from the file.

To be perfectly honest, I don''t know what all of these lines do.
Maybe that could be part of the problem.


g_pd3dDevice->SetRenderState(D3DRS_ALPHABLENDENABLE,TRUE);
g_pd3dDevice->SetRenderState(D3DRS_SRCBLEND,D3DBLEND_ONE);
g_pd3dDevice->SetRenderState(D3DRS_DESTBLEND,D3DBLEND_ONE);
g_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_MODULATE );
g_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
g_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE );
g_pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_MODULATE );

g_pd3dDevice->SetTextureStageState( 0, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT2 );
g_pd3dDevice->SetTextureStageState( 0, D3DTSS_TEXCOORDINDEX, D3DTSS_TCI_CAMERASPACEPOSITION );

Share this post


Link to post
Share on other sites
quote:
Original post by shane1985
g_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
g_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE );



Diffuse? How about setting it to use the texturefactor instead of the vertex diffuse?

Share this post


Link to post
Share on other sites
quote:
Original post by DrunkenHyena

Did you set up the states to use the Texture Factor?

SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE);
SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_TFACTOR);

Stay Casual,

Ken



Actually, the drunk pointed it out up there aswell

Share this post


Link to post
Share on other sites