Android OpenGL - ES Texture Bleeding

I am writing a small application that currently generates a random texture map.

I draw this map as a group of 10 x 15 ATVs that fill all triangular stripes. I use a “map” to capture an int, which I then take as the texture location for this square in textureAtlas. therefore, for example, 0 is the bottom left “tile”. Atlas is 128 x 128 and is divided into 32 pixel tiles.

However, I seem to get some odd artifacts where a texture from one tile crawls to the next plate. I wondered if this was the image itself, but as far as I can tell, the pixels are exactly where they should be. Then I looked at the texture coordinates that I specified, but they all look accurate (0.0, 0.25, 0.5, 0.75, 1.0), dividing them into 4 rows and columns, which I would expect).

It is strange if I run it on an emulator, I do not receive any artifacts.

Is there a parameter that I don’t have that will cause 1 pixel bleeding? It seems that it is only vertical - it can be connected with the phone, I "stretch" the image in this direction when the phone screen is larger than usual in this direction.

I load the texture like this:

//Get a new ID
    int id = newTextureID(gl);

    //We will need to flip the texture vertically
    Matrix flip = new Matrix();
    flip.postScale(1f, -1f);

    //Load up and flip the texture
    Bitmap temp = BitmapFactory.decodeResource(context.getResources(), resource);

    //Store the widths for the texturemap
    int width = temp.getWidth();
    int height = temp.getHeight();
    Bitmap bmp = Bitmap.createBitmap(temp, 0, 0, width, height, flip, true);
    temp.recycle();

    //Bind
    gl.glBindTexture(GL10.GL_TEXTURE_2D, id);

    //Set params
    gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER, gl.GL_LINEAR);
    gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MAG_FILTER, gl.GL_LINEAR);

    //Push onto the GPU
    GLUtils.texImage2D(GL10.GL_TEXTURE_2D, 0, bmp, 0);

    TextureAtlas atlas = new TextureAtlas(id, width, height, tileSize);
    return atlas;

Then I will do this:

gl.glBindTexture(GL10.GL_TEXTURE_2D, currentAtlas.textureID);
    //Enable the vertices buffer for writing and to be used during our rendering
    gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
    //Specify the location and data format of an array of vertex coordinates to use
    gl.glVertexPointer(3, GL10.GL_FLOAT, 0, vertexBuffer);

    //Enable the texture buffer
    gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
    gl.glTexCoordPointer(2, GL10.GL_FLOAT, 0, textureBuffer);
    gl.glDrawElements(GL10.GL_TRIANGLES, indices.length, GL10.GL_UNSIGNED_SHORT, indexBuffer);

, , ...

- , , , , , , !

.

: - . , . : D /.

ScreenCap

+5
1

, .

, , .

.

:

//Top Left
            textureCoords[textPlace] = xAdjust*currentAtlas.texSpaceWidth + currentAtlas.halfPixelAdjust;        textPlace++;
            textureCoords[textPlace] = (yAdjust+1)*currentAtlas.texSpaceHeight - currentAtlas.halfPixelAdjust;    textPlace++;

:

(float)(0.5 * ((1.0f / numberOfTilesInAtlasRow) / pixelsPerTile));

( ), .

, . , - !

+11

All Articles