Anaglyph 3d Video Player For Android – Simple
// Dubois anaglyph red-cyan coefficients float r = left.r * 0.437 + left.g * 0.449 + left.b * 0.164; float g = right.r * 0.062 + right.g * 0.354 + right.b * 0.207; float b = right.r * 0.011 + right.g * 0.101 + right.b * 0.142;
gl_FragColor = vec4(r, g, b, 1.0);
vec4 left = texture2D(uTexture, leftCoord); vec4 right = texture2D(uTexture, rightCoord); anaglyph 3d video player for android
The renderer’s SurfaceTexture feeds frames to the shader. Add a setting in UI:
fun getSurfaceTexture(): SurfaceTexture = surfaceTexture // Dubois anaglyph red-cyan coefficients float r = left
| Format | Sampling logic in shader | |------------------|-------------------------------------------------| | Side‑by‑side | leftCoord.x = vTexCoord.x / 2 | | Over‑under | leftCoord.y = vTexCoord.y / 2 | | Full‑frame left/right | Use separate textures if available |
val mediaPlayer = MediaPlayer().apply setDataSource(videoPath) setSurface(Surface(renderer.getSurfaceTexture())) prepare() start() gl_FragColor = vec4(r
// Anaglyph fragment shader – Dubois optimized matrix precision mediump float; uniform sampler2D uTexture; // frame from video varying vec2 vTexCoord; void main() vec4 color = texture2D(uTexture, vTexCoord);



