Sign in to follow this  

[SlimDX] Instanced Triangles

Recommended Posts

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 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

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this