-
i been searching on a way to do what i can do in javscript and the canvas context 2d, change the pixels color or delete them. I can't figure it out. I have search all over the internet and can't come across some code. I have read the website but still have a hard time wrapping my head around webgl. https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API/Manipulating_video_using_canvas in the above link is what i want to do in webgl. that exactly what i want to do in webgl, how do i write the logic in the fragment shader to do this? |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 4 replies
-
You copy the video every frame into a texture. Also supply the texture you want to mix into the same shader One example is here https://webglfundamentals.org/webgl/lessons/webgl-2-textures.html which is a followed up to the articles about image processing Just change the images to videos and continue drawing each frame. Example: |
Beta Was this translation helpful? Give feedback.
-
You need translate the code from the article
Into GLSL That is basically
https://jsgist.org/?src=9a6ff91dfa2f72df3ac3f98dd5327a33 But that is specific to that one example video |
Beta Was this translation helpful? Give feedback.
-
I don't know what you mean? Are you saying the code doesn't run? Screen.Recording.2022-05-02.at.10.19.29.AM.movOr are you saying something else? The code you posted seems to have a typo this
Is really this
So it always returns black If it was me I'd try to do something more generic. Examples (1) Use a uniform
Then you can pass in the color gl.uniform3fv(minColorLocationYouLookedUpPreviously, [10 / 255, 10 / 255, 10 / 255]); Maybe 10 is the wrong value and you need 20 or 30 or 55 or whatever (2) Use more GLSLcontining from 1 above
(3) Compute a perceptual luminance.I'm not entirely sure what the correct values are but looking at this it looks like maybe
Of course you can achieve the same result but just using different values for r,g,b in (1) above. |
Beta Was this translation helpful? Give feedback.
-
One where you can set the minColor https://jsgist.org/?src=398b5b5505ad1938a8cae6201f9e5d28 Screen.Recording.2022-05-02.at.10.46.03.AM.mov |
Beta Was this translation helpful? Give feedback.
I don't know what you mean? Are you saying the code doesn't run?
Screen.Recording.2022-05-02.at.10.19.29.AM.mov
Or are you saying something else?
The code you posted seems to have a typo
this
Is really this
So it always returns black
If it was me I'd try to do something more generic. Examples
(1) Use a uniform