Some trick to see values in GLSL(debugging)?


I wonder if is there some way to see what is the the specific calculated or read variable value inside GLSL function?
How do you usually deal with debugging more sophisticated shaders?

Thanks in advance

There’s two methods I normally use:

  1. Assign the variable to gl_FragColor, scaling if necessary to ensure the range is 0…1, and visually inspect the results. If this fails…

  2. Create an FBO with a high-bit depth format (like RGBA32F) and again assign the variable to gl_FragColor. I then read the pixels back, and either print the results to stdout, or and write out the data as an HDR image (like a TIFF or EXR). You’ll need a image viewer that can inspect pixel values and support HDR images for the latter.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.