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 7 of 7

Thread: How to debug with shader, I've been stuck for 2 days and having no clue...

  1. #1
    Junior Member Newbie
    Join Date
    Aug 2011
    Posts
    20

    Question How to debug with shader, I've been stuck for 2 days and having no clue...

    I'm a beginner in opengl, recently I'm learning GLSL.
    but I find it's really difficult to dubug because I can't make break piont in shader files(that't usually how I do it).
    I also tried use transform feedback to retrieve data from shader files but ended up getting (0, 0, 0, 0) all the time, so I assume there must be something wrong in my setup of transform feedback.

    How do you guys debug with shaders efficiently? can some tell me how to use transform feedback?
    Last edited by Sobeit; 12-06-2012 at 11:01 PM.

  2. #2
    Senior Member OpenGL Pro
    Join Date
    Jan 2012
    Location
    Australia
    Posts
    1,098
    I usually end up changing the colour render to something based on the shader logic; eg if I expect some value to be say < 0.5 I out vec4(1,0,0,1) if it is and vec4(0,1,0,1) if it is not.
    It is a bit slow but without a proper debugger there is not much else

  3. #3
    Intern Newbie
    Join Date
    Oct 2010
    Posts
    47
    I am a beginner too.
    I used the color to verify some values. For example :
    gl_FragColor = vec4(N.x, N.y, N.z, 1); // N is a normal
    if ((N.x < 0.019) &&(N.y < 0.019) && (N.z < 0.019)) gl_FragColor = vec4(1,0,0,1);
    When I had problems with lights I rendered with ambient only then with diffuse only, etc...

    It's like the old "printf" debug... Not easy...

  4. #4
    Junior Member Regular Contributor
    Join Date
    Dec 2007
    Posts
    249
    debugging shaders is hard
    I've done the old, debug to colour output. But when that's clamped to 0-1 can make it hard.

  5. #5
    Junior Member Newbie
    Join Date
    Jan 2011
    Posts
    9
    When color coding is not enough, i use RGBA32UI texture as another render target and modify shader to pack needed information of its execution as bitfields and render it to that texture. Then i hover mouse pointer on suspicious pixel, read that pixel by pressing a key and decode info.

    It's not easy to setup all that stuff, but it helps.

  6. #6
    Senior Member OpenGL Pro
    Join Date
    Jan 2012
    Location
    Australia
    Posts
    1,098
    nuclear_bro - thats not a bad idea - I might try that.

  7. #7
    Junior Member Newbie
    Join Date
    Aug 2011
    Posts
    20
    thank you guys. debug with color is a great idea, I'll try that out.

Tags for this Thread

Posting Permissions

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