   Alpha Blending/Texture filtering unexpected border
Here is my code:// For Alpha Blending/Channelm_D3dDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE );m_D3dDevice->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_SRCALPHA );m_D3dDevice->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA );m_D3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_MODULATE );m_D3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE );m_D3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG2, D3DTA_CURRENT );// Texture Filteringm_D3dDevice->SetSamplerState( 0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR );m_D3dDevice->SetSamplerState( 0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR );m_D3dDevice->SetSamplerState( 0, D3DSAMP_MIPFILTER, D3DTEXF_LINEAR );// Texture UV Clampingm_D3dDevice->SetSamplerState( 0, D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP );m_D3dDevice->SetSamplerState( 0, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP );But why is there a yellow border? if i change D3DTEXF_LINEAR to D3DTEXF_NONE, the border is not visible anymore but the quality if the texture it self is ugly(dotty). What am i missing here? do i need the otherSetTextureStageState with something like Colorarg etc.. hmmmmm.. I really can't solve this issue, kindly help me.. Thanks!PS. the png file as of course an alpha channel, it's just that it's white in the image.   
  PS.if i change D3DTOP_MODULATE to D3DTOP_MODULATE2X or to D3DTOP_MODULATE4X the unexpected border becomes more visible. to correct my last post, it is a white border, not yellow.pls help..;  Are you offsetting your UV coords by half a texel, as per Directly Mapping Texels to Pixels?   ;  I don't know exactly. UV coordinates are 0.0 - 1.0 right? and if my rect for x.png is located at 10 by 10 px and the size of x.png is 128 by 128 px. my UV is  U: (10/128) V: (10/128)U: 0.078125V: 0.078125   ;  Then you want your UVs to be:U = 9.5 / 128 = 0.07421875V = 9.5 / 128 = 0.07421875(Or possibly 10.5 / 128, I can't recall offhand)so the UV coordinate is in the centre of the texel instead of in the corner.   ;I don't know exactly. UV coordinates are 0.0 - 1.0 right?Yes, this is called normalized texture coordinates. To make the Pixel-to-Texel alignment work, eitherdecrease your drawing coordinates by half a pixel: (x - 0.5, y - 0.5)orincrease your texture coordinates by half a texel: (u + 0.5/texturewidth, v + 0.5/textureheight), so in your case the texel offset for both coordinates is 0.5 / 128.0.Since I've been ninja-ed here some additional info:The white border happens because you have a transparent white around your drawing elements and enabled linear filtering. Filtering between a transparent white and e.g. a opaque blue will give you some half-transparent light-blue. This is sometimes called bleeding or maybe "alpha fringes" AFAIK.;  WOW!!! it worked!! how did you guys know it? i'm searching in the internet and got no luck By the way, THANK YOU VERY MUCH!!!for those who also got this problem, here's my code:float val_x = ((float)m_Rect.left + 0.5f) / (float)tot_width;float val_y = ((float)m_Rect.top + 0.5f) / (float)tot_height;vertices[0].tu = val_x;vertices[0].tv = val_y;val_x = ((float)((float)m_Rect.left + m_Width) + 0.5f) / (float)tot_width;val_y = ((float)m_Rect.top + 0.5f) / (float)tot_height;vertices[1].tu = val_x;vertices[1].tv = val_y;val_x = ((float)m_Rect.left + 0.5f) / (float)tot_width;val_y = ((float)((float)m_Rect.top + m_Height) + 0.5f) / (float)tot_height;vertices[2].tu = val_x;vertices[2].tv = val_y;val_x = ((float)((float)m_Rect.left + m_Width) + 0.5f) / (float)tot_width;val_y = ((float)((float)m_Rect.top + m_Height) + 0.5f) / (float)tot_height;vertices[3].tu = val_x;vertices[3].tv = val_y;;  Everybody working with DX 9 will stumble on this at one point, and searching the interweb hardly helps if you don't know the keywords yet. And if you know the keywords you likely already know what it's all about. It's a common beginner pitfall and appears on this forum every [strike]week[/strike] (correction: almost daily). Glad it's working ;  Hehehe, Thanks a lot! by the way, correct me if I'm wrong, the reason we offset the UV by 0.5 so that the linear calculation will get that pixel only? so how's that differ from no texture filtering?   ;  Theoretically (mathematically) there's no difference. But calculating on a computer (generally) has some bias, since hardware uses floating point arithmetic (or maybe even some fixed point tricks for the hardware filtering, I don't know, that's vendor secrets). Floating point arithmetic is an approximation and rarely yields mathematically exact results. But you probably won't notice any difference in this case. Turning off filtering will put you on the safe side, though, and might also improve performance.   