webgl运动检测:闪烁输出

时间:2013-11-05 22:50:03

标签: three.js glsl webgl motion-detection

尝试使用WebGL / Three.js进行简单的帧减法

当前演示:http://zebradog.github.io/camera/motion.html

Shader here:https://github.com/zebradog/camera/blob/master/js/shaders/motion.js

输出似乎是每隔一帧闪烁/渲染。我认为这是animate()中交换帧缓冲区的问题,但似乎无法找到问题:

https://github.com/zebradog/camera/blob/master/motion.html#L139

if ( video.readyState === video.HAVE_ENOUGH_DATA ){
    prevTexture.image.data = videoTexture.image.data;
    videoContext.drawImage(video, 0, 0,SCREEN_WIDTH,SCREEN_HEIGHT);
    videoTexture.image.data = new Uint8Array(videoContext.getImageData(0,0,SCREEN_WIDTH, SCREEN_HEIGHT).data);
    if(prevTexture.image.data.length) {
      prevTexture.needsUpdate = true;
    }
    videoTexture.needsUpdate = true;
  }

0 个答案:

没有答案