Search code examples
algorithmshaderfragment-shaderedge-detectioncompute-shader

what are the common used fast Edge Detection Algorithm using GPU shader(glsl, hlsl, not CUDA)?


what's the fastest Edge Detection Algorithm using GPU shader(glsl, hlsl, not CUDA)?

  1. just fragment-shader, just image-processing, no matter the image is colorful or gray
  2. color buffer with normal buffer and depth buffer.

Solution

  • simple edge detector using convolution matrix (partial derivation by x):

    -1 +1
    

    and (partial derivation by y):

    -1
    +1
    

    You can do this with standard pipeline no need for compute shaders:

    1. render rectangle covering screen/image/whatever

      with input image as texture

    2. in fragment shader compute the edge (1st derivation)

      so for each fragment fetch corresponding 2 (or 3 if done both derivations in one step) texels compute the resulting color and output it

    both partial derivations are sometimes combined together one goes to one channel of color and the other to next one ...

    In case you do this in 2D you can also use depth buffer to obtain 3D position and do also partial derivation in z axis ...

    This approach is fast as GPU is rendering just single rectangle with very simple shaders