1

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

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

这里的着色器: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;
  }
4

0 回答 0