Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7625143
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T05:09:11+00:00 2026-05-31T05:09:11+00:00

I’m currently developing a game for Android using OpenGL ES 2.0. I have almost

  • 0

I’m currently developing a game for Android using OpenGL ES 2.0. I have almost everything working with textures and vertex colors but when i use transparency in textures, the transparent parts get dotted. Here is a screenshot of it: Dotted transparency

The boll (blue circle) shown currently has 3 layers of planes on top of him, the eyes, mouth and teeth. All layers have the same dimensions and transparency and it seems like the dotting gets worse the more layers I add. This is the onCreate method of the renderer:

    mMVPMatrix = new float [16];
    mViewMatrix = new float [16];
    mProjectionMatrix = new float [16];
    mModelMatrix = new float [16];

    Matrix.setLookAtM(mViewMatrix, 0, 0.0f, 0.0f, mZoom, 0.0f, 0.0f, -0.1f, 0.0f, 1.0f, 0.0f);
    Matrix.setIdentityM(mModelMatrix, 0);

    mTexturePointer = new int [32];

    loadTextures();

    GLES20.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
    mShaderPointer = loadProgram();

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

    GLES20.glUseProgram(mShaderPointer);

    mMVPMatrixPointer = GLES20.glGetUniformLocation(mShaderPointer, "uMVPMatrix");
    mPositionPointer = GLES20.glGetAttribLocation(mShaderPointer, "a_position");
    mTexCoordPointer = GLES20.glGetAttribLocation(mShaderPointer, "a_texCoord");
    mSamplerPointer = GLES20.glGetUniformLocation(mShaderPointer, "s_texture");
    mColorPointer = GLES20.glGetAttribLocation(mShaderPointer, "a_color");

This is the fragment shader:

              "precision mediump float;                                         \n" 
            + "uniform sampler2D s_texture;                                                 \n"
            + "                                                                             \n" 
            + "varying vec4 v_color;                                                        \n" 
            + "varying vec2 v_texCoord;                                                     \n"
            + "                                                                             \n" 
            + "void main()                                                                  \n" 
            + "{                                                                            \n"
            + "                                                                             \n"
            + "     vec4 final_color = vec4(texture2D(s_texture, v_texCoord).r * v_color.r,   "
            + "                             texture2D(s_texture, v_texCoord).g * v_color.g,   " 
            + "                             texture2D(s_texture, v_texCoord).b * v_color.b,   "
            + "                             texture2D(s_texture, v_texCoord).a + v_color.a);\n" 
            + "                                                                             \n" 
            + "     //Set the Fragments colour                                              \n" 
            + "     gl_FragColor = final_color;                                             \n" 
            + "}                                                                            \n";

And the vertex shader:

              "attribute vec4 a_position;       \n" 
            + "uniform mat4 uMVPMatrix;                     \n" 
            + "                                             \n"
            + "attribute vec2 a_texCoord;                   \n" 
            + "attribute vec4 a_color;                      \n" 
            + "                                             \n" 
            + "varying vec4 v_color;                        \n"
            + "varying vec2 v_texCoord;                     \n" 
            + "                                             \n" 
            + "void main()                                  \n"
            + "{                                            \n" 
            + "   gl_Position = uMVPMatrix * a_position;    \n" 
            + "   v_texCoord = a_texCoord;                  \n"
            + "   v_color = a_color;                        \n" 
            + "}                                            \n";

And last but not least the draw (this is the draw method for each object):

GLES20.glViewport(0, 0, mScreenWidth, mScreenHeight);

GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT);

protected void draw(GameRenderer aRenderer){
    if(mVisible){
        // Do the animation.
        if(mAnimated)
            animate();

        GLES20.glEnableVertexAttribArray(aRenderer.mPositionPointer);
        GLES20.glEnableVertexAttribArray(aRenderer.mTexCoordPointer);
        GLES20.glEnableVertexAttribArray(aRenderer.mColorPointer);

        // Load the texture mapping.
        mTexture.position(0);
        GLES20.glVertexAttribPointer(aRenderer.mTexCoordPointer, 2, GLES20.GL_FLOAT, false, 2 * 4, mTexture);

        // Load the vertex position.
        mVertices.position(0);
        GLES20.glVertexAttribPointer(aRenderer.mPositionPointer, 3, GLES20.GL_FLOAT, false, 3 * 4, mVertices);

        // Load the vertex color.
        mColor.position(0);
        GLES20.glVertexAttribPointer(aRenderer.mColorPointer, 4, GLES20.GL_FLOAT, false, 4 * 4, mColor);

        // Set the texture.
        GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
        GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, aRenderer.mTexturePointer[mTextureId]);
        GLES20.glUniform1i(aRenderer.mSamplerPointer, 0);

        // Calculate stuff.
        Matrix.multiplyMM(aRenderer.mMVPMatrix, 0, aRenderer.mViewMatrix, 0, aRenderer.mModelMatrix, 0);
        Matrix.multiplyMM(aRenderer.mMVPMatrix, 0, aRenderer.mProjectionMatrix, 0, aRenderer.mMVPMatrix, 0);

        GLES20.glUniformMatrix4fv(aRenderer.mMVPMatrixPointer, 1, false, aRenderer.mMVPMatrix, 0);

        GLES20.glDrawElements(GLES20.GL_TRIANGLES, 6, GLES20.GL_UNSIGNED_SHORT, mIndices);

        GLES20.glDisableVertexAttribArray(aRenderer.mPositionPointer);
        GLES20.glDisableVertexAttribArray(aRenderer.mTexCoordPointer);
        GLES20.glDisableVertexAttribArray(aRenderer.mColorPointer);
    }
}

The loadTexture() Method:

public void loadTextures(){

    Log.d("loadTextures()", "Loading textures");

    Bitmap tBitmap = null;

    // Tell OpenGL to generate textures.
    GLES20.glGenTextures(32, mTexturePointer, 0);

    BitmapFactory.Options options = new BitmapFactory.Options();
    options.inTempStorage = new byte [16 * 1024];
    options.inScaled = false;

    // TEXTURE 0
    GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
    GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mTexturePointer[0]);

    // Scale up if the texture if smaller.
    GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR);
    GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR);

    tBitmap = BitmapFactory.decodeResource(mContext.getResources(), R.drawable.ingame_boll_spritesheet_new_style, options);

    GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, tBitmap, 0);

    tBitmap.recycle();
    // TEXTURE 1
    GLES20.glActiveTexture(GLES20.GL_TEXTURE1);
    GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mTexturePointer[1]);

    // Scale up if the texture if smaller.
    GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR);
    GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR);

    tBitmap = BitmapFactory.decodeResource(mContext.getResources(), R.drawable.ingame_boll_mouth, options);

    GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, tBitmap, 0);

    tBitmap.recycle();

    // And so on for all textures

    Log.d("loadTextures()", "Loaded textures");

}

I have looked very closely and the .pngs is not the problem. I tried setting the vertex colors alpha to -1 and yes, the texture disappear but the dotting is still there. When i disable the blending all transparency gets black and the dotting disappear. I can’t figure out what to try next, when the fragment shader outputs alpha 0.0 and it still gets dotted..

Any feedback on things to try is appreciated. Thank you!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T05:09:12+00:00Added an answer on May 31, 2026 at 5:09 am

    It seems like a color-depth problem. You should set your surface and window to 32 bit mode and see if that helps:

    glview.setEGLConfigChooser(8, 8, 8, 8, 16, 0);
    

    and

    getWindow().setFormat(PixelFormat.RGBA_8888);
    

    It should not be necessary to dither anything now that the window and surface uses the same amount of bits, but sometimes it can give a better result, so you can try to enable that for both the window and openGL as well.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a French site that I want to parse, but am running into
I have thousands of HTML files to process using Groovy/Java and I need to
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
I am reading a book about Javascript and jQuery and using one of the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.