Jump to content

  • Log In with Google      Sign In   
  • Create Account

#Actualqorthos

Posted 30 January 2013 - 07:36 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.


#1qorthos

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

 

 


PARTNERS