Why should I need a shader in every D3DShaderMeshNode11?

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • Why should I need a shader in every D3DShaderMeshNode11?

      Hi there,

      It really confuses me when I saw the source code in D3DShaderMeshNode11.

      Every instance of D3DShaderMeshNode11 will have its own shader, and it will compile and generate constant buffer for the shaders.

      My question is, is the approach really necessary? I'm new to these graphics API, but I thought these shaders should be reused by refreshing data in constant buffer such as material or ModelViewProjection matrix.

      In order to render each mesh scene node, D3DX have to keep switch between different shaders for rendering. Will it cause more overhead and slow down frame rate?

      If the answer is NO, how should I optimize it?