D3D10_INPUT_ELEMENT_DESC vertexDesc[] =
{
{"POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D10_INPUT_PER_VERTEX_DATA, 0},
{"COLOR", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 12, D3D10_INPUT_PER_VERTEX_DATA, 0},
{ "VEL", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 28, D3D10_INPUT_PER_VERTEX_DATA, 0 },
{ "MA", 0, DXGI_FORMAT_R32_FLOAT, 0, 40, D3D10_INPUT_PER_VERTEX_DATA, 0 },
};
UINT numElements = sizeof( vertexDesc) / sizeof( vertexDesc[0] );
D3D10_PASS_DESC PassDesc;
g_pTechnique->GetPassByIndex(0)->GetDesc(&PassDesc);
hr = g_pd3dDevice->CreateInputLayout(vertexDesc, numElements,PassDesc.pIAInputSignature, PassDesc.IAInputSignatureSize,&g_pVertexLayout);
if( FAILED( hr ) )
return hr;
g_pd3dDevice->IASetInputLayout(g_pVertexLayout);now the buffer: i have 2 buffers one with the original vertex data and another where the modified vertex buffer is gonna be
SimpleVertex vertices2[] =
{
{ D3DXVECTOR3( 0.0f, 1.0f, 0.0f ), D3DXCOLOR( 0.0f, 0.0f, 1.0f, 1.0f ), D3DXVECTOR3( 0.0f, 0.0f, 0.0f ),float(1.0f)},
{ D3DXVECTOR3( 1.0f, 0.0f, 0.0f ), D3DXCOLOR( 0.0f, 1.0f, 0.0f, 1.0f ), D3DXVECTOR3( 0.0f, 0.0f, 0.0f ),float(1.0f)},
{ D3DXVECTOR3( 0.0f, 0.0f, -1.0f ), D3DXCOLOR( 0.0f, 1.0f, 1.0f, 1.0f ), D3DXVECTOR3( 0.0f, 0.0f, 0.0f ),float(1.0f)},
{ D3DXVECTOR3( 0.0f, 0.0f, 0.0f ), D3DXCOLOR( 1.0f, 0.0f, 0.0f, 1.0f ), D3DXVECTOR3( 0.0f, 0.0f, 0.0f ),float(1.0f)},
};
bd.Usage = D3D10_USAGE_DEFAULT;
bd.ByteWidth = sizeof( SimpleVertex ) * 4;
bd.BindFlags = D3D10_BIND_VERTEX_BUFFER | D3D10_BIND_STREAM_OUTPUT;
bd.CPUAccessFlags = 0;
bd.MiscFlags = 0;
initData.pSysMem = vertices2;
hr = g_pd3dDevice->CreateBuffer( &bd, &initData, &g_pVertexBuffer2 );//first buffer where the original info is
if( FAILED( hr ) )
return hr;
hr = g_pd3dDevice->CreateBuffer( &bd, 0, &g_pVertexBuffer3 );//second buffer where the info form the first is gona be after modified
if( FAILED( hr ) )
return hr;and now this is how i render it, i change the buffers each frame ping pong metod
if(g)
{
g_pd3dDevice->SOSetTargets(1, &g_pVertexBuffer3 , &offset);
g_pd3dDevice->IASetVertexBuffers(0, 1, &g_pVertexBuffer2, &stride, &offset);
g=false;
}
else
{
g_pd3dDevice->SOSetTargets(1, &g_pVertexBuffer2 , &offset);
g_pd3dDevice->IASetVertexBuffers(0, 1, &g_pVertexBuffer3, &stride, &offset);
g=true;
}
g_pd3dDevice->IASetIndexBuffer( g_pIndexBuffer2, DXGI_FORMAT_R32_UINT, 0 );
g_pWorldVariable->SetMatrix( ( float* )&g_World2 );
g_pTechnique2->GetPassByIndex( 0 )->Apply( 0 );
g_pd3dDevice->DrawIndexed( 12, 0, 0 );
g_pSwapChain->Present( 0, 0 );the .fx is like this, there are no errors any more, the vertex shader only returns the same position, the tetrahedron never moves.
struct VS_INPUT
{
float4 Pos : POSITION;
float4 Color : COLOR;
float3 Vel : VEL;
float Ma : MA;
};
struct VS_INPUTT
{
float4 Pos : SV_POSITION;
float4 Color : COLOR;
float3 Vel : VEL;
float Ma : MA;
};
VS_INPUTT VS2( VS_INPUT input )
{
VS_INPUTT output = (VS_INPUTT)0;
output.Pos = mul( input.Pos, World );
output.Pos = mul( output.Pos, View );
output.Pos = mul( output.Pos, Projection );
output.Color = input.Color;
output.Vel.x = input.Vel.x+(Time*Force.x);
output.Vel.y = input.Vel.y+(Time*Force.y);
output.Vel.z = input.Vel.z+(Time*Force.z);
output.Ma = input.Ma;
return output;
}and at the end of the .fx file is this
VertexShader vss = CompileShader( vs_4_0, VS2() );
GeometryShader gss= ConstructGSWithSO( vss, "SV_POSITION.xyz; COLOR.xyzw; VEL.xyz; MA.x" );
technique10 Pa
{
pass P0
{
SetVertexShader( vss );
SetGeometryShader( gss );
SetPixelShader( CompileShader( ps_4_0, PS2() ) );
}
}what happens is that there is no error anywere,but it works rare, the first frame i render it renders ok, the tetrahedron is in its place, then the second frame some vertex of the tetrahedron are in its place and the others are like very far away up, and then in the next frame it disapears.






