   setting the alpha value in a texture
  My two ideas:1) Set the render target to the texture, then render some stuff using D3DPT_POINTLIST or whatever it is with the fvf containing a diffuse color. Question: will this set the alpha value in the texture or not?2) Lock the texture and set the data manually. I looked up in the msdn and the pitch part in the data thing is confusing. If I can''t do #1 could someone explain this for me?Thanks! 
  I would go with #2 if it's done during loading time.  Locking a texture, however, is very slow so you should make use of the graphics card and render to it whenever you can.  In your case, though, I think you will be wanting to set the alpha value in the pixel through locking the texture.  Something like this: D3DLOCKED_RECT rect;ZeroMemory(&rect, sizeof(rect));pTexture->LockRect(0, &rect, NULL, 0);BYTE *pData = (BYTE*)rect.pBits;int index = (y*rect.Pitch)+(x*4);pData[index++] = (BYTE)(pixel.b*255);pData[index++] = (BYTE)(pixel.g*255);pData[index++] = (BYTE)(pixel.r*255);pData[index++] = (BYTE)(pixel.a*255);pTexture->Unlock(); [edited by - Chaucer on August 14, 2003 1:40:48 AM];  Sorry to bump this thread, but now I can''t get them the base texture and alpha map to blend together . I''ve come close but it still doesn''t set actual alpha values, just makes the color what it would be. I don''t know how to really explain it. Can you show me what you set for your texture states? The ones on the site don''t work at all... // stage 0 coloring : get color from texture0*diffuselpDev->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE);lpDev->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);lpDev->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE);// stage 0 alpha : nadalpDev->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);lpDev->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_CURRENT);// stage 1 coloring : nadalpDev->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_SELECTARG1);lpDev->SetTextureStageState(1, D3DTSS_COLORARG1, D3DTA_DIFFUSE);// stage 1 alpha : get alpha from texture1lpDev->SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);lpDev->SetTextureStageState(1, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);;  here''s what i use: m_pd3dDevice->SetTextureStageState(0,D3DTSS_COLOROP, D3DTOP_ADD);m_pd3dDevice->SetTextureStageState(0,D3DTSS_COLORARG1, D3DTA_TEXTURE);m_pd3dDevice->SetTextureStageState(0,D3DTSS_COLORARG2, D3DTA_DIFFUSE);m_pd3dDevice->SetTextureStageState(0,D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);m_pd3dDevice->SetTextureStageState(0,D3DTSS_ALPHAARG1, D3DTA_TEXTURE);m_pd3dDevice->SetTextureStageState(1,D3DTSS_COLOROP, D3DTOP_SELECTARG1);m_pd3dDevice->SetTextureStageState(1,D3DTSS_COLORARG1, D3DTA_CURRENT);m_pd3dDevice->SetTextureStageState(1,D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);m_pd3dDevice->SetTextureStageState(1,D3DTSS_ALPHAARG1, D3DTA_TEXTURE);;  Although chaucer is correct in locking the texture and accessing the contents directly remember that the code he has applies to 32 bit color (BGRA) with 8 bits for each color. For other color formats be sure to convert the color information appropriately. Also always check to see if a lock on a resource is successful (checking for a resource lock is more important than checking for your usual dx api calls IMHO due to funky things users try to do with the resources.) Trying to write data to an invalid resource location will give you a nice surprise Also always use the pitch provided as the texture mem location may have a longer width than the actual width of the texture due to aligning.As for your your prob of state settings for the alpha the states you have listed appear to be correct, for one thing try to write random data to the alpha chan of your tex and see if that helps.I don''t have the dx sdk with me atm but have a good look at your lpd3ddevice settings to ensure that alpha is enabled. ;  Ok, now something is seriously strange. Not even those settings get my textures to blend properly. In fact, they don''t even blend at all . I had to change your D3DTOP_ADD to D3DTOP_MODULATE since I don''t have a vertex color. Could that be the problem? ;  you need to set srccolorop and set destcolorop so that you can blend the texture from the resulting computed alpha with the backbuffer for version <8 and for dx9 i think they are done through samplers;  Ooooh shoot, I think you are right. You don't need to set them to do the multitexturing but I sure need them when I do my next pass for the other textures. Thanks!   [edited by - Raloth on August 14, 2003 12:42:59 AM]