Webcam input for the new GLSLShader feature
Posted: Wed Sep 17, 2014 1:21 am
I trying to run a shader from shadertoy.com, but I am lost. The shader use a webcam input and I can't to find the right way.
It is a shader with edge detection, and is located at : https://www.shadertoy.com/view/XssGD7
Can you help me??
the code is:
It is a shader with edge detection, and is located at : https://www.shadertoy.com/view/XssGD7
Can you help me??
the code is:
Code: Select all
#define WEBCAM_RESOLUTION 512.0
void main(void)
{
vec2 uv = gl_FragCoord.xy / iResolution.xy;
// Sobel operator
float offset = 1.0 / WEBCAM_RESOLUTION;
vec3 o = vec3(-offset, 0.0, offset);
vec4 gx = vec4(0.0);
vec4 gy = vec4(0.0);
vec4 t;
gx += texture2D(iChannel0, uv + o.xz);
gy += gx;
gx += 2.0*texture2D(iChannel0, uv + o.xy);
t = texture2D(iChannel0, uv + o.xx);
gx += t;
gy -= t;
gy += 2.0*texture2D(iChannel0, uv + o.yz);
gy -= 2.0*texture2D(iChannel0, uv + o.yx);
t = texture2D(iChannel0, uv + o.zz);
gx -= t;
gy += t;
gx -= 2.0*texture2D(iChannel0, uv + o.zy);
t = texture2D(iChannel0, uv + o.zx);
gx -= t;
gy -= t;
vec4 grad = sqrt(gx*gx + gy*gy);
gl_FragColor = vec4(grad);
}