Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: Queries about my edge detection shader and RTT

  1. #1
    Junior Member Regular Contributor
    Join Date
    Jun 2006
    Location
    Edinburgh - Scotland
    Posts
    146

    Queries about my edge detection shader and RTT

    Hi,
    I've written an edge detect shader and after bashing my head against a wall I got it working, but I'm not sure why.

    First off, this reference Orange Book, section 19.7.2 (and I'm sure there were others, or similar), shows a convolution matrix of
    Code :
       0, 1, 0
       1,-4, 1
       0, 1, 0
    but that will produce a -ve final vector and if I set gl_FragColor it then I get black. So I had to negate the above matrix. I'm I missing something?

    The second thing is I am rendering a 2048x2048 texture to a 128x128 texture. I thought the offsets to move the sample coord would be 1/2048 (e.g. add 1/2048,1/2048 to S,T to sample the pixel 1 to the right and 1 up from the current pixel), but I had to use 1/128. Don't undertand why.

    Thanks,

    Stuart.

  2. #2
    Junior Member Regular Contributor
    Join Date
    Jun 2006
    Location
    Edinburgh - Scotland
    Posts
    146

    Re: Queries about my edge detection shader and RTT

    D'oh! Shouldn't have been doing that at 1 in the morning. Realised why it's 1/128 (since the 2040 texture is mapped to a 128 quad).

    However, still interested if I am missing something about the matrix values.

  3. #3
    Super Moderator OpenGL Lord
    Join Date
    Dec 2003
    Location
    Grenoble - France
    Posts
    5,575

    Re: Queries about my edge detection shader and RTT

    The matrix above will produce 0 for flat color areas, 1 for pure black to pure white transition as well as from white to black, etc. You want to multiply the result if it is too dark.

    If the original image is too blurry, you may have to widen the kernel.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •