Hacker News new | ask | show | jobs
by JimJames 4761 days ago
Isn't the algorithm just, filter out the greenscreen, for each remaining pixel draw it to the buffer, draw the buffer to the screen?

That doesn't seem more complicated than the examples they showed.

2 comments

No one said it would be MORE complicated than the examples.

"Would also be interesting" and "fun to compare" give no implication of relative difficulty. I would like to see the algorithm though so please post the code if you get it working in JS! That would be awesome!

It is actually slightly more complicated. The existing effects work in GLSL and are just transforming single frames of video. For that effect to work, you need the previous buffer states; this means that seeking will cause the image to be different, and you need to feed the previous render state back as a texture.
Just draw the frames to a 2D canvas, without clearing it, then back to the background buffer.
You still need to remove the green-screen. This either means an expensive process on the CPU side, or pushing the frame to the GPU to remove it with a shader and then using RTT and rendering that or reading the framebuffer and drawing that to a canvas. Note, it's really not difficult to do this, it's just slightly more complex than the other effects, is all.
The demo is already removing the green-screen, I don't think that's the most expensive part.
Well no, the demo is removing the green screen but only in the shaders. As I said, this really isn't a big deal, but it does add complexity.