GLSL shaders

Can you check what the parameters to the GL call that fails are? We should be able to figure out what enum value is wrong and what it should be.
I hope I can help a bit, but I’ve never done MRT and I can’t test iOS because I don’t have a Mac :confused:

Yeah sure, below is a screen. Note the params to GL in the watch window:

From glFramebufferTexture2D

GL_INVALID_ENUM is generated if attachment is not an accepted attachment point.

That seems to be the only thing that could be causing the crash. The value of the attachment when the crash happens is GL_COLOR_ATTACHMENT1 which should be valid. I don’t know what ‘an accepted attachment point’ means exactly…

This certainly will help JJagg and sent me in a direction now. Thank you for this and also prompt reply. I’m taking a look at this now and trying to dig in a little further.

UPDATE: I think I figured this out now, and might just be running into something not supported in GLES 2.0. I don’t think this will be possible with GLES 2.0 actually, maybe 3.0 but from what I can see this might not be possible with the way I have had my existing shaders defined.

Java and C# are relatively different in comparison.

Just wanted to point out that java is very similar to c# more so then c++.
If you know c# you practically already have learned java.

I was using java before c# came out then jumped ship c# provides more flexability pinvokes unsafe ect.
Some basic things are different like the way base and super work in java vs base in c# and a few other minor things. However code java is extremely similar to c#.

You could easily get a program running in no time at all in java and feel like your in very familiar territory, if you already know c#.

1 Like

Hi,

I was also looking to implement GLSL shaders in monogame as the default shader language rather than HLSL, just for the sake of portability, but I can see this is not available.

I’ve read somewhere that the current transpiler HLSL->GLSL used in the content pipeline may not work well when GLSL is missing features from HLSL.

Can someone with good knowedge/experience provide an insight of the current state of the art?
What are the long term plans?

Thanks :slight_smile:

Not much development here lately, so the steps you need to take are still the same as explained in this thread. Recommended steps:

  1. Fork MonoGame and clone your fork in case you haven’t yet.
  2. Add my fork as a remote: git remote add jjagg https://github.com/Jjagg/MonoGame.git
  3. Fetch the GLFX branch. git fetch jjagg glfx
  4. Check it out git checkout glfx
  5. Run Protobuild and enable the GLFX service: [mono] Protobuild.exe -enable GLFX.
  6. Build your shaders with the GLFX target. Check out the SpriteEffect shader in my PR for the syntax (PR. Only old GLSL syntax works for now due to parsing difficulties.
  7. Run your game as usual. There are some errors in my branch, check out comments in the PR for some fixes.

You’re welcome to open PR’s on my branch if you want to contribute. It might get merged soon so you can send PRs to the MG repo directly. Feel free to ask me anything if you run into issues or want to help out.

It generally works pretty well. So if you’re just doing this for portability, I don’t recommend digging into the direct GLSL stuff :stuck_out_tongue: The GLFX branch was pretty quickly implemented and there are probably more issues with it than the automatic translation.

While it would be nice to support GLSL directly (or some dialect to make it fit better into MonoGame), this is a pretty low priority issue. Some better tooling might help speed up the process of supporting GLSL (like the vulkan stuff) because optimization is currently the most difficult thing in supporting GLSL shaders.

Update on the Multiple Render Target on iOS with the glsl issue I had above:

Revisiting this turns out its due to the Graphics Context being constructed for GLES2.0

I changed this number above {in red} to 3 [GLES 3.0] and Multiple render Targets appear to function now as well with glsl compiled shaders for iOS {iPhone /iPad}.

thanks

1 Like

Hi,

I’m trying to compile and run the 2mgfx program with the GLFX target. I’ve followed the instructions, but when I run the 2MGFX with a shader to compile, I get the following error:

Unable to find an entry point named ‘glslopt_initialize’ in DLL ‘glsl_optimizer.dll’.
Unexpected error compiling ‘o:test.fx’!

any ideas why this is happening? Is there a precompiled windows binary anywhere?

Just in case, MD5 is glsl_optimizer.dll 2cfe83111201dbe25856519113b93252

Thanks!

I don’t remember if I actually tested this on Windows :confused: Maybe there are issues with the native dll. I don’t have time to look at this atm. If you want to try to build it yourself, you can check out the MG fork of glsl-optimizer. It has some changes so it supports PInvoke, maybe the windows binary was compiled without these changes. Repo is at https://github.com/MonoGame/glsl-optimizer

thanks for the answer.

I found that https://github.com/infinitespace-studios/GLSLOptimizerSharp actually contains a working binary dll in the repo.

1 Like