Sign in to follow this  

Colour Overlay On Texture

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

Hi guys, i'm using the d3d8 sprite class to render a texture, the texture is greyscale and i wish to "overlay" colour through rendering. I've looked into direct3d render states and texture stages and spent many hours fiddling about with it but never quite reaching the results i wanted. Before i call the "Draw" function of the sprite class inbetween "Begin" and "End" i call the follow commands:
	Backbones.GetDevice ( )->SetTextureStageState ( 0, D3DTSS_ALPHAOP,   D3DTOP_MODULATE );
	Backbones.GetDevice ( )->SetTextureStageState ( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE );
	Backbones.GetDevice ( )->SetTextureStageState ( 0, D3DTSS_ALPHAARG2, D3DTA_TFACTOR );

	Backbones.GetDevice ( )->SetTextureStageState ( 0, D3DTSS_COLOROP,   D3DTOP_MODULATE );
	Backbones.GetDevice ( )->SetTextureStageState ( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
	Backbones.GetDevice ( )->SetTextureStageState ( 0, D3DTSS_COLORARG2, D3DTA_TFACTOR );
	
	Backbones.GetDevice ( )->SetRenderState ( D3DRS_TEXTUREFACTOR, D3DCOLOR_ARGB ( 255, 0, 0, 255 ) );
The Alpha code works fine ,when i change the value it modified the texture alpha fine. But when the colour ops are called, the texture appears black. I've tried SetRenderState ( D3DRS_LIGHTING, FALSE ) but doesn't seem to change anything. Any help is greatly appreciated!! Thanks :) [b]EDIT[b] Very typical, i've spent hours trying out loads of different things, i finally resort to getting help and i solved it simply by changing [b]D3DTOP_MODULATE[b/] on the colour ops to D3DTOP_ADD. Thanks for reading :)

Share this post


Link to post
Share on other sites
try this;

->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1 );
->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TFACTOR );
->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1 );
->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TFACTOR );


and now set color:

->SetRenderState( D3DRS_TEXTUREFACTOR, 0xFFFF0000 );

Share this post


Link to post
Share on other sites

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