erichlof/THREE.js-PathTracing-Renderer

[question] how to debug glsl in chrome?

sonygod opened this issue · 2 comments

how to debug glsl in chrome?

I found most of the code you write in glsl? but how to debug it?

Hello @sonygod
Unfortunately, there are not many options for debugging GLSL shader code. Since these shaders run in parallel on the GPU, you can't really get text output and breakpoints like a traditional CPU debugger would offer. There are some tools out there for certain graphics cards, but you have to have one of those types of graphics card and system, like NVIDIA NSight.

There's a relevant discussion about this very topic here:
https://stackoverflow.com/questions/2508818/how-to-debug-a-glsl-shader

Out of the answers given to the OP of that Stack Overflow post, the one I agree with the most is to find simple ways of setting surfaces to bright colors like magenta, so that the affected surfaces will stand out from the rest of the scene if something going wrong. I have actually used this technique myself, and it has served me well in the past.

Graphics programming and GPU shader programming is a very visual process, so it makes sense that if we devise little graphics checks and tests (with if statements in the shader code), then the debugging output will be more visual and scene-based to help us isolate errors in rendering.

Are you having a specific problem with your rendering as of now? Feel free to share it here, or better yet, a screen shot of the problem. I'll do my best to try and see what's going on, and if I can't see the exact problem, I could hopefully point you in the right direction. :-)

-Erich

ok, so I close this issue.thanks .