Jump to content

  • Log In with Google      Sign In   
  • Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

Sign up from the right-hand sidebar on our homepage and read Tuesday's newsletter for details!


[SlimDX] Instanced Triangles


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 qorthos   Members   -  Reputation: 165

Like
0Likes
Like

Posted 30 January 2013 - 07:35 PM

Hi everyone, I'm back!  This time I have an equally simple problem as my previous problem.  I've got constant buffers, indexbuffers and view/projection matrices worked out (who woulda though I'd need to transpose the matrices!).  Now I'm having a spot of bother trying to instance my triangle.

 

 

I'm trying to set up the InputElement array and the InputLayout and getting a gibberish error message (I'm using visual studio express and can't see the native code exceptions and DebugView tells me nothing) 

 

Here's my shader code:

cbuffer OncePerDraw : register(cb0)
{
	float4		color;
	float4x4	world;	
}

cbuffer OncePerFrame : register(cb1)
{
	float4x4	view;
	float4x4	projection;	
}


struct VS_INPUT
{
	float4 Position : POSITION;
	float3 Offset	: TEXCOORD0;
};

struct VS_OUTPUT
{
	float4 Position : SV_POSITION;
	float4 Color	: COLOR0;
};


VS_OUTPUT VShader(VS_INPUT input)
{
	VS_OUTPUT output = (VS_OUTPUT)0;
	
	float4 worldPosition = mul(input.Position, world);
	worldPosition += float4(input.Offset, 0);
    float4 viewPosition = mul(worldPosition, view);
    output.Position = mul(viewPosition, projection);
		
	output.Color = color;
	//output.Color = float4(1, 1, 1, 1);

	return output;
}

float4 PShader(VS_OUTPUT input) : SV_Target
{
	float4 color = input.Color;
	return color;
}

 

 

 

And a snippet of trying to set up the InputElement array:

            using (var bytecode = ShaderBytecode.CompileFromFile("colored.fx", "VShader", "vs_4_0", ShaderFlags.None, EffectFlags.None))
            {
                isColored = ShaderSignature.GetInputSignature(bytecode);
                vsColored = new VertexShader(device, bytecode);
            }

            primitiveElements = new[] 
            { 
                new InputElement("POSITION", 0, Format.R32G32B32_Float, 0),
                new InputElement("TEXCOORD", 0, Format.R32G32B32_Float, 0, 0, InputClassification.PerInstanceData, 1)
            };          
                        
            ilPrimitiveColored = new InputLayout(device, isColored, primitiveElements);

 

 

The error is thrown on the line that creates the InputLayout.  I'm a bit baffled, as changing the InputClassification of the TEXCOORD0 semantic to PerVertexData and the stepRate to 0 solves the problem.


Edited by qorthos, 30 January 2013 - 07:36 PM.


Sponsor:

#2 qorthos   Members   -  Reputation: 165

Like
0Likes
Like

Posted 30 January 2013 - 10:54 PM

Oh, ffs, I figured it out.  Ugh.






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS