Blake Hashimoto
Blake Hashimoto

Reputation: 37

Problems with transparent edges in OpenGL ES 2.0

So, I'm making a live wallpaper in android using OpenGL ES 2.0 using a series of squares with image textures in a 3D environment. The problem that I'm running into is that I'm getting a weird black line that flickers upon camera movement. The squares are supposed to be transparent, and I can't figure out what's causing this or how to fix it. I've tried using Anti Aliasing, and I've set the transparency using both GLES20.glBlendFunc(GLES20.GL_ONE, GLES20.GL_ONE_MINUS_SRC_ALPHA); and

    GLES20.glBlendFunc(GLES20.GL_SRC_ALPHA, GLES20.GL_ONE_MINUS_SRC_ALPHA);

This is what my wallpaper looks like right now. Three layers (background, girl, grass), with both the grass and girl showing a dark line around the top edge.

enter image description here

Anyone know what I'm doing wrong, or how to fix this?

Upvotes: 1

Views: 564

Answers (1)

Blake Hashimoto
Blake Hashimoto

Reputation: 37

So, it looks like Andon M. Coleman was right. All I had to do was clamp the texture coordinates to remove the black edges. Adding:

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

seems to do the trick.

Upvotes: 1

Related Questions