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?
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
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…
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.