By DonCossack
on Thu, 10/30/2014 - 12:46
Hi.
I am implementing Vuforia on Android. I am using example ImageTargetsNative. I replace the teapot model with 2D plane image. I modified the native C++ rendering code as instructed here:
https://developer.vuforia.com/resources/dev-guide/textured-plane-targetEverything is OK. But now when I try to use my own png image (512x512), I always get a black background. My image has transparent background. Now the plane 2D image fits the target image, but left a black background.
Screenshot in the attachment, you can see the black background around the image of a skirt.
Can you please make any suggestion how to remove it? I wan the backbround to be transparent completely.
const Texture* const thisTexture = textures[textureIndex]; QCAR::Matrix44F modelViewProjection; SampleUtils::translatePoseMatrix(0.0f, 0.0f, kObjectScale, &modelViewMatrix.data[0]); SampleUtils::scalePoseMatrix(targetSize.data[0], targetSize.data[1], 1.0f, &modelViewMatrix.data[0]); SampleUtils::multiplyMatrix(&projectionMatrix.data[0], &modelViewMatrix.data[0] , &modelViewProjection.data[0]); glUseProgram(shaderProgramID); glVertexAttribPointer(vertexHandle, 3, GL_FLOAT, GL_FALSE, 0, (const GLvoid*) &planeVertices[0]); glVertexAttribPointer(normalHandle, 3, GL_FLOAT, GL_FALSE, 0, (const GLvoid*) &planeNormals[0]); glVertexAttribPointer(textureCoordHandle, 2, GL_FLOAT, GL_FALSE, 0, (const GLvoid*) &planeTexcoords[0]); glEnableVertexAttribArray(vertexHandle); glEnableVertexAttribArray(normalHandle); glEnableVertexAttribArray(textureCoordHandle); glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, thisTexture->mTextureID); glUniformMatrix4fv(mvpMatrixHandle, 1, GL_FALSE, (GLfloat*)&modelViewProjection.data[0] ); glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, (const GLvoid*) &planeIndices[0]); glDisableVertexAttribArray(vertexHandle); glDisableVertexAttribArray(normalHandle); glDisableVertexAttribArray(textureCoordHandle);
Here is the rendering code from ImageTarget.cpp
black background in plane 2D texture
OK I found it after much frustration....
http://stackoverflow.com/questions/17676017/translucent-models-using-vuforia-sdk-for-augmented-reality