erichlof / THREE.js-PathTracing-Renderer

Real-time PathTracing with global illumination and progressive rendering, all on top of the Three.js WebGL framework. Click here for Live Demo: https://erichlof.github.io/THREE.js-PathTracing-Renderer/Geometry_Showcase.html
Creative Commons Zero v1.0 Universal
1.88k stars 171 forks source link

[question] how to debug glsl in chrome? #73

Closed sonygod closed 1 year ago

sonygod commented 1 year ago

how to debug glsl in chrome?

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

erichlof commented 1 year ago

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

sonygod commented 1 year ago

ok, so I close this issue.thanks .