As a preface, the same code works fine in XNA, but Monogame throws an exception. To do this, you probably need someone who is familiar with the Monogame rendering pipeline.
In the "Draw" section of my game, there is a ShadowmapResolver that displays a texture that is the final calculated light pattern from the given light. It gets an exception when rendering from the fact that EffectPass.Apply() is EffectPass.Apply() complaining that somewhere inside Mono theres an attempt is made from int32[] to Single[] . Here is my code that calls it:
private void ExecuteTechnique(Texture2D source, RenderTarget2D destination, string techniqueName, Texture2D shadowMap) { graphicsDevice.SetRenderTarget(destination); graphicsDevice.Clear(Color.Transparent); resolveShadowsEffect.Parameters["renderTargetSizeX"].SetValue((float)baseSizeX); resolveShadowsEffect.Parameters["renderTargetSizeY"].SetValue((float)baseSizeY); if (source != null) resolveShadowsEffect.Parameters["InputTexture"].SetValue(source); if (shadowMap != null) resolveShadowsEffect.Parameters["ShadowMapTexture"].SetValue(shadowMap); resolveShadowsEffect.CurrentTechnique = resolveShadowsEffect .Techniques[techniqueName]; try { foreach (EffectPass pass in resolveShadowsEffect.CurrentTechnique.Passes) { pass.Apply();
And here is the stacktrace:
at Microsoft.Xna.Framework.Graphics.ConstantBuffer.SetData(Int32 offset, Int32 rows, Int32 columns, Object data) at Microsoft.Xna.Framework.Graphics.ConstantBuffer.SetParameter(Int32 offset, EffectParameter param) at Microsoft.Xna.Framework.Graphics.ConstantBuffer.Update(EffectParameterCollection parameters) at Microsoft.Xna.Framework.Graphics.EffectPass.Apply() at JASG.ShadowmapResolver.ExecuteTechnique(Texture2D source, RenderTarget2D destination, String techniqueName, Texture2D shadowMap) in C:\Users\[snip]\dropbox\Projects\JASG2\JASG\JASG\Rendering\ShadowmapResolver.cs:line 253
So, it seems that one of the parameters of my shader, which I am trying to set, somehow confuses the monogame, but I do not understand what it can be. I click float, not int arrays. I even tried changing RenderTarget2D.SurfaceFormat from Color to Single for all my goals and textures, still giving the same error.
Outside of the function that I gave, in a wider range there are no other parameters that are set with another EffectPass.Apply . There are several other effects that render without error before.
In case this helps, here is the source for the MonoGame Framework regarding ConstantBuffer.SetData()
private void SetData(int offset, int rows, int columns, object data) {
Is this some kind of marshaling problem? Thank you for your time!
Edit: PS: The exception is an InvalidCastException , not a NotImplementedException .