Ivorforce/Psychedelicraft

GL Error

XBlackLeopardX opened this issue · 5 comments

When running this mod (latest version of psychedelicraft, botania, and forge) with botania it seems to spam my console with a GL Error here is the log
https://gist.github.com/XBlackLeopardX/07c2ecc5e0a824e15c0d

Hmmm.... There is no indication of this being Psychedelicraft's fault, but of course I can't just dismiss it.
I take it it doesn't happen if Psychedelicraft is not installed, and neither does it happen if Botania is not installed?

In that case, I'd wager it's a shader issue. Does it still spam the error when you disable shaders in the config?
Lastly, do you notice anything different, visually?

Correct remove botania and I don't get the error or remove Psychedelicraft and I don't get the error

With shaders disabled the error doesn't appear at all in the console

Also I havn't noticed anything visually off it all looks like it should

Interesting... I highly suspect Botania is calling some OGL methods that depend on no shader being set up. I might investigate this myself in the future, but it might help to report this to the Botania author, too - especially with the information about what version the errors started occuring in. They probably have better chances of figuring out exactly what OGL calls cause this issue than I do.

The class I use for shaders is here https://github.com/Vazkii/Botania/blob/master/src/main/java/vazkii/botania/client/core/helper/ShaderHelper.java
Perhaps you ought to have a look at it, you seem much more experient on this than I am, I don't have that much experience regarding shader code so there might be some bad practices in there.

@Vazkii
Alright, I'm noticing a few things here. Good on you for trying to improve the code, I don't see that a lot! :D

Firstly, OpenGLHelper wraps a lot of GL calls these days. Not only do they improve compatibility between mods, and towards more graphics cards, but they also ensure code sanity internally.
My example of a fully wrapped shader looks like this:
https://github.com/Ivorforce/IvToolkit/blob/2a03617dd4a1a05e2e4340239f3ef73d7f9a3d11/src/main/java/ivorius/ivtoolkit/rendering/IvShaderInstance.java
It's Apache 2.0, so if you want to use it, go ahead and copy it - with proper attribution, of course. This would make the whole process a bit easier and a lot stabler. :)

That aside, there are inherent problems involved with two mods running shaders at once. After looking at your code a bit more, I'm willing to bet the gl errors are thrown by me trying to set uniforms when the shader is not bound.
It's possible to solve this, albeit with noticeable visual artifacts surrounding all your renderings utilizing shaders, to manually make the processes compatible, by simply re-binding the currently used shader after yours is done (making a shader stack, so to say). That would require you calling my classes though, or any other shader mod's for that matter, and that's not so fun.
This whole thing is basically the reason I discourage using shaders for random objects in the first place - it makes you incompatible to a lot of other mods doing the same. Also it won't work in 1.8+ either way, with Mojang wrapping everything with their own shaders :P

To improve your future debugging capabilities, I highly recommend you get your own logger (logger = fmlPreInitializationEvent.getModLog();) and log to that, rather than using the FMLLog. It should always be clear what mod is logging what, especially to the end user.
If you're going as deep as shaders, you should also definitely consider logging glErrors yourself. I do it post every render pass, which is why this is logged by Psychedelicraft rather than vanilla in the first place. The code looks like this: https://github.com/Ivorforce/IvToolkit/blob/2a03617dd4a1a05e2e4340239f3ef73d7f9a3d11/src/main/java/ivorius/ivtoolkit/rendering/IvOpenGLHelper.java#L82-93
Shouldn't call it too often, but certainly after big operations.

Btw., this is unrelated, but you can basically replace your big readFileAsString with a simple
String myString = IOUtils.toString(ShaderHelper.class.getResourceAsStream(filename), "UTF-8");
Just saying :P

@XBlackLeopardX Basically what this means is that Vazkii's shaders cancel out mine, and you'd notice the difference when hallucinating on drugs (aka activating my shader's capabilities).
This is an inherent incompatibility, and I'm afraid you'll have to disable either Psychedelicraft's or Botania's shaders.