So i recently decided to convert my XNA project to monogame but i am having problems with my content pipeline:
I used my pipeline to assign a specific loaded effect to the models and apply the texture, however I get an error when trying to load the content in-game.
I tried to isolate the case as much as possible but i might just be missing something:
-i switched to the default instancing shader since it is a shader error.
-i changed the fbx file version to an older type.
-i made a new game in wich i only load the model, no special stuff going on:
Model n2x2x3 = this.Content.Load(“N2x2x3”);
(this is the only line of importance)
but i still get the error:
HRESULT: [0x80070057], Module: [General], ApiCode: [E_INVALIDARG/Invalid Arguments], Message: The parameter is incorrect.
With stacktrace:
at SharpDX.Result.CheckError()
at SharpDX.Direct3D11.Device.CreatePixelShader(IntPtr shaderBytecodeRef, PointerSize bytecodeLength, ClassLinkage classLinkageRef, PixelShader pixelShaderOut)
at SharpDX.Direct3D11.PixelShader…ctor(Device device, Byte shaderBytecode, ClassLinkage linkage)
at Microsoft.Xna.Framework.Graphics.Shader.CreatePixelShader()
at Microsoft.Xna.Framework.Graphics.Shader.PlatformConstruct(Boolean isVertexShader, Byte shaderBytecode)
at Microsoft.Xna.Framework.Graphics.Shader…ctor(GraphicsDevice device, BinaryReader reader)
at Microsoft.Xna.Framework.Graphics.Effect.ReadEffect(BinaryReader reader)
at Microsoft.Xna.Framework.Graphics.Effect…ctor(GraphicsDevice graphicsDevice, Byte effectCode, Int32 index, Int32 count)
at Microsoft.Xna.Framework.Content.EffectReader.Read(ContentReader input, Effect existingInstance)
at Microsoft.Xna.Framework.Content.ContentTypeReader1.Read(ContentReader input, Object existingInstance) at Microsoft.Xna.Framework.Content.ContentReader.InnerReadObject[T](T existingInstance) at Microsoft.Xna.Framework.Content.ContentReader.ReadObject[T]() at Microsoft.Xna.Framework.Content.ContentReader.ReadAsset[T]() at Microsoft.Xna.Framework.Content.ContentManager.ReadAsset[T](String assetName, Action
1 recordDisposableObject)
at Microsoft.Xna.Framework.Content.ContentManager.Load[T](String assetName)
at Microsoft.Xna.Framework.Content.ContentReader.ReadExternalReferenceT
at Microsoft.Xna.Framework.Content.EffectMaterialReader.Read(ContentReader input, EffectMaterial existingInstance)
at Microsoft.Xna.Framework.Content.ContentTypeReader1.Read(ContentReader input, Object existingInstance) at Microsoft.Xna.Framework.Content.ContentReader.InnerReadObject[T](T existingInstance) at Microsoft.Xna.Framework.Content.ContentReader.ReadSharedResources() at Microsoft.Xna.Framework.Content.ContentReader.ReadAsset[T]() at Microsoft.Xna.Framework.Content.ContentManager.ReadAsset[T](String assetName, Action
1 recordDisposableObject)
at Microsoft.Xna.Framework.Content.ContentManager.Load[T](String assetName)
at Game1.Game1.LoadContent() in D:\Mercurial\World Of Bricks\testprojects\Creator\Monogame\Game1\Game1.cs:line 44
at Microsoft.Xna.Framework.Game.Initialize()
at Game1.Game1.Initialize() in D:\Mercurial\World Of Bricks\testprojects\Creator\Monogame\Game1\Game1.cs:line 31
at Microsoft.Xna.Framework.Game.DoInitialize()
at Microsoft.Xna.Framework.Game.Run(GameRunBehavior runBehavior)
at Microsoft.Xna.Framework.Game.Run()
at Game1.Program.Main() in D:\Mercurial\World Of Bricks\testprojects\Creator\Monogame\Game1\Program.cs:line 18
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
The default instancing shader:
// MonoGame - Copyright (C) The MonoGame Team
// This file is subject to the terms and conditions defined in
// file ‘LICENSE.txt’, which is part of this source code package.
float4x4 View;
float4x4 Projection;
struct VSInput
{
float4 Position : POSITION0;
float2 TexCoord : TEXCOORD0;
};
struct VSOutput
{
float2 TexCoord : TEXCOORD0;
float4 Position : SV_Position;
};
struct PSInput
{
float2 TexCoord : TEXCOORD0;
};
VSOutput VS(VSInput input, float4x4 worldTransposed : BLENDWEIGHT)
{
VSOutput output = (VSOutput)0;
float4x4 world = transpose(worldTransposed);
float4 positionWorld = mul(input.Position, world);
float4 positionView = mul(positionWorld, View);
output.Position = mul(positionView, Projection);
output.TexCoord = input.TexCoord;
return output;
}
float4 PS(PSInput input) : COLOR0
{
return float4(input.TexCoord.xy, 0, 1);
}
#if SM4
#define PS_PROFILE ps_4_0
#define VS_PROFILE vs_4_0
#else
#define PS_PROFILE ps_3_0
#define VS_PROFILE vs_3_0
#endif
technique
{
pass
{
VertexShader = compile VS_PROFILE VS();
PixelShader = compile PS_PROFILE PS();
}
}
My content pipeline:
[ContentProcessor(DisplayName = “Instanced Model”)]
public class InstancedModelProcessor : ModelProcessor
{
ContentIdentity rootIdentity;
public override ModelContent Process(NodeContent input, ContentProcessorContext context)
{
rootIdentity = input.Identity;
return base.Process(input, context);
}
protected override MaterialContent ConvertMaterial(MaterialContent material,ContentProcessorContext context)
{
// Create a new material.
EffectMaterialContent newMaterial = new EffectMaterialContent();
// Tell it to use our custom shader.
newMaterial.Effect = new ExternalReference(“Instancing.fx”,rootIdentity);
// Copy the texture setting across from the original material.
BasicMaterialContent basicMaterial = material as BasicMaterialContent;
if ((basicMaterial != null) && (basicMaterial.Texture != null))
{
newMaterial.Textures.Add(“Texture”, basicMaterial.Texture);
}
// Chain to the base ModelProcessor, so it can build our new material.
return base.ConvertMaterial(newMaterial, context);
}
}
(Sorry for the bad formatting, i couldn’t finde the “code” tag)
Just to be clear EVERYTHING i did (pipeline, my custom shader, fbx importing ect) works on xna.
I am really getting desparate here i have been searching for this for over a week and i really need this to work since i planned on releasing my game this week. (If it had not been that i found an unmanaged memory leak in xna, i didn’t have to switch to monogame in such short notice)