Shaderx5 - Transparent Shader Data Binding

Started by
-1 comments, last by littlekid 15 years, 9 months ago
I have read the article by Dustin Franklin, and was wondering how to actually use it. For example if I have a global common ShadowMap.fx that generates shadowmaps. This EffectFile would be common across all entity/mesh to be drawn. How would I bind the data to the ShadowMap.fx? Does that mean for each Mesh, I need to have a Static/Dynamic Linker for every effect to be used? I was thinking of having something like this in each mesh:

class CLinkerTable
{
    std::map<ID3D10Effect*, std::vector<CLinker> > LinkerMap;

public:
    HRESULT ApplyLink(ID3D10Effect *pEffectToUse)
    {
        //Attempt to find if the Effect to be used has a list of Linker
        if (LinkerMap.find(pEffectToUse) == LinkerMap.end())
           return E_FAIL;

        //Apply the Link to bind the data
        for(size_t n=0; n<LinkerMap[pEffectToUse]->second.size(); n++)
           LinkerMap[pEffectToUse]->second[n].UpdateLink();
    }
};

//To draw a mesh I with shadowmap generation:
CMesh HumanMesh;
CLinkerTable HumanMeshLinkTable;
...

//ShadowMap
HumanMeshLinkTable.ApplyLink(pShadowMapEffect);
HumanMesh.Draw();

//Standard Drawing
HumanMeshLinkTable.ApplyLink(pStandardEffect);
HumanMesh.Draw();

However it seems that each time I load a effect, I need to loop through all the entites/mesh and create the Data Link for it and store it in the CLinkerTable. Wouldn't it be slow if the game has like 1000 entites?

This topic is closed to new replies.

Advertisement