Log in or register to post comments

Apply Occlusion effect on Model

December 8, 2014 - 9:24pm #1

Hello guys, I'm working on android application. In this application I have use native java code for loading 3D Frame and 2D image. I have load both of these models on surface view while camera is running using OpenGl. I have used Vuforia SDK for image detection to augment 3D Frame and 2D model. After augmenting 3D model and and 2D image successfully shown in attached image I've applied pinch zoom effect using Scale Gesturelistner.

So right now I'm facing below problems

1) After zooming image, Image is displyed outside of frame

2) I'm want to apply pinch zoom only for Image. For scale gesture listener is applied for whole surfaceview.

3) How to apply occlusion effect for another mask model so that I can hide rest part of image which is displyrd outside of frame.

 

I have load another model so that I can give occlusion effect to that model. I have try the code given in occlusion sample for vuforia. But this model is displayed as a black background. Plese find attached image. This is my code for occlusion.

 

 

 GLES20.glDepthFunc(GLES20.GL_LEQUAL);
          GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
          Renderer.getInstance().bindVideoBackground(vbVideoTextureUnit);
           GLES20.glActiveTexture(GLES20.GL_TEXTURE0 + vbMaskTextureUnit);
           GLES20.glBindTexture(GLES20.GL_TEXTURE_2D,
               mTextures.get(1).mTextureID[0]);
           GLES20.glEnable(GLES20.GL_BLEND);
           GLES20.glBlendFunc(GLES20.GL_SRC_ALPHA,
               GLES20.GL_ONE_MINUS_SRC_ALPHA);
           GLES20.glViewport(viewportPosition_x, viewportPosition_y,
               viewportSize_x, viewportSize_y);
           
           GLES20.glDisable(GLES20.GL_DEPTH_TEST);
           GLES20.glUseProgram(vbShaderProgramOcclusionID);
           GLES20.glVertexAttribPointer(vbVertexPositionOcclusionHandle, 3,
               GLES20.GL_FLOAT, false, 0, objrenderer_mask.getVertexbuffer());
           GLES20.glVertexAttribPointer(vbVertexTexCoordOcclusionHandle, 2,
               GLES20.GL_FLOAT, false, 0, objrenderer_mask.gettexturewbuffer());
           GLES20.glEnableVertexAttribArray(vbVertexPositionOcclusionHandle);
           GLES20.glEnableVertexAttribArray(vbVertexTexCoordOcclusionHandle);
           
           GLES20.glUniform2f(vbViewportOriginHandle, viewportPosition_x,
               viewportPosition_y);
           GLES20.glUniform2f(vbViewportSizeHandle, viewportSize_x,
               viewportSize_y);
           GLES20.glUniform2f(vbTextureRatioHandle, uRatio, vRatio);
           GLES20.glUniform2f(vbPrefixHandle, prefix[0], prefix[1]);
           GLES20.glUniform2f(vbInversionMultiplierHandle,
               inversion_multiplier[0], inversion_multiplier[1]);
           GLES20.glUniform1i(vbPortraitHandle, isPortrait ? 1 : 0);
           GLES20.glUniform1i(vbTexSamplerVideoOcclusionHandle,
               vbVideoTextureUnit);
           GLES20.glUniform1i(vbTexSamplerMaskOcclusionHandle,
               vbMaskTextureUnit);
           GLES20.glUniformMatrix4fv(vbProjectionMatrixOcclusionHandle, 1,
               false, modelViewProjection_mask, 0);
           GLES20.glDrawArrays(GLES20.GL_TRIANGLES,0,48);
                      
           
           GLES20.glDisableVertexAttribArray(vbVertexPositionOcclusionHandle);
           GLES20.glDisableVertexAttribArray(vbVertexTexCoordOcclusionHandle);
           GLES20.glUseProgram(0);
           
           GLES20.glDisableVertexAttribArray(vertexHandle_mask);
   GLES20.glDisableVertexAttribArray(normalHandle_mask);
   GLES20.glDisableVertexAttribArray(textureCoordHandle_mask);
           
           GLES20.glDepthFunc(GLES20.GL_LESS);
           SampleUtils.checkGLError("Transparency layer");
         
           GLES20.glDisable(GLES20.GL_BLEND);
           GLES20.glDisable(GLES20.GL_DEPTH_TEST);
Log in or register to post comments