Previous topic • Next topic
Questions, comments, feedback, etc.
wko
Posts: 3 Joined: Thu Sep 04, 2014 8:20 am
Post
by wko » 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:
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);
}
Magic
Site Admin
Posts: 3441 Joined: Wed Apr 09, 2014 9:28 pm
Post
by Magic » Wed Sep 17, 2014 1:34 am
In general, you probably won't need to modify any code when you are using shaders.
Assuming you've copied the code into a text file (called "EdgeDetect.txt" for example), just do something like this to use your camera as input:
Does that help?
Eric
wko
Posts: 3 Joined: Thu Sep 04, 2014 8:20 am
Post
by wko » Wed Sep 17, 2014 3:21 am
Yep, It's working!!!!
My webcam drivers was corrupted and I dont know why, a clean installing was necessary for correct function. The shader and output already works, I 'm happy..
Thanks