   Alpha blending problem
  Hello, I'm trying to render a road with the dashed demarcation that separates the 2 lanes.The base texture for the road is in one texture, and the dashed line is in a separate transparent texture.Both of the textures are .dds files.I use the following code to set up the texture stages, but i can't get it to work.Can someone please show me what do I do wrong here.  D3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE,true); D3DDevice->SetRenderState(D3DRS_SRCBLEND,D3DBLEND_SRCALPHA); D3DDevice->SetRenderState(D3DRS_DESTBLEND,D3DBLEND_INVSRCALPHA); D3DDevice->SetTextureStageState(0,D3DTSS_COLOROP,D3DTOP_SELECTARG1); D3DDevice->SetTextureStageState(0,D3DTSS_COLORARG1,D3DTA_TEXTURE); D3DDevice->SetTextureStageState(0,D3DTSS_ALPHAOP,D3DTOP_DISABLE); D3DDevice->SetTextureStageState(1,D3DTSS_COLOROP,D3DTOP_SELECTARG1); D3DDevice->SetTextureStageState(1,D3DTSS_COLORARG1,D3DTA_TEXTURE); D3DDevice->SetTextureStageState(1,D3DTSS_ALPHAOP,D3DTOP_SELECTARG1); D3DDevice->SetTextureStageState(1,D3DTSS_ALPHAARG1,D3DTA_TEXTURE); D3DDevice->SetFVF(D3DFVF_VERTEX); D3DDevice->SetStreamSource(0,VertexBuffer,0,sizeof(VERTEX)); D3DDevice->SetMaterial(&Material); D3DDevice->SetTexture(0,BaseTexture); D3DDevice->SetTexture(1,MarksTexture); D3DDevice->DrawPrimitive(D3DPT_TRIANGLELIST,0,LaneCount * 2); D3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE,false); D3DDevice->SetTextureStageState(1,D3DTSS_COLOROP,D3DTOP_DISABLE); D3DDevice->SetTextureStageState(1,D3DTSS_ALPHAOP,D3DTOP_DISABLE); Thank you   
  For starters - I don't think you can disable one stage without disabling subsequent stages - nor should you disable part of one stage.Secondly, you have both textures in the same pipeline - Post processing stuff like alpha blending happens AFTER you leave the pipeline, so you would only be using it if you had already drawn the base texture and were simply drawing the dashed line on top.So - either draw the base texture (default texture stage states) first.  Then draw the dashed line (default texture stage states again) with alpha blending on.OR - If you are going to draw both at the same time, you need to do your alpha blending inside the pipeline.  Make sure you leave alpha blending off.  Like so: D3DDevice->SetTextureStageState(0,D3DTSS_COLOROP,D3DTOP_SELECTARG1); D3DDevice->SetTextureStageState(0,D3DTSS_COLORARG1,D3DTA_TEXTURE); D3DDevice->SetTextureStageState(0,D3DTSS_ALPHAOP,D3DTOP_SELECTARG1); D3DDevice->SetTextureStageState(0,D3DTSS_ALPHAARG1,D3DTA_TEXTURE); D3DDevice->SetTextureStageState(1,D3DTSS_COLOROP,D3DTOP_BLENDFACTORALPHA); D3DDevice->SetTextureStageState(1,D3DTSS_COLORARG1,D3DTA_TEXTURE); D3DDevice->SetTextureStageState(1,D3DTSS_COLORARG2,D3DTA_CURRENT); D3DDevice->SetTextureStageState(1,D3DTSS_ALPHAOP,D3DTOP_SELECTARG1); D3DDevice->SetTextureStageState(1,D3DTSS_ALPHAARG1,D3DTA_TEXTURE);;  Actually, you're really close. All the stages are correct, you only need to use an operation that uses alpha for your second stage. Try using D3DTOP_BLENDTEXTUREALPHA as the color operation on your second stage. This will blend the two colors according to the alpha of the second texture, which is what you want :).Hope this helps :).   ;Quote:Original post by sirobActually, you're really close. All the stages are correct, you only need to use an operation that uses alpha for your second stage. Try using D3DTOP_BLENDTEXTUREALPHA as the color operation on your second stage. This will blend the two colors according to the alpha of the second texture, which is what you want :).Hope this helps :).Brilliant recap of my post. [wink]   ;  Bah! I'm just blind!Sorry :-/.   