Jump to content
  • Advertisement
Sign in to follow this  

DirectX texture blending problem

This topic is 3996 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 everybody! I'm new to DirectX programming, and I'm trying to do a really simple texture blend effect. My graphic card is a GeForce 7600 GT, drivers are version and DirectX is 9.0c with SDK April 2007 DirectX detects these capabilities, among the others: MaxTextureBlendStages = 8 MaxSimultaneousTextures = 8 My problem is that if I try to blend three textures, aparently the third stage is not taken in account! This happen with any operation, and any combination of arguments; however I'm trying with the following blending settings:
d3dDevice->SetTexture(0, texture4);
d3dDevice->SetTexture(1, texture6);
d3dDevice->SetTexture(2, texture5);

d3dDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE);
d3dDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_DIFFUSE);
d3dDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_TEXTURE);
d3dDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_DISABLE);

d3dDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_ADD);
d3dDevice->SetTextureStageState(1, D3DTSS_COLORARG1, D3DTA_CURRENT);
d3dDevice->SetTextureStageState(1, D3DTSS_COLORARG2, D3DTA_TEXTURE);
d3dDevice->SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_DISABLE);

d3dDevice->SetTextureStageState(2, D3DTSS_COLOROP, D3DTOP_ADD);
d3dDevice->SetTextureStageState(2, D3DTSS_COLORARG1, D3DTA_CURRENT);
d3dDevice->SetTextureStageState(2, D3DTSS_COLORARG2, D3DTA_TEXTURE);
d3dDevice->SetTextureStageState(2, D3DTSS_ALPHAOP, D3DTOP_DISABLE);

d3dDevice->SetTextureStageState(3, D3DTSS_COLOROP, D3DTOP_DISABLE);
d3dDevice->SetTextureStageState(3, D3DTSS_ALPHAOP, D3DTOP_DISABLE);

Am I doing something wrong? Thanks to everybody for helping! Bye! ;-) [Edited by - damix911 on January 2, 2008 4:52:10 PM]

Share this post

Link to post
Share on other sites
All stages must either have BOTH a colorop and alphaop, or be disabled. So, all your stages are actually invalid. Set an alphaop on all your stages. Setting to SELECTARG1, DIFFUSE is a pretty harmless generic value.

That said, you'll probably want to look into D3DTSS_TEXCOORDINDEX, which lets you specify which set of UVs to use on a texture stage. Most models have 1 set of UVs, so you'll need to set the TEXCOORDINDEX for stage 1 and 2 to '0'.

Also, be aware that what you're doing will apply lighting to texture 0, then add textures 1 and 2 on top of that, unlit.

Share this post

Link to post
Share on other sites
Thank you!

First of all because even if I read it, I was thinking that the color blending must be active when the alpha is active, and actually it is exactly the opposite, as you told me. However last thing you said solved my problem: simply I had defined the vertex format and then I forgot about it, but only two set of UV coordinates were defined! I will look for sure to the parameter you recommended me, however for now I have simply redefined the vertex format and it works :-D

Thank you again and have a nice day!

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!