How to use webcam texture in a GLSL Shader

Started by Stefan, February 26, 2016, 06:07:34 PM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

Stefan

That one is quite easy

init_scene:

copy webcam code from geexlab_code_sample_pack/host_api/webcam/webcam_win32_spout_test.xml ( the other demos didn't work on my rig for some reason)

rename tex01 to webcamtex to avoid confusion

and don't forget (like me in first place) to add

quad = gh_mesh.create_quad(winW, winH)
shadertoy_prog = gh_node.getid("shadertoy_prog")



update_scene:

gh_texture.bind(webcamtex, 0)
gh_utils.webcam_grab_frame(webcam1)
gh_utils.webcam_update_texture(webcam1, webcamtex)
gh_gpu_program.uniform1i(shadertoy_prog, "iChannel0", 0)


That's all.

>>>download RippleCam<<<






Wrist slitter, originally for video texture


JeGX

Thanks for the effect!

Quote from: Stefan on February 26, 2016, 06:07:34 PM

copy webcam code from geexlab_code_sample_pack/host_api/webcam/webcam_win32_spout_test.xml ( the other demos didn't work on my rig for some reason)


I think it's because the demo tries to connect to the second webcam. Look for the following line in the INIT script:

gh_utils.webcam_start(webcam1, 2)


and replace it by:

gh_utils.webcam_start(webcam1, 1)


I have two webcams on my system and I forgot to update the demos.





Stefan

Quote from: JeGX on February 26, 2016, 06:37:34 PM

I think it's because the demo tries to connect to the second webcam.

Yes, that was the culprit.

I quickly converted some video demos to webcam demos.
Hail to the clipboard  :P

>>> download 10 webcam demos<<<

QuoteRippleCam_gl2.xml
webcam_Ascii_Art_gl2.xml
webcam_BillBoarding_gl2.xml
webcam_EGA_Style_gl2.xml
webcam_fractal_gl2.xml
webcam_heightfield_gl2.xml
webcam_mush_gl2.xml
webcam_Old_video_gl2.xml
webcam_Page_Curl_Effect_gl2.xml
webcam_Wrist_Slitter_gl2.xml