Artefacts when blending textures

Started by
1 comment, last by MrSparkle 17 years, 7 months ago
Hi, I try to alpha-blend two textures: a base texture without and an overlay texture with alpha channel. When I turn filtering of the second texture on, there is a small rectangular line visible around the texture border of the overlay texture. I tried different address modes like Clamp or Border and assigned the BorderColor with (0,0,0,0) so it's supposed to be invisible, but none of this helps. Is there a workaround to get this working with texture filtering? Thanks, Christian
Advertisement
Generally you should ensure your texture coordinates are correct, and not rely on clamping or forcing border colors. Doing this may fix your problem.

If any of my assumptions that follow are incorrect the conclusions will likely be incorrect. In such a case, feel free to provide more information and disregard my conclusions.

That said, I'm guessing from your explanation that your texture filtering is screwing up a single-pixel wide border. And from what you're saying, it would be darker (and more transparent) than it's supposed to be. If this is the case, it would seem your pixel is being averaged (through a filter) with the actual color and transparent black resulting in a darker and more transparent color than you want. You can use point filtering to prevent such averaging, or you can create a shader which ensures the results you desire. Also, as stated at the beginning of this post fixing your texture coorinates may fix everything if they are wrong.
Thanks, Richard. You are right, it was the texture coordinates which caused the artefacts.
I want to write a shader which uses the textures generated by the brick texture generator Bricks'n'Tiles which creates tileable brick textures and also textures for the left and right border to fit the adjacent walls.

I calculated the texture coordinates like this:
if (texCoord.x < 0.1){  // Draw left border blended with the brick tiles}else if (texCoord.x > 0.9){  // Draw right border blended with the brick tiles}else{  // Draw brick tiles only}


Now I changed the calculation like this:
if (texCoord.x < 0.5){  // Draw left border blended with the brick tiles}else {  // Draw right border blended with the brick tiles}


Now, it works fine even though, I don't understand exactly what causes the artefacts in the fist calculation, because I havn't enabled antialiasing or something.

This topic is closed to new replies.

Advertisement