GLSL Edge Detection

Here is an edge detection I created for class.  I used a Laplacian stencil sums up, down, left, and right values and subtracts them by 4 times the center value.

 


Vert Shader

 uniform sampler2D my_color_texture;
varying vec2 texc;

varying vec2 left_coord;
varying vec2 right_coord;
varying vec2 above_coord;
varying vec2 below_coord;
float d = 0.001;

void main()
{
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
texc = vec2(gl_MultiTexCoord0);

left_coord = texc.xy + vec2(-d , 0);
right_coord = texc.xy + vec2(d , 0);
above_coord = texc.xy + vec2(0,d);
below_coord = texc.xy + vec2(0,-d);

}

Frag Shader:

varying vec2 texc;
uniform sampler2D my_color_texture;

varying vec2 left_coord;
varying vec2 right_coord;
varying vec2 above_coord;
varying vec2 below_coord;

void main()
{

gl_FragColor = texture2D(my_color_texture, texc);
gl_FragColor.a = 1.0; //Best to make sure nothing seems transparent

vec2 c = texc.xy;
vec4 diffuse_color = texture2D(my_color_texture, texc);
vec4 diffuse_colorL = texture2D(my_color_texture, left_coord);
vec4 diffuse_colorR = texture2D(my_color_texture, right_coord);
vec4 diffuse_colorA = texture2D(my_color_texture, above_coord);
vec4 diffuse_colorB = texture2D(my_color_texture, below_coord);

gl_FragColor = (diffuse_colorL + diffuse_colorR +diffuse_colorA +
diffuse_colorB ) - (4.0 *diffuse_color);
gl_FragColor = vec4(gl_FragColor.r, gl_FragColor.r, gl_FragColor.r, 1.0);
gl_FragColor.a = 1.0;

}

Graveyard Database Logo

Has everything you want to know about grave yards. Plus has many celebrites and world leaders graves. Pssst it is my other site

Google + Profile
Check out Android Photo Mapping, its a app/site I been working on

  • wholesale nfl jerseys
  • wholesale nfl jerseys china
  • wholesale sports jerseys