Effekt einlesen mit EffetkFramework unter DX10 geht nicht



  • Hallo,

    ich möchte eine Effektdatei einlesen unter DX10(.1). Leider funktioniert das bei mir nicht so wie ich es gerne hätte. Sprich MSVC 2010 Express gibt mir einen Laufzeitfehler beim setzen der Technique, da er(oder eher DX) die Effektdatei einliest (oder kompiliert) aber den Effekt nicht richtig kreiert.
    Meine Code sieht so aus:

    HRESULT hr;
        WCHAR str[MAX_PATH];
        hr=DXUTFindDXSDKMediaFileCch(str,MAX_PATH,m_EffectFileName);
        if(hr!=S_OK)
            MessageBox( DXUTGetHWND(),L"Konnte die Effektdatei nicht finden!",L"DXUT Application",MB_ICONERROR | MB_OK );
        DWORD dwShaderFlags=D3D10_SHADER_ENABLE_STRICTNESS;
        ID3D10Blob *pBlob=NULL;
        hr=D3DX11CompileFromFile(str,NULL,NULL,"","fx_4_0",dwShaderFlags,0,NULL,&pBlob,NULL,NULL);
        if(hr!=S_OK)
            MessageBox( DXUTGetHWND(),L"Konnte die Effektdatei nicht einlesen!",L"DXUT Application",MB_ICONERROR | MB_OK );
        hr=D3DX11CreateEffectFromMemory(pBlob->GetBufferPointer(),pBlob->GetBufferSize(),dwShaderFlags,g_pBase->m_pDevice,&m_pEffect);
        if(hr!=S_OK)
            MessageBox( DXUTGetHWND(),L"Konnte die Effektdatei nicht kompilieren!",L"DXUT Application",MB_ICONERROR | MB_OK );
        m_pTechnique=m_pEffect->GetTechniqueByName(m_TechniqueName.c_str());
    

    Die Messageboxes dienen nur für mich.

    Die Effektdatei:

    //------------------------------------------------------------------------------
    // Globale Variablen
    //------------------------------------------------------------------------------
    cbuffer cbPerObject 
    {
        matrix  g_mWorldViewProjection;  
        matrix  g_mWorld;                
        float4  g_MaterialAmbientColor;  
        float4  g_MaterialDiffuseColor;  
    }
    
    cbuffer cbPerFrame 
    {
        float3              g_vLightDir;
        float               g_fTime;    
        float4              g_LightDiffuse;
    };
    
    Texture2D g_txDiffuse;                
    
    //------------------------------------------------------------------------------
    // Textur-Sampler
    //------------------------------------------------------------------------------
    SamplerState g_samLinear
    {
        Filter = MIN_MAG_MIP_LINEAR;
        AddressU = Wrap;
        AddressV = Wrap;
    };
    
    //------------------------------------------------------------------------------
    // Ein- und Ausgabestrukturen
    //------------------------------------------------------------------------------
    struct VS_INPUT
    {
        float4 Position     : POSITION; // vertex position 
        float3 Normal       : NORMAL;   // this normal comes in per-vertex
        float2 TextureUV    : TEXCOORD0;// vertex texture coords 
    };
    
    struct VS_OUTPUT
    {
        float4 Position     : SV_POSITION; // vertex position 
        float4 Diffuse      : COLOR0;      // vertex diffuse color 
                                           //(note that COLOR0 is clamped from 0..1)
        float2 TextureUV    : TEXCOORD0;   // vertex texture coords 
    };
    
    //------------------------------------------------------------------------------
    // Vertexshader
    //------------------------------------------------------------------------------
    VS_OUTPUT RenderSceneVS( VS_INPUT input )
    {
        VS_OUTPUT Output;
        float3 vNormalWorldSpace;
    
        // Transform the position from object space to homogeneous projection space
        Output.Position = mul( input.Position, g_mWorldViewProjection );
    
        // Transform the normal from object space to world space    
        vNormalWorldSpace = normalize(mul(input.Normal, (float3x3)g_mWorld)); 
                                             // normal (world space)
        // Calc diffuse color    
        Output.Diffuse.rgb = g_MaterialDiffuseColor * g_LightDiffuse * 
            max(0,dot(vNormalWorldSpace, g_vLightDir)) + g_MaterialAmbientColor;   
        Output.Diffuse.a = 1.0f; 
    
        // Just copy the texture coordinate through
        Output.TextureUV = input.TextureUV; 
    
        return Output;    
    }
    
    //------------------------------------------------------------------------------
    // Pixelshader
    //------------------------------------------------------------------------------
    float4 RenderScenePS( VS_OUTPUT In ) : SV_TARGET
    { 
        // Lookup mesh texture and modulate it with diffuse
        return g_txDiffuse.Sample( g_samLinear, In.TextureUV ) * In.Diffuse;
    }
    
    //------------------------------------------------------------------------------
    // Technique
    //------------------------------------------------------------------------------
    technique11 RenderScene
    {
        pass P0
        {       
    		SetVertexShader( CompileShader(vs_4_0, RenderSceneVS() ) );
            SetGeometryShader( NULL );
            SetPixelShader( CompileShader(ps_4_0, RenderScenePS() ) );
        }
    }
    

    Der Fehler tritt um genau zu sein auf bei:
    EffectLoad.cpp

    // Verify the version
        if( FAILED( hr = GetEffectVersion( m_pHeader->Tag, &m_Version ) ) )
        {
            DPF(0, "Effect version is unrecognized.  This runtime supports fx_5_0 to %s.", g_EffectVersions[NUM_EFFECT10_VERSIONS-1].m_pName );
            VH( hr );
        }
    

    Was genau mache ich falsch?



  • Ok inzwischen weiß ichs: ich muss nur den Effekt mit fx_5_0 compilieren und dann geht's 🙂 .


Anmelden zum Antworten