Monday, April 11, 2016

glsl - Debugging Shader Code?


I'm writing a game engine, and when I use a perspective camera I get a black screen. I am not going to ask exactly why this is because there would be a lot of code to share and, frankly, I think that's a bit petty a question even to bother you all with.


The trouble is that I don't know how to debug it. All that changes is my projection matrix, and if my projection matrix looks fine, I don't know why it doesn't work. Ideally I'd print out the values of various things as the shader did its calculations, but GLSL inconveniently doesn't have a printf() function.


So my question is: how do I debug my problem? The only thing I can think of is checking as many values as I can client-side and then programming by permutation, but I've done that and gotten nowhere. Is there a way I can see what's happening in the video card? Is there a completely different technique I could be using?



I'm using GLSL version 420 (and features specific to that version), so I don't think that glslDevil is an option, considering that it was last updated in 2010.


EDIT


I managed to solve my problem through some completely unrelated debugging.



Answer



You can also use a program like glIntercept, which is like PIX but then for OpenGL. Next to intercepting and logging all calls it also let's you display shader usage and edit the shaders at run time. This last option (editing the shaders at runtime) could be extremely helpful when debugging because you can keep editing in parts until something goes wrong and you can quickly debug a value by outputting a color.


http://code.google.com/p/glintercept/


No comments:

Post a Comment

Simple past, Present perfect Past perfect

Can you tell me which form of the following sentences is the correct one please? Imagine two friends discussing the gym... I was in a good s...