Jump to content
  • Advertisement
Sign in to follow this  
Oliver_zx

[Texture Stage] Blending textures

This topic is 2553 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 everyone,

im currently facing an issue with texture render states. Im not much familiar with them so i'd like to ask if someone could give me a hint on that. What i have is two textures. One contains the ARGB texture with a shape i want to use to display a second texture. So i.e. my first texture is a circle and my second contains the real texture. The final texture shall have the shape of a circle and display the content of the second texture inside (w/o uv changes).

The result comes quite unexpected to me. The shape of the final texture is ok - its a circle. Yet the color is wrong. The whole shape is filled with the color of just the very first texel of the second texture (from position 0,0).


Would be great if someone could help me out here. The code below shows a view on what i'm doing.


Thanks alot,
Oliver



device->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
device->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
device->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);

//use texel color value of the second texture
device->SetTextureStageState( 1, D3DTSS_COLOROP, D3DTOP_SELECTARG1 );
device->SetTextureStageState( 1, D3DTSS_COLORARG1, D3DTA_TEXTURE);


//apply alpha from first texture
device->SetTextureStageState( 1, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1 );
device->SetTextureStageState( 1, D3DTSS_ALPHAARG1, D3DTA_CURRENT );

//disable
device->SetTextureStageState( 2, D3DTSS_COLOROP, D3DTOP_DISABLE );
device->SetTextureStageState( 2, D3DTSS_ALPHAOP, D3DTOP_DISABLE );


device->SetTexture(0, tex1);
device->SetTexture(1, tex2);

Share this post


Link to post
Share on other sites
Advertisement
The texture stage also specify which tex-coord is used. The default for stage 1 is 1, and your vertex probably does not have a second tex-coord (with index 1), so it's always (0,0). Try


device->SetTextureStageState( 1, D3DTSS_TEXCOORDINDEX , 0 );

to use the same tex-coord for both stages.

Share this post


Link to post
Share on other sites

The texture stage also specify which tex-coord is used. The default for stage 1 is 1, and your vertex probably does not have a second tex-coord (with index 1), so it's always (0,0). Try


device->SetTextureStageState( 1, D3DTSS_TEXCOORDINDEX , 0 );

to use the same tex-coord for both stages.



ah...ok, good to know. Thanks alot unbird. It helps - looks as expected now. :)

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!