MonoGame on linux not loading effect assets

EDIT: The problem is now resolved, I will include detailed information here to help someone else who is facing this, as it is not so easy to solve.

Basically, it comes down to updating using the development branch.

The first step is to check the monogame development branch, this will not include the thirdparty / libs submodule, so you also need to update it to be able to compile the sources.

After that, you can compile MonoGame.Framework.Linux.sln and update the links in your project to point to the new dll files.

It still won’t load effect files if they weren’t created using an updated version of the content processors, so you need to go to a Windows computer, check the development branch (and libs) - or copy them from your Linux system - then compile MonoGame. ContentPipeline / ContentProcessors / MonoGameContentProcessors.sln

You need to update the link to MonoGameContentProcessors.dll in your content project, you also need to rename the file MonoGame.ContentPipeline \ ContentProcessors \ bin \ Release \ libmojoshader_32.dll to just libmojoshader.dll.

Once all this is done, you can finally use it for its intended purpose - create .xnb files from your .fx files and add them to your linux project.

Hope this information is helpful to someone.

================================================== Original message:

I just started with MonoGame, and am trying to get a very simple application (spinning cube) to work on Windows and Linux. Windows is not a problem, but I am having problems getting .fx files to work on Linux.

I created the "MonoGame Content Project", added the .fx file to it, selected the "MonoGame Effect" processor, set the build configuration on Linux - it all works, and I get the .xnb file in the output directory.

When I set up the Linux project, I copied the .xnb file to the "Content" folder (the root directory is set accordingly) and used the following code to load the effect (the same code as on Windows):

CubeEffect = Content.Load<Effect>("Effect1"); CubeEffect.CurrentTechnique = CubeEffect.Techniques["Technique1"]; 

This causes the application to crash with this error:

 Microsoft.Xna.Framework.Content.ContentLoadException: Could not load Effect1 asset! 

Initially, I assumed that this was a problem with file names, directory names, or incorrect configuration. However, I tried to add the .png file to the content folder and upload it:

 Texture2D Tex = Content.Load<Texture2D>("bg.png"); 

This works fine (checks the Texture2D properties in the debugger and has the correct data for the file).

Am I missing a step when converting a shader file? Is there some really obvious thing that I don't see?

If not, can someone understand why he will act in this way or somehow get a more detailed error from him, as the actual reason that he will not be able to download the asset?

EDIT: by looking at the disassembly point where it really throws an error, it seems that it finds the file but does not recognize it as a valid resource type - could this be a problem for version / compatibility

+4
source share
1 answer

This is a very common problem when trying to load shaders into Monogame. I tried and could not load my custom shader into the Monogame framework.

You need to compile from the develop3d branch, not the official version. You also need to convert your HLSL shader into syntax compatible with MojoShader. Then you need to either load the effect from the Monogame content importer (which you need to configure manually) or add a shader as an embedded resource and load it into your project in order to use it.

I could never really escape from this. From my testimony on the Internet, this part of the Monogame structure is not yet ready for prime time.

Here is some information about this. They really did not provide much information about this, as I suspect they know this is very problematic:

https://github.com/mono/MonoGame/wiki/Effects-And-Shaders

+2
source

Source: https://habr.com/ru/post/1485814/


All Articles