Jump to content

View more

Image of the Day

Boxes as reward for our ranking mode. ヾ(☆▽☆)
#indiedev #gamedev #gameart #screenshotsaturday https://t.co/ALF1InmM7K
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

[SlimDX] Instanced Triangles

4: Adsense

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   

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


#2 qorthos   Members   

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