Anime4K icon indicating copy to clipboard operation
Anime4K copied to clipboard

Create WebGL Shader implementation for use in HTML5 browsers

Open mdale opened this issue 4 years ago • 10 comments

Implementation in wasm or webgl shader that worked with video tag / canvas would be very interesting and would let foulks pop this into web anime players as an option. Would the runtime be fast enough for real-time in web context ?

mdale avatar Aug 15 '19 07:08 mdale

It should be quite doable to take a video, render it to a canvas and apply WebGL effects. The GLSL shader seems simple enough. It would potentially lag behind 1-3 frames, but that's not an issue since it's a video and not a realtime game.

Ideally, that would be turned into a browser plugin so that it could be used on most websites.

stefnotch avatar Aug 15 '19 07:08 stefnotch

@mdale If you're interested in implementing this, I'd be willing to help out.

stefnotch avatar Aug 15 '19 09:08 stefnotch

@stefnotch sound great. I or someone on my team may take a look in the coming weeks.

mdale avatar Aug 15 '19 17:08 mdale

Hi, I am also interested in that implementation. Here is a gist based on GLSL code. I don't know much about the MPV pipeline and custom shaders so the code is probably wrong. But it seems to work nonetheless. 1 Can anyone verify this code? 😃

NeuroWhAI avatar Aug 17 '19 09:08 NeuroWhAI

On a quick inspection, it doesn't seem to have any obvious flaws. It'd be great if you could put it on a GitHub repository. Then, I could take a closer look at it and submit PRs with improvements.

stefnotch avatar Aug 17 '19 09:08 stefnotch

Just a quick question: Would it be also possible to have it inside an userscript, which runs on certain sites/Webplayers? that would be the best way for endusers i think.

Tsubajashi avatar Sep 26 '19 08:09 Tsubajashi

Of course that would be possible. Although, it might run into issues on the various websites that use a custom video player.

stefnotch avatar Sep 26 '19 08:09 stefnotch

@stefnotch that would be nice, i would work on such a thing if someone gives me starting directions. Custom Video Player are a problem, but i know enough sites i would use which have Standard player

Tsubajashi avatar Sep 26 '19 09:09 Tsubajashi

Anime4k already has a web implementation https://github.com/bloc97/Anime4K/blob/master/web

In the onLoad function, the important setup stuff happens https://github.com/bloc97/Anime4K/blob/333aca5d5760ae58bdea7033d2f25d5bf244ccc8/web/main.js#L662

I'm not the author of it, but I think a userscript would approximately do this

  • Find the correct (or first) video tag instead of using a hardcoded one
  • Add a canvas with the correct size and put it over the video
  • Do pretty much whatever the onLoad function does

stefnotch avatar Sep 26 '19 10:09 stefnotch

@stefnotch hello, this is Anime4K v2.1 WebGL implement, but it can't be work. Would you help me to fix it?

Juszoe avatar Apr 18 '20 07:04 Juszoe