WebGL
Khronos
 

WebGL WEBGL_texture_from_depth_video Extension Rejected Specification

Name

WEBGL_texture_from_depth_video

Contact

WebGL working group (public_webgl 'at' khronos.org)

Contributors

Ningxin Hu, Intel

Anssi Kostiainen, Intel

Rob Manson, buildAR

Members of the WebGL working group

Version

Last modified date: January 24, 2015
Revision: 2

Number

WebGL extension #NN

Dependencies

Written against the WebGL API 1.0 specification.

Overview

This extension provides support for the Media Capture Depth Stream Extensions. Specifically, it supports uploading to a WebGL texture a video element whose source is a MediaStream object containing a depth track.

When this extension is enabled:

IDL

[NoInterfaceObject]
interface WEBGL_texture_from_depth_video {
};
  

Sample Code

This code sets up a video element from a depth stream, uploads it to a WebGL texture, and samples that texture in the fragment shader, reconstructing the 16-bit depth values from the red, green and blue channels.
var ext = gl.getExtension("WEBGL_texture_from_depth_video");
if (ext) {
  navigator.getUserMedia({ video: true }, successVideo, failureVideo);
}

var depthVideo;

function successVideo(s) {
  // wire the stream into a <video> element for playback
  depthVideo = document.querySelector('#video');
  depthVideo.src = URL.createObjectURL(s);
  depthVideo.play();
}

// ... later, in the rendering loop ...

if (ext) {
 gl.texImage2D(
     gl.TEXTURE_2D,
     0,
     gl.RGB,
     gl.RGB,
     gl.UNSIGNED_SHORT_5_6_5,
     depthVideo
   );  
}

<script id="fragment-shader" type="x-shader/x-fragment">
  varying vec2 v_texCoord;
  // u_tex points to the texture unit containing the depth texture.
  uniform sampler2D u_tex;
  void main() {
    vec4 floatColor = texture2D(u_tex, v_texCoord);
    vec3 rgb = floatColor.rgb;
    ...
    float depth = 63488. * rgb.r + 2016. * rgb.g + 31. * rgb.b;
    ...
  }
</script>

Issues

Revision History

Revision 1, 2014/11/03

Revision 2, 2015/01/24