Geeks3D Forums

GeeXLab => GeeXLab - english forum => Topic started by: Stefan on February 26, 2016, 06:07:34 PM

Title: How to use webcam texture in a GLSL Shader
Post by: Stefan on February 26, 2016, 06:07:34 PM
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<<< (https://drive.google.com/file/d/0BykQ4pHxfGQWNXUwNkpSVUdidjQ/view)

(http://img.techpowerup.org/160226/stefan031-20160226.png)


(http://img.techpowerup.org/160226/stefan032-20160226.png)

Wrist slitter, originally for video texture

(http://img.techpowerup.org/160226/stefan033-20160226.png)
Title: Re: How to use webcam texture in a GLSL Shader
Post by: JeGX on February 26, 2016, 06:37:34 PM
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.




Title: Re: How to use webcam texture in a GLSL Shader
Post by: Stefan on February 26, 2016, 07:06:50 PM
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<<< (https://drive.google.com/file/d/0BykQ4pHxfGQWM18wWWNQai1MdEE/view)

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