Thanks for the hint. That was in fact the problem. I have it loading fine now, however, I have now hit another issue :-).
I get a E_INVALIDARG in the last line of this code:
Effect effect = new Effect(Renderer.RenderDevice, shaderbytecode);
EffectTechnique tech = mat.Effect.GetTechniqueByName("RenderInstanced");
EffectPass pass = tech.GetPassByIndex(0);
InputSignature = pass.Description.Signature;
inputLayout = new InputLayout(Renderer.RenderDevice, InputSignature, DiffuseColorInstancedVertex.GetInputLayout());
The technique looks like this:
technique11 RenderInstanced
{
pass P0
{
SetVertexShader( CompileShader( vs_5_0, DiffInstVertShader() ) );
SetGeometryShader( NULL );
SetPixelShader( CompileShader( ps_5_0, DiffInstPixShader() ) );
SetBlendState( NoBlending, float4( 0.0f, 0.0f, 0.0f, 0.0f ), 0xFFFFFFFF);
SetDepthStencilState( EnableDepthTestWrite, 0 );
}
}
?
?
The vertex shader looks like this:
struct VS_OUTPUT_INST
{
float4 Pos : SV_POSITION;
float3 Normal : NORMAL;
float4 Color : COLOR;
row_major float4x4 mtxTransform : mtxTransform;
float4 Tint : Tint;
};
?
VS_OUTPUT_INST DiffInstVertShader(VS_OUTPUT_INST vsIn)
{
VS_OUTPUT_INST outp = (VS_OUTPUT_INST)0;
[snip]
return outp;
}
The pixelshader:
float4 DiffInstPixShader(VS_OUTPUT_INST inpt) : SV_Target
{
return inpt.Color * inpt.Tint;
}
And the inputlayout for DiffuseColorInstancedVertex is this:
new InputElement("POSITION", 0, Format.R32G32B32A32_Float, 0, 0, InputClassification.PerVertexData, 0),
new InputElement("NORMAL", 0, Format.R32G32B32_Float, 16, 0, InputClassification.PerVertexData, 0),
new InputElement("COLOR", 0, Format.R32G32B32A32_Float, 32, 0, InputClassification.PerVertexData, 0),
new InputElement("mtxTransform",0,Format.R32G32B32A32_Float,0,1,InputClassification.PerInstanceData,1),
new InputElement("mtxTransform",1,Format.R32G32B32A32_Float,16,1,InputClassification.PerInstanceData,1),
new InputElement("mtxTransform",2,Format.R32G32B32A32_Float,32,1,InputClassification.PerInstanceData,1),
new InputElement("mtxTransform",3,Format.R32G32B32A32_Float,48,1,InputClassification.PerInstanceData,1),
new InputElement("Tint", 0, Format.R32G32B32A32_Float, 64, 1, InputClassification.PerInstanceData, 1),
And the struct is defined like this:
[StructLayout(LayoutKind.Sequential)]
public struct DiffuseColorInstancedVertex
{
private Vector4 position;
private Vector3 normal;
private readonly float reserved2;
private Vector4 color;
private Matrix transform;
private Vector4 tint;
....
}
Not sure what is going on here, the error message is not very helpful.
Thanks for any pointers.
- Lutz