Debugging of GLSL code - Any suggestions?

GLSL code is very powerful and yet coding for it is horrible since the compiler is extremely uninformative and very strict.
I spent like an hour trying to find an error and it turned out I had to write 0.0 instead of 0 because one is a floating point and the other is not… really.

Any suggestions on how to debug GLSL code?
What are these programs like ShaderGen or RenderMonkey used for in the openFrameworks universe?

Thanks :smiley:

I’ve found that the open source graphics drivers on linux provide pretty good GLSL compiler error messages. For example the Gallium3D Radeon driver.

I’ll try that when I have time. Thanks Tim S.

There is so much that can go wrong when writting a shader that I’d like to know more.

takes some time to get into, but worth it!
http://www.vis.uni-stuttgart.de/glsldevil/

Question about this, the last update was one 02/16/10, is this program useful when making shaders that will be used in the latest openFrameworks applications? I’ll give it my full attention if it can be.
I had downloaded it before but I didn’t know what it was for.

I’ll make a small walkthrough for openF if it is worth it. :smiley:

good question :slight_smile: Please correct me if i’m wrong.

glsldevil supports up to GLSL 1.1 which is linked to openGL 2.0
(http://www.opengl.org/wiki/Core-Language-(GLSL)

Openframeworks uses GLUT as window manager which is limited to opengl 2.x
(http://forum.openframeworks.cc/t/is-openframeworks-moving-to-opengl-3.0/11534/0)

Given that, there won’t be many shader features unsupported by glsldevil that you do can use in OF.
However, if the next major release will replace GLUT (theo mentioned it in the above post) the glsldevil might not be the best option.

But for learning shaders, its still very usefull :slight_smile:

BTW: the source of glslDevil is opensourced now. You can grab the source from here:

https://github.com/XenonofArcticus/GLSL-Debugger

cheers,

Stephan

Thanks Kj1 and sth.
@Kj1
At the moment I wouldn’t know how to verify your comments about the versions but I guess most of the important functionality is already there. GLSL has more function than I could ever think of using anyways. :smiley:

Any other common tools you guys like?
Maybe a starters guide for not getting a blank screen?
I know the theory of GLSL but I get blank screens most of the time, is this common?
I can’t wrap my head around the idea that there are very very sofisticated shaders when I mostly get blank screens. xD

One thing I have been missing is an updated Pass-Through Vertex shader and updated Pass-Through Fragment shader. I’ve found some older ones but some functionality has been deprecated in newer versions making them obsolete. Some examples in openF 0.7.4 seem to be older too.
The idea behind a Pass-Through is to set them, and know they are running and, for example, make an image pass the vertex shader untouched into the fragment shader for “image processing”. And the same for vertices in the other scenario.

OK, lets begin. I’m taking what you guys have told me and updating it with stuff from here:
http://www.opengl.org/discussion-boards/showthread.php/169708-Tools-IDE-for-authoring-GLSL-shaders
I will comment on the ones I get working with openFrameworks and others that might be useful.
I tried some openF GLSL code from the examples with the ones that provide such functionality, most of the should work but I expect the newer GLSL ones will not.
I made this list because I couldn’t find one that was complete or updated. If you think I am wrong about something just post a comment. :slight_smile:
Hope the list helps others. :smiley:

GLSL Devil
http://wwwvis.informatik.uni-stuttgart.de/glsldevil/
Latest version: 1.1.5 (16 Feb 2010)
For Windows and Linux, no OSX support
Use: Run GLSL Devil and click on Open Program. In the program field put your application executable, Arguments can be left blank and Working Directory can point to the same place where the exe is for openFramework use. Press “OK” and now look for the GL Trace part of the window (lower left), clicking on the green gear will run the program.
This program acts as a standard debugger, it will stop after each Call and wait for your input but you can also skip over to the next Draw Call.
Since it is checking every call it will take a bit of time to reach the next Draw Call, jump a few times until the Shader Source displays the code. This should be the exact same code that you programed. Read the tutorial on their website in order to debug.
Current Status: It will not be updated but the source code is avaiable. Read more here: https://github.com/XenonofArcticus/GLSL-Debugger

NVIDIA FX Composer (FX Composer 2.51 + Shader Debugger 2.51 plug-in (Bundle))
https://developer.nvidia.com/fx-composer
Latest version: 2.51 (XX June 2008)
For Windows. Support for openGL, DirectX 9 and 10, HLSL, CgFX, no GLSL so no openFrameworks!
This is a very nice and complete tool that integrates many great features but cannot be used for debugging GLSL code so it cannot quickly or easily be used with openF. There are some converters from HLSL to GLSL but I haven’t tried them, here is one: https://github.com/aras-p/hlsl2glslfork

RenderMonkey™ Toolsuite
http://developer.amd.com/resources/archive/archived-tools/gpu-tools-archive/rendermonkey-toolsuite/
Latest version: 1.82 (18 Dec 2008)
**For Windows, DirectX® (9.1), OpenGL® (2.0), and OpenGL ES® (2.0) **
This is not exactly a debugger but it is very useful when tickering with shaders. I ported the exact ogl2brick-2.0 shaders from
http://forum.openframeworks.cc/t/ofshader-example—port-from-orange-book-chapter-6-source-included/12310/1
and used this tutorial here:
http://www.david-gouveia.com/rendermonkey-beginners-tutorial/
This tutorial uses HLSL so in order to use it with our GLSL shaders just change any mention of DirectX to openGL and that is about it. Remember to refresh the preview after adding the code for the shaders.
By the way, the integrated examples in RenderMonkey are awesome, I suggest looking at each of them. The “AmbientOcclusion.rfx” example includes two cubemaps and an ambient occlusion map using DDS textures, both can be done in openFrameworks.
Also, most of the examples are very portable and well commented.

TyphoonLabs’ OpenGL Shader Designer
http://www.opengl.org/sdk/tools/ShaderDesigner/
Latest version: 1.5.9.6 ( 1.5.9.4 is from 26 Jan 2006)
For Windows and Linux, no OSX support For Windows download the No Installer version, the installer one seems to requiere NET 1.1 and will crash if you don’t have it.
It is old and I’ve read it is buggy. I found the older ogl2brick in this program and even if it rendered it didn’t even display the code on screen and instead I god a buggy interface.
Here is the old “not going to update this” statement: http://web.archive.org/web/20060424075236/http://www.typhoonlabs.com/
Don’t even waste your time here.

Fragmentarium
http://syntopia.github.io/Fragmentarium/
For Windows, OSX and Linux Uses GLSL.
Latest version: 0.9.12b ( 9 Sept 2012)
This is not much of a debugger but as the website says … “is created specifically with fractals and generative systems in mind.”
This one looks amazing and is much more complex than I thought so I’ll just leave it here. It includes many many historical and newer fractals and stuff I haven’t even heard of.
Quote from the site “If you like Fragmentarium, you might like its sister project, Structure Synth.” so check it out here: http://structuresynth.sourceforge.net/
Also, I had found these ones while browsing: https://www.shadertoy.com/ . If you like shaders and WebGL you might want to see it. :wink:

Shader Maker
http://cgvr.cs.uni-bremen.de/teaching/shader-maker/
For Windows, OSX and Linux Uses GLSL.
Latest version: 1.02 ( 7 May 2012)
This is only a shader editor but I think it is well implemented, it is small and does what it is supposed to do, nothing more. Just load a 3D model, a Frag and a Vert shader and you should see the results. It also has a few Geometry shaders in there and you can download an extra 100 MByte file of 3D models from their site for educational and research purposes only.
Shader Maker also lets you load any mesh model in obj format. :smiley:

Winner! Shader Maker
If I had to work with some of the tools I’ve mentioned I’d have to say that Shader Maker by far. I’d also use Render Monkey although it hasn’t been updated for a while now.
Fragmentarium looks awesome and it may be useful but I have yet to learn how to use it well.

Also, somebody posted a debugging technique in this other thread:
http://www.opengl.org/discussion-boards/showthread.php/169708-Tools-IDE-for-authoring-GLSL-shaders?p=1195484&viewfull=1#post1195484
I will check it out when I get the time but it seems to work.

-Edit 1->
There was also this:
https://kenai.com/projects/netbeans-opengl-pack/pages/Home
It is an openGL pack for netbeans and this is what it offers:

  • OpenGL Shading Language (GLSL 1.4) editor with compiler error annotation, code folding, syntax highlighting, auto completion and documentation.

  • Easy access to the GLSL compiler and linker of your graphics driver integrated in the editor.

1 Like

I found this today, works very nicely and indeed does help a lot and is easier on the eyes.
Before, reading GLSL on a text editor left me like this 0_o! Not anymore! Call now!

Notepad++ GLSL 4.3 Syntax Highlight
http://www.lighthouse3d.com/2013/01/notepad-glsl-4-3-syntax-highlight/

_Notepad++ is a great text editor and I keep using over and over. I found some GLSL syntax highlight UDL files in the site but they were not up to date and most importantly they we’re not prepared to work with dark themes. So I made two UDLs for GLSL 4.3. One for the default theme and another to use with dark themes. The extensions supported are: vert frag geom tesc tese v f g.

The zip file contains both. To install the themes go to “Language”->”Define your language”. In the “User Defined Language” dialog select import to load the files into notepad++._