Nodes/Jovi_GLSL/SOBEL (JOV_GL)
ComfyUI Node

SOBEL (JOV_GL)

Finds the edges of an image

By Amorano·Created 2 years ago·Updated 12 months ago· 20
SOBEL (JOV_GL)
  • image
  • RGBA
  • RGB
  • MASK
FRAGMENT// name: SOBEL // desc: Finds the edges of an image // category: FILTER uniform sampler2D image; // | RGB(A) image void mainImage( out vec4 fragColor, in vec2 fragCoord ) { float x = 1.0 / iResolution.x; float y = 1.0 / iResolution.y; vec2 uv = fragCoord / iResolution.xy; vec4 horizEdge = vec4( 0.0 ); horizEdge -= texture( image, vec2( uv.x - x, uv.y - y ) ) * 1.0; horizEdge -= texture( image, vec2( uv.x - x, uv.y ) ) * 2.0; horizEdge -= texture( image, vec2( uv.x - x, uv.y + y ) ) * 1.0; horizEdge += texture( image, vec2( uv.x + x, uv.y - y ) ) * 1.0; horizEdge += texture( image, vec2( uv.x + x, uv.y ) ) * 2.0; horizEdge += texture( image, vec2( uv.x + x, uv.y + y ) ) * 1.0; vec4 vertEdge = vec4( 0.0 ); vertEdge -= texture( image, vec2( uv.x - x, uv.y - y ) ) * 1.0; vertEdge -= texture( image, vec2( uv.x , uv.y - y ) ) * 2.0; vertEdge -= texture( image, vec2( uv.x + x, uv.y - y ) ) * 1.0; vertEdge += texture( image, vec2( uv.x - x, uv.y + y ) ) * 1.0; vertEdge += texture( image, vec2( uv.x , uv.y + y ) ) * 2.0; vertEdge += texture( image, vec2( uv.x + x, uv.y + y ) ) * 1.0; vec3 edge = sqrt((horizEdge.rgb * horizEdge.rgb) + (vertEdge.rgb * vertEdge.rgb)); fragColor = vec4( edge, texture( image, uv ).a ); }
CategoryJOV_GL 🌈/FILTER

Inputs (2)

NameTypeDefaultDescription
imageoptIMAGERGB(A) image
FRAGMENToptSTRING// name: SOBEL // desc: Finds the edges of an image // category: FILTER uniform sampler2D image; // | RGB(A) image void mainImage( out vec4 fragColor, in vec2 fragCoord ) { float x = 1.0 / iResolution.x; float y = 1.0 / iResolution.y; vec2 uv = fragCoord / iResolution.xy; vec4 horizEdge = vec4( 0.0 ); horizEdge -= texture( image, vec2( uv.x - x, uv.y - y ) ) * 1.0; horizEdge -= texture( image, vec2( uv.x - x, uv.y ) ) * 2.0; horizEdge -= texture( image, vec2( uv.x - x, uv.y + y ) ) * 1.0; horizEdge += texture( image, vec2( uv.x + x, uv.y - y ) ) * 1.0; horizEdge += texture( image, vec2( uv.x + x, uv.y ) ) * 2.0; horizEdge += texture( image, vec2( uv.x + x, uv.y + y ) ) * 1.0; vec4 vertEdge = vec4( 0.0 ); vertEdge -= texture( image, vec2( uv.x - x, uv.y - y ) ) * 1.0; vertEdge -= texture( image, vec2( uv.x , uv.y - y ) ) * 2.0; vertEdge -= texture( image, vec2( uv.x + x, uv.y - y ) ) * 1.0; vertEdge += texture( image, vec2( uv.x - x, uv.y + y ) ) * 1.0; vertEdge += texture( image, vec2( uv.x , uv.y + y ) ) * 2.0; vertEdge += texture( image, vec2( uv.x + x, uv.y + y ) ) * 1.0; vec3 edge = sqrt((horizEdge.rgb * horizEdge.rgb) + (vertEdge.rgb * vertEdge.rgb)); fragColor = vec4( edge, texture( image, uv ).a ); }

Outputs (3)

NameTypeDescription
RGBAIMAGEFull channel [RGBA] image. If there is an alpha, the image will be masked out with it when using this output.
RGBIMAGEThree channel [RGB] image. There will be no alpha.
MASKMASKSingle channel mask output.