Search code examples
androidopengl-esarcore

How to load Multiple 2D Texture in a single 3D Object in ARCORE Using OpenGL


This is load a single texture place in single Object

     Bitmap textureBitmap = BitmapFactory.decodeStream(
        context.getAssets().open(diffuseTextureAssetName));
    GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
    GLES20.glGenTextures(mTextures.length, mTextures, 0);
    GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mTextures[0]);

    GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D,
        GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR_MIPMAP_LINEAR);
    GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D,
        GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR);
    GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, textureBitmap, 0);
    GLES20.glGenerateMipmap(GLES20.GL_TEXTURE_2D);
    GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0);  

I need to add Multiple image texture load in to the single 3D object using java code.

Github: https://github.com/google-ar/arcore-android-sdk/issues/113


Solution

  • Texture Rendering involves two things - multi-texturing and multiple-textures. Multi-texturing is basically applying multiple textures at the same time to produce the final output.

    I guess you are referring to multiple textures,activating one after another to render parts of 3D object. Take a look at this C++ answer which suggests the approach.

    What i have done is to separate faces by the materials they use, make the material and texture active - render all the faces. Repeat the same for each of the set of faces.