Jump to content
  • Advertisement
Sign in to follow this  

[SlimDX] Instanced Triangles

This topic is 2088 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!