Jump to content
  • Advertisement
Sign in to follow this  

Colour Overlay On Texture

This topic is 3931 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 :) EDIT 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 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
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!