Problem with HLSL Shaders in Monogame V 3.2

Hello,

i’m realativ new to HLSL and got some problems with it.

I’m trying to use a simple shader on a single sprite. The shader i use looks like:

sampler s0; 

float4 PixelShaderFunction(float4 position : SV_Position, float4 color : COLOR0, float2 coords : TEXCOORD0) : COLOR
{
	color = tex2D(s0, coords);
	color.rgb = color.gbr;   
	return color;  
}
  
technique SimpleEffect  
{  
    pass Pass1  
    {  
        PixelShader = compile ps_3_0 PixelShaderFunction();  
    }  
} 

if i use the shader in an single spritebatch.begin() spritebatch.end() draw call everything works fine, but if i try to make a second call all pictures turn red.

without the shader all looks fine

The following code is used to draw the shader and the additional two Images:

GraphicsDevice.Clear(Color.CornflowerBlue);
spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend);
SimpleEffect.CurrentTechnique.Passes[0].Apply();
spriteBatch.Draw(TestImage, new Rectangle(0, 0, (int)(GraphicsDevice.PresentationParameters.BackBufferWidth / 1.33f), GraphicsDevice.PresentationParameters.BackBufferHeight), Color.White);
    
spriteBatch.End();
    
spriteBatch.Begin();
spriteBatch.Draw(TestImage, new Rectangle(0, 0, (int)(GraphicsDevice.PresentationParameters.BackBufferWidth / 2), GraphicsDevice.PresentationParameters.BackBufferHeight), Color.Green);
spriteBatch.End();
    
spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend);
spriteBatch.Draw(TestImage, new Rectangle(0, 0, (int)(GraphicsDevice.PresentationParameters.BackBufferWidth / 4), GraphicsDevice.PresentationParameters.BackBufferHeight), Color.Yellow);
spriteBatch.End();

Can’t say for sure what is going wrong there, but it seems like a bug.

First recommendation would be trying the latest development build from the download area. A lot has changed since 3.2 and this possible bug might already be fixed.

1 Like

Seems like the Content Pipeline missing a DLL file. The project is using the OpenGL backend…

Content Importer: Effect - XNA Framework
Content processor: MonoGame Effect.

I installed the last development buildversion for Windows. Trying to rebuild the content pipline or start debuging the entire project leads to the following error:

Fehler    2    Building content threw DllNotFoundException: Die DLL "libmojoshader_64.dll": Das angegebene Modul wurde nicht gefunden. (Ausnahme von HRESULT: 0x8007007E) kann nicht geladen werden.
   bei TwoMGFX.MojoShader.NativeMethods.MOJOSHADER_parse(String profile, Byte[] tokenbuf, Int32 bufsize, IntPtr swiz, Int32 swizcount, IntPtr smap, Int32 smapcount, IntPtr m, IntPtr f, IntPtr d)
   bei TwoMGFX.ShaderData.CreateGLSL(Byte[] byteCode, Boolean isVertexShader, List`1 cbuffers, Int32 sharedIndex, Dictionary`2 samplerStates, Boolean debug)
   bei TwoMGFX.EffectObject.CreateShader(ShaderInfo shaderInfo, String shaderFunction, String shaderProfile, Boolean isVertexShader, String& errorsAndWarnings)
   bei TwoMGFX.EffectObject.CompileEffect(ShaderInfo shaderInfo, String& errorsAndWarnings)
   bei MonoGameContentProcessors.Processors.MGEffectProcessor.Process(EffectContent input, ContentProcessorContext context)
   bei Microsoft.Xna.Framework.Content.Pipeline.ContentProcessor`2.Microsoft.Xna.Framework.Content.Pipeline.IContentProcessor.Process(Object input, ContentProcessorContext context)
   bei Microsoft.Xna.Framework.Content.Pipeline.BuildCoordinator.BuildAssetWorker(BuildItem item)
   bei Microsoft.Xna.Framework.Content.Pipeline.BuildCoordinator.BuildAsset(BuildItem item)
   bei Microsoft.Xna.Framework.Content.Pipeline.BuildCoordinator.RunTheBuild()
   bei Microsoft.Xna.Framework.Content.Pipeline.Tasks.BuildContent.RemoteProxy.RunTheBuild(BuildCoordinatorSettings settings, TimestampCache timestampCache, ITaskItem[] sourceAssets, String[]& outputContent, String[]& rebuiltContent, String[]& intermediates, Dictionary`2& dependencyTimestamps, KeyValuePair`2[]& warnings)    c:\users\simon\documents\visual studio 2010\Projects\Pipeline\PipelineContent\Simple.fx

If i delete the shader everthing works fine.

Using Effect - XNA Framework as Content Processor compiles the .fx file.

The file (libmojoshader_64.dll) exists in the following path: C:\Program Files (x86)\MSBuild\MonoGame\v3.0\Tools

I see… you are using the older MonoGame processors for the XNA content pipeline.

We’re not improving the old processors anymore, but I had thought I had fixed it to work after the latest changes to content processing.

If you copy the DLL out to C:\Program Files (x86)\MSBuild\MonoGame\v3.0 does it work?

I will try this on monday as soon as possible.

What is the new content processor? I was using this tutorial to setup my content pipeline

http://rbwhitaker.wikidot.com/monogame-managing-content

i will replay after testing this out thanks for your help.