Log in or register to post comments

Video Transparency Critical

April 8, 2013 - 4:06am #1

Hi ,

 

I need to implement video transparency  for my videos

i used the below link as suggested

http://pilcrowpipe.blogspot.in/2013/03/chroma-keying-transparent-background.html

 

But my video gets disappear.

Video Playbackshaders.h

static const char* videoPlaybackVertexShader =
    "attribute vec4 vertexPosition; \n"
    "attribute vec4 vertexNormal; \n"
    "attribute vec2 vertexTexCoord; \n"
    "varying vec2 texCoord; \n"
    "varying vec4 normal; \n"
    "uniform mat4 modelViewProjectionMatrix; \n"
    "void main() \n"
    "{ \n"
    "   gl_Position = modelViewProjectionMatrix * vertexPosition; \n"
    "   normal = vertexNormal; \n"
    "   texCoord = vertexTexCoord; \n"
    "} \n";

/*
 *
 * IMPORTANT:
 *
 * The SurfaceTexture functionality from ICS provides the video
 * frames from the movie in an unconventional format. So we cant
 * use Texture2D but we need to use the ExternalOES extension.
 *
 * Two things that are important in the shader below. The first is
 * the extension declaration (first line). The second is the type
 * of the texSamplerOES uniform.
 *
 */

static const char videoPlaybackFragmentShader[] =
  "#extension GL_OES_EGL_image_external : require \n"
  "precision mediump float; \n"
  "uniform samplerExternalOES texSamplerOES; \n"
  "   varying vec2 texCoord;\n"
  "   varying vec2 texdim0;\n"
  "   void main()\n\n"
  "   {\n"
  "       vec3 keying_color = vec3(%f, %f, %f);\n"
  "       float thresh = 0.8; // [0, 1.732]\n"
  "       float slope = 0.2; // [0, 1]\n"
  "       vec3 input_color = texture2D(texSamplerOES, texCoord).rgb;\n"
  "       float d = abs(length(abs(keying_color.rgb - input_color.rgb)));\n"
  "       float edge0 = thresh * (1.0 - slope);\n"
  "       float alpha = smoothstep(edge0, thresh, d);\n"
  "       gl_FragColor = vec4(input_color, alpha);\n"
  "   }";

 

 

Also used below lines 

glDepthFunc(GL_LEQUAL);

glEnable(GL_BLEND);

glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
 
before translateposeMatrix in renderFrame
 
 
Please help me out
 

Video Transparency Critical

April 8, 2013 - 11:52pm #6

Sounds great!

Video Transparency Critical

April 8, 2013 - 7:11am #5

Hi Its working for me now,

 

i was doing silly mistake.

Video Transparency Critical

April 8, 2013 - 6:48am #4

Hi, are you sure this does not work ?

https://developer.vuforia.com/forum/rendering-opengl-es/display-video-chromakey

this is just a thread under the "Rendering with OpenGL ES" section, so you should be able to access it.

Video Transparency Critical

April 8, 2013 - 6:46am #3

Hi , 

 

the first link is not working for me. Second one if for height and width of video

Video Transparency Critical

April 8, 2013 - 6:21am #2
Log in or register to post comments