problem with loading in .FBX meshes in DirectX 10

Posted by N0xus on Game Development See other posts from Game Development or by N0xus
Published on 2012-06-11T18:23:18Z Indexed on 2012/06/11 22:48 UTC
Read the original article Hit count: 429

Filed under:
|
|

I'm trying to load in meshes into DirectX 10. I've created a bunch of classes that handle it and allow me to call in a mesh with only a single line of code in my main game class.

How ever, when I run the program this is what renders: enter image description here

In the debug output window the following errors keep appearing:

D3D10: ERROR: ID3D10Device::DrawIndexed: Input Assembler - Vertex Shader linkage error: Signatures between stages are incompatible. The reason is that Semantic 'TEXCOORD' is defined for mismatched hardware registers between the output stage and input stage. [ EXECUTION ERROR #343: DEVICE_SHADER_LINKAGE_REGISTERINDEX ] D3D10: ERROR: ID3D10Device::DrawIndexed: Input Assembler - Vertex Shader linkage error: Signatures between stages are incompatible. The reason is that the input stage requires Semantic/Index (POSITION,0) as input, but it is not provided by the output stage. [ EXECUTION ERROR #342: DEVICE_SHADER_LINKAGE_SEMANTICNAME_NOT_FOUND ]

The thing is, I've no idea how to fix this. The code I'm using does work and I've simply brought all of that code into a new project of mine. There are no build errors and this only appears when the game is running

The .fx file is as follows:

float4x4 matWorld;
float4x4 matView;
float4x4 matProjection;

struct VS_INPUT
{
    float4 Pos:POSITION;
    float2 TexCoord:TEXCOORD;
};

struct PS_INPUT
{
    float4 Pos:SV_POSITION;
    float2 TexCoord:TEXCOORD;
};

Texture2D diffuseTexture;

SamplerState diffuseSampler
{
    Filter = MIN_MAG_MIP_POINT;
    AddressU = WRAP;
    AddressV = WRAP;
};

//
// Vertex Shader
//
PS_INPUT VS( VS_INPUT input )
{
    PS_INPUT output=(PS_INPUT)0;

    float4x4 viewProjection=mul(matView,matProjection);
    float4x4 worldViewProjection=mul(matWorld,viewProjection);

    output.Pos=mul(input.Pos,worldViewProjection);
    output.TexCoord=input.TexCoord;
    return output;
}


//
// Pixel Shader
//
float4 PS(PS_INPUT input ) : SV_Target
{
    return diffuseTexture.Sample(diffuseSampler,input.TexCoord);
    //return float4(1.0f,1.0f,1.0f,1.0f);
}

RasterizerState  NoCulling
{
    FILLMODE=SOLID;
    CULLMODE=NONE;
};

technique10 Render
{
    pass P0
    {
        SetVertexShader( CompileShader( vs_4_0, VS() ) );
        SetGeometryShader( NULL );
        SetPixelShader( CompileShader( ps_4_0, PS() ) );
        SetRasterizerState(NoCulling);
    }
}

In my game, the .fx file and model are called and set as follows:

Loading in shader file

    //Set the shader flags - BMD
    DWORD dwShaderFlags = D3D10_SHADER_ENABLE_STRICTNESS;

#if defined( DEBUG ) || defined( _DEBUG )
    dwShaderFlags |= D3D10_SHADER_DEBUG;
#endif
    ID3D10Blob * pErrorBuffer=NULL;


    if( FAILED( D3DX10CreateEffectFromFile( TEXT("TransformedTexture.fx" ), NULL, NULL, "fx_4_0", dwShaderFlags, 0, md3dDevice, NULL, NULL, &m_pEffect, &pErrorBuffer, NULL ) ) )
    {
        char * pErrorStr = ( char* )pErrorBuffer->GetBufferPointer();
        //If the creation of the Effect fails then a message box will be shown
        MessageBoxA( NULL, pErrorStr, "Error", MB_OK );
        return false;
    }

    //Get the technique called Render from the effect, we need this for rendering later on 
    m_pTechnique=m_pEffect->GetTechniqueByName("Render");

    //Number of elements in the layout 
    UINT numElements = TexturedLitVertex::layoutSize;

    //Get the Pass description, we need this to bind the vertex to the pipeline 
    D3D10_PASS_DESC PassDesc;
    m_pTechnique->GetPassByIndex( 0 )->GetDesc( &PassDesc );

    //Create Input layout to describe the incoming buffer to the input assembler
    if (FAILED(md3dDevice->CreateInputLayout( TexturedLitVertex::layout, numElements,PassDesc.pIAInputSignature, PassDesc.IAInputSignatureSize, &m_pVertexLayout ) ) ) 
    {
        return false;
    }

model loading:

m_pTestRenderable=new CRenderable();
//m_pTestRenderable->create<TexturedVertex>(md3dDevice,8,6,vertices,indices);

    m_pModelLoader = new CModelLoader();
    m_pTestRenderable = m_pModelLoader->loadModelFromFile( md3dDevice,"armoredrecon.fbx" );
    m_pGameObjectTest = new CGameObject();
    m_pGameObjectTest->setRenderable( m_pTestRenderable );



    // Set primitive topology, how are we going to interpet the vertices in the vertex buffer 
    md3dDevice->IASetPrimitiveTopology( D3D10_PRIMITIVE_TOPOLOGY_TRIANGLELIST );    

    if ( FAILED( D3DX10CreateShaderResourceViewFromFile( md3dDevice, TEXT( "armoredrecon_diff.png" ), NULL, NULL, &m_pTextureShaderResource, NULL ) ) )
    {
        MessageBox( NULL, TEXT( "Can't load Texture" ), TEXT( "Error" ), MB_OK );
        return false;
    }

    m_pDiffuseTextureVariable = m_pEffect->GetVariableByName( "diffuseTexture" )->AsShaderResource();
    m_pDiffuseTextureVariable->SetResource( m_pTextureShaderResource );

Finally, the draw function code:

//All drawing will occur between the clear and present 
    m_pViewMatrixVariable->SetMatrix( ( float* )m_matView );
    m_pWorldMatrixVariable->SetMatrix( ( float* )m_pGameObjectTest->getWorld() );

    //Get the stride(size) of the a vertex, we need this to tell the pipeline the size of one vertex 
    UINT stride = m_pTestRenderable->getStride();

    //The offset from start of the buffer to where our vertices are located 
    UINT offset = m_pTestRenderable->getOffset();
    ID3D10Buffer * pVB=m_pTestRenderable->getVB();

    //Bind the vertex buffer to input assembler stage -
    md3dDevice->IASetVertexBuffers( 0, 1, &pVB, &stride, &offset );
    md3dDevice->IASetIndexBuffer( m_pTestRenderable->getIB(), DXGI_FORMAT_R32_UINT, 0 );

    //Get the Description of the technique, we need this in order to loop through each pass in the technique
    D3D10_TECHNIQUE_DESC techDesc;
    m_pTechnique->GetDesc( &techDesc );

    //Loop through the passes in the technique 
    for( UINT p = 0; p < techDesc.Passes; ++p )
    {
        //Get a pass at current index and apply it 
        m_pTechnique->GetPassByIndex( p )->Apply( 0 );

        //Draw call
        md3dDevice->DrawIndexed(m_pTestRenderable->getNumOfIndices(),0,0);
        //m_pD3D10Device->Draw(m_pTestRenderable->getNumOfVerts(),0);
    }

Is there anything I've clearly done wrong or are missing? Spent 2 weeks trying to workout what on earth I've done wrong to no avail.

Any insight a fresh pair eyes could give on this would be great.

© Game Development or respective owner

Related posts about directx

Related posts about 3d-meshes