Sign in to follow this  

strange border-like artifact when blending and masking [SOLVED]

This topic is 3577 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

Hello community, I'll start my 1st post with following problem: I'm making a VERY simple FPP thing, and like most FPPs, it needs a good gun. It's a tiny, non-commercial project I need for learning purposes (university), so I borrowed two pieces: CS:S m4a1 and UT's shockrifle from google graph search. Simplicity first, I don't model the weapons. I just make a 512x512 quad at the bottom-right corner of the screen and paint a weapon on it. Blend, actually, as NeHe teaches, using masking, so I put the mask for the weapon on the quad first, then put the actual weapon texture (by putting I mean proper blending). It works great, beside this effect (here comes the problem): http://img119.imageshack.us/my.php?image=artefaktramkaei6.jpg http://img227.imageshack.us/my.php?image=artefaktramka2wp9.jpg http://img227.imageshack.us/my.php?image=artefaktramka3nl5.jpg The border appears from nowhere, as the green arrows indicate. The quad is 512x512, both the mask and weapon textures are 512x512. There is no thing neither on the mask nor on the texture that could produce this, I have repainted them a hundred times yet nothing changed. The color of this 1px partial border does not depend on what you are looking at (though it may seem so), it's more or less constant. Nevermind the textures' quality, they're more temp, not a real thing. Any ideas why this happens? I could post part of the code if needed. [excuse me my english, it's not my native at all] [Edited by - wlw_wl on April 1, 2008 8:08:42 PM]

Share this post


Link to post
Share on other sites
That's your textures' bilinear filter wrapping around. The easy solution is to set the texture wrap modes to CLAMP_TO_EDGE:

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);

By the way, if you want to stay with the image blending approach instead of a 3D model, I would suggest you look into adding an alpha channel to your image. That will allow you to do single pass blending. NeHe's masking technique is a rather bad approach, and should be avoided.

Share this post


Link to post
Share on other sites
You Are The Man!

Although I got known
http://www.gamedev.net/community/forums/topic.asp?topic_id=191794
error, definition made my day!

About alpha and masking - I know it would be better (and somehow easier) to include alpha channel, but I was just using plain .bmps and I was quite happy with them until the non-model weapons display.

I'll keep your advice in mind however, for future. Letting this stay wrong and masked in NeHe's way works for me as it implements yet another technique, and all this project is about is just showing few techniques in one place, hopefully giving me higher grade.

Thank you Yann L, I learnt in practise another thing I read in some tutorial or somewhere.

Now it looks preety. :)

Share this post


Link to post
Share on other sites
Sign in to follow this