HLSL Vertex Shader gets wrong input
<p>I am currently working on an project but my problem is that my Vertex shader gets the wrong data, so my position values aren't any longer the same as i set them at the beginning. </p>

<p>So this is where I define the position/anchor of my Sprite</p>

<pre><code>struct SpriteVertex
{
    DirectX::XMFLOAT3 position;     
    float radius;                  
    int textureIndex;         
};

    //Sprite renderer 
    vector&lt;SpriteVertex&gt; sprite_vertices;
    SpriteVertex current;
    current.position.x = 0;
    current.position.y = 0;
    current.position.z = 0;
    current.radius = 100;
    current.textureIndex = 0;
    sprite_vertices.push_back(current);



    g_SpriteRenderer-&gt;renderSprites(pd3dImmediateContext, sprite_vertices, g_camera);
</code></pre>

<p>So in my SpriteRenderer Class I have the create method where I set up the Input layout and create an empty vertex buffer.</p>

<pre><code>HRESULT SpriteRenderer::create(ID3D11Device* pDevice)
{
    cout &lt;&lt; "Spriterender Create has been called" &lt;&lt; endl;

    HRESULT hr;


    D3D11_BUFFER_DESC bd;
    ZeroMemory(&amp;bd, sizeof(bd));
    bd.Usage = D3D11_USAGE_DEFAULT;
    bd.ByteWidth = 1024 * sizeof(SpriteVertex);
    bd.BindFlags = D3D11_BIND_SHADER_RESOURCE;
    bd.CPUAccessFlags = 0;
    bd.MiscFlags = 0;

    V(pDevice-&gt;CreateBuffer(&amp;bd , nullptr, &amp;m_pVertexBuffer));

    const D3D11_INPUT_ELEMENT_DESC layout[] ={
    { "POSITION",    0, DXGI_FORMAT_R32G32B32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 },
    { "RADIUS",    0, DXGI_FORMAT_R32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 },
    { "TEXTUREINDEX",0,DXGI_FORMAT_R32_SINT,0,D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }
    };

    UINT numEements = sizeof(layout) / sizeof(layout[0]);

    D3DX11_PASS_DESC pd;
    V_RETURN(m_pEffect-&gt;GetTechniqueByName("Render")-&gt;GetPassByName("SpritePass")-&gt;GetDesc(&amp;pd));

    V_RETURN(pDevice-&gt;CreateInputLayout(layout, numEements, pd.pIAInputSignature, pd.IAInputSignatureSize, &amp;m_pInputLayout));


    return S_OK;
}
</code></pre>

<p>And I have the render method which fills the buffer and is supposed to render it with the shader I coded:</p>

<pre><code>void SpriteRenderer::renderSprites(ID3D11DeviceContext* context, const std::vector&lt;SpriteVertex&gt;&amp; sprites, const CFirstPersonCamera&amp; camera)
{
//cout &lt;&lt; "SpriterenderrenderSprites has been called" &lt;&lt; endl;

D3D11_BOX box;
box.left = 0; box.right = sprites.size()*sizeof(SpriteVertex);
box.top = 0; box.bottom = 1;
box.front = 0; box.back = 1;

context-&gt;UpdateSubresource(m_pVertexBuffer,0,&amp;box,&amp;sprites[0],0,0);

const UINT size = sizeof(SpriteVertex);

context-&gt;IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_POINTLIST);
context-&gt;IASetInputLayout(m_pInputLayout);
context-&gt;IASetVertexBuffers(0, 0, &amp;m_pVertexBuffer, &amp;size, nullptr);

//setting shader resouirces
DirectX::XMMATRIX worldviewProj =camera.GetViewMatrix()*camera.GetProjMatrix();
m_pEffect-&gt;GetVariableByName("g_ViewProjection")-&gt;AsMatrix()-&gt;SetMatrix(( float* ) &amp;worldviewProj);
m_pEffect-&gt;GetVariableByName("g_cameraRight")-&gt;AsVector()-&gt;SetFloatVector((float*) &amp;camera.GetWorldRight());
m_pEffect-&gt;GetVariableByName("g_cameraUP")-&gt;AsVector()-&gt;SetFloatVector((float*)&amp;camera.GetWorldUp());

m_pEffect-&gt;GetTechniqueByName("Render")-&gt;GetPassByName("SpritePass")-&gt;Apply( 0,context);
context-&gt;Draw(size,0);  
</code></pre>

<p>}</p>

<p>So my big problem is that when I debug the Shaders that my inital Position radius and so on aren't even close to what I want: </p>

<p><a href="http://i.stack.imgur.com/p7xLw.jpg" rel="nofollow">Debug VS </a></p>

<p>I'm trying to fix this now for ever any help would be really appreciated.</p>

<p>EDIT: HLSL Code might help ;=)</p>

<pre><code>    //--------------------------------------------------------------------------------------
// Shader resources
//--------------------------------------------------------------------------------------



//--------------------------------------------------------------------------------------
// Constant buffers
//--------------------------------------------------------------------------------------
cbuffer cbCOnstant
{
    matrix g_ViewProjection;
    float4 g_cameraRight;
    float4 g_cameraUP;
};


//--------------------------------------------------------------------------------------
// Structs
//--------------------------------------------------------------------------------------
struct SpriteVertex
{  
    float3 POSITION : POSITION;
    float RADIUS: RADIUS;
    int TEXIN : TEXTUREINDEX;
};

struct PSVertex
{
    float4 POSITION : SV_Position;
    int TEXIN : TEXTUREINDEX;
};

//--------------------------------------------------------------------------------------
// Rasterizer states
//--------------------------------------------------------------------------------------
RasterizerState rsCullNone 
{
    CullMode = None;
};

//--------------------------------------------------------------------------------------
// DepthStates
//--------------------------------------------------------------------------------------
DepthStencilState EnableDepth
{
    DepthEnable = TRUE;
    DepthWriteMask = ALL;
    DepthFunc = LESS_EQUAL;
};
BlendState NoBlending
{
    AlphaToCoverageEnable = FALSE;
    BlendEnable[0] = FALSE;
};


//--------------------------------------------------------------------------------------
// Shaders
//--------------------------------------------------------------------------------------
SpriteVertex DummyVS(SpriteVertex Input)
{    
    return Input;
}

[maxvertexcount(4)]
void SpriteGS(point SpriteVertex vertex[1], inout TriangleStream&lt;PSVertex&gt; stream){

    PSVertex input;
    input.TEXIN = vertex[0].TEXIN; 


    //bottom left   
    input.POSITION = mul(float4(vertex[0].POSITION,1) - vertex[0].RADIUS * g_cameraRight - vertex[0].RADIUS * g_cameraUP, g_ViewProjection);
    stream.Append(input);

    //top left

    input.POSITION = mul(float4(vertex[0].POSITION,1) - vertex[0].RADIUS * g_cameraRight + vertex[0].RADIUS * g_cameraUP, g_ViewProjection);
    stream.Append(input);

    //top right
   input.POSITION = mul(float4(vertex[0].POSITION,1) + vertex[0].RADIUS * g_cameraRight + vertex[0].RADIUS * g_cameraUP, g_ViewProjection);
    stream.Append(input);  

         //bot right

    input.POSITION = mul(float4(vertex[0].POSITION,1) + vertex[0].RADIUS * g_cameraRight - vertex[0].RADIUS * g_cameraUP, g_ViewProjection);
    stream.Append(input);

}



float4 DummyPS(PSVertex input) : SV_Target0
{
 return float4(1, 1, 0, 1);
}

//--------------------------------------------------------------------------------------
// Techniques
//--------------------------------------------------------------------------------------
technique11 Render
{
    pass SpritePass
    {
        SetVertexShader(CompileShader(vs_5_0, DummyVS()));
        SetGeometryShader(CompileShader(gs_5_0, SpriteGS()));
        SetPixelShader(CompileShader(ps_5_0, DummyPS()));

        SetRasterizerState(rsCullNone);
        SetDepthStencilState(EnableDepth,0);
        SetBlendState(NoBlending, float4(0.0f, 0.0f, 0.0f, 0.0f), 0xFFFFFFFF);
    }
}
</code></pre>