View Full Version : Return/Output variables from shader
07-15-2011, 10:48 AM
Hello. I've been learning GLSL recently, however it's difficult to debug my code without some type of output to see what is happening.
In C I usually output to a file variable values when I need to, but I haven't been able to find a way to get the values of variables in a shader program. Is there any way to output these so I can tell what is happening in the program?
07-15-2011, 11:06 AM
The only thing you can do to debug a shader (outside of using a shader debugger) is to write values on the screen. Your vertex shader can always return vertices directly in clip-space (which is in front of the viewer), and your fragment shader can return any value it wants.
07-15-2011, 11:34 AM
Ok thanks. So the fragment shader can return a value to my code? That would help as I'm trying to get a handle on how depth is handled there compared to the depth handling in the code.
07-15-2011, 11:41 AM
So the fragment shader can return a value to my code?
No. It can write values to the screen. As in colors. That's what fragment shaders write.
When you debug a fragment shader, you use the ability to write colors to tell you something about what is going on in the shader. You can write a specific number as a color, you can write some value conditionally to test things, etc.
07-15-2011, 11:45 AM
Ahh ok. Thanks!
07-19-2011, 12:16 AM
The gDEBugger at http://www.gremedy.com/ can help you. You can single step drawing calls and monitor shader uniforms.
Powered by vBulletin® Version 4.2.3 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.