Each GOP is transformed into a 3D texture composed of slices of width*height consecutives pictures.
=> we can map the frame at time timestamp to a 2D quad from (x0,y0) to (x1,y1) in the z depth using :
glBegin(GL_QUADS);
glTexCoord3f(0,0,timestamp); glVertex3f(x0,y0,z);
glTexCoord3f(1,0,timestamp); glVertex3f(x1,y0,z);
glTexCoord3f(0,1,timestamp); glVertex3f(x0,y1,z);
glTexCoord3f(1,1,timestamp); glVertex3f(x1,y1,z);
glEnd();
where the s,t positions into glTexCoord3f(s,t, timestamp) calls and the (x0,y0) and (x1,y1) positions can be adapted for handle the screen format (4/3, 16/9, etc …) and an automatic zoom in/out
and timestamp is used for to index the slice into the 3D texture (that is an array of 2D pictures that form a video)
=> we have only to increment the timestamp variable (and/or z) in this short code for to display in 3D consecutives frames (and/or slices) from the GOP
With this vertex shader :
void main()
{
gl_FrontColor = gl_Color;
gl_TexCoord[0] = gl_MultiTexCoord0;
gl_Position = ftransform();
}
and this YUV 420 fragment shader :
uniform sampler2D tex;
void main(void)
{
float nx, ny, r, g, b, y, u, v;
float u1,u2,v1,v2;
nx = gl_TexCoord[0].x;
ny = gl_TexCoord[0].y;
y = texture2D(tex, vec2( (nx), (ny)*(4.0/6.0) )).r;
u1 = texture2D(tex, vec2( (nx/2.0), (ny+4.0)/6.0 )).r;
u2 = texture2D(tex, vec2( (nx/2.0)+0.5, (ny+4.0)/6.0 )).r;
v1 = texture2D(tex, vec2( (nx/2.0), (ny+5.0)/6.0 )).r;
v2 = texture2D(tex, vec2( (nx/2.0)+0.5, (ny+5.0)/6.0 )).r;
y = 1.1643 * (y - 0.0625);
u = (u1+u2)/2.0 - 0.5;
v = (v1+v2)/2.0 - 0.5;
r = y + 1.5958 * v;
g = y - 0.39173 * u - 0.8129 * v;
b = y + 2.017 * u;
gl_FragColor=vec4(b,g,r,1.0);
}
I can map videos on the surface of a lot of various 3D animated objects.
This versions of shaders doesn’t use the 3D texture approach, they only map one YUV420 picture into the RGBA domain color of OpenGL textures and display (I work on it and don’t have something that work well for this instant, but this is only a question of hours or days)
The OpenGL output is really very impressive, but the video input seem to me “relatively slow”, so I want something for to boost it
One other side, GOPs can be “simuled” by glTextGenTextures use too …
ZBuffer, how you make quotes ?
@+
Yannoo