Dear people from the forum, I am trying to develop a game prototype which uses OpenGL and I am designing the entire graphic engine. My game requires some tricks with the shaders, and therefore I had to write a very complex geometry shader with lots of ifs and for loops, it increases the complexity of the geometrical models.

I program on a linux OS and I was using an AMD graphic card with the MESA drivers (which have a very limited OpenGL support) but I managed it to work by forcing the driver to use newer versions of the api (by putting this before the command: MESA_GL_VERSION_OVERRIDE=3.3 MESA_GLSL_VERSION_OVERRIDE=330) and the program worked fine. But even then, I had been struggling with the glsl shaders compilation. Sometimes there was nothing wrong with the code, but the compilation would raise an error and it would be fixed by adding a blank line somewhere in the source, by deleting one irrelevant line, multiplying some float by 1., or any ridiculous patch. Doing this would solve it. However, at least I know there is something wrong because the compiler tells me. But sometimes there could be an undefined behavior because some variable is not initialized or something like that, and there is no way of finding out what the problem is, especially if the shader is very complex like mine.

Right now I am using an nVidia graphic card with the proprietary drivers, therefore I don't need to force the driver to support a 'new' version of OpenGL, but the shader does not work. It compiles but it doesn't work, I suspect there could be an undefined behavior but I cannot find it. The code is really complex and I cannot upload it here.

I am wondering why the ridiculous errors mentioned above occur (sometimes they appear when there is a REAL error, which is not detected), and if there is a way to get the warnings or undefined behaviors when the shaders are compiled successfully because the compilations logs are blank. I would not like to rewrite my shader entirely when it works perfectly with other graphic cards. Thank you in advance!

  • \$\begingroup\$ This will he hard for us to diagnose and help you with if we can't see your code and a clear description/example of what the symptoms of "does not work" are in this case. Can you write a small shader that reproduces a similar problem, and share code & output screenshots of that example? Solving the problem in the minimal example often yields leads we can apply to solve the problem in the original complex code. \$\endgroup\$ – DMGregory Sep 9 '19 at 19:11
  • \$\begingroup\$ glGetShaderInfoLog should show the compilation warnings even when compilation is successful. Are you perhaps reusing some boilerplate code that only prints the shader info log if an error occurs? Also, if your shader is very long, with lots of conditionals, is it possible to split it into smaller shaders, perhaps one for each material? Keeping in mind that an object can be run through more than one. For example, your water might go through both a 'ripple' and a 'reflect' shader. \$\endgroup\$ – Fletcher D Sep 10 '19 at 0:46
  • \$\begingroup\$ I cannot really shrink the program to the part where it fails, this is why I find these problems really difficult, they alter all the program's behavior. It is impossible for me to find a logical way to start removing variables or force the program to not execute some parts of the code to deduce what happens, because it won't work as expected. For example: there a conditional to execute block A or B, B is just a function call. If I force to always run B, it draws something, but if I force to run A even with the same function call in the beginning of the block, it doesn't draw anything. \$\endgroup\$ – Agustín Sep 13 '19 at 3:49
  • \$\begingroup\$ I was using someone's code for the error/warnings log, you were right, it only worked when the compilation wasn't successful. But now I set it to always show the log, but it seems to work with some gpu/drivers, showing me a lot of warnings. But this is not the case with my other computer, the log is blank when the compilation succeeded. \$\endgroup\$ – Agustín Sep 13 '19 at 3:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.