XNA Creators Club Online
Page 1 of 1 (3 items)
Sort Posts: Previous Next

Models with multiple meshes sharing the same effect but using different techniques

Last post 09-05-2008 9:38 PM by kristian. 2 replies.
  • 09-03-2008 1:12 AM

    Models with multiple meshes sharing the same effect but using different techniques

    I've created a cube with a color texture and normal map. I got it into XNA from ModTool using this guide: Integrating Your XNA Engine With XSI ModTool .

    My idea was to make another cube. I want it to use the same effect file but a different technique. So I wrote a pixel shader returning nothing but the color white and a new technique using it called "render1". I duplicated my previous DirectX material and changed the technique on my newly created material. Now I got two materials; brick1 using technique "render0" and brick2 using technique "render1" both using the same xsiEffect.fx file. 

    I assigned brick1 to one of the cubes and brick2 to the other. Everything plays nicely in the viewport in ModTool. One shows the textures and the other one is white. I published the model and when I loaded it in XNA they look just the same. Both using the "render0" technique. Debugging the application confirms that the current technique for both effects is indeed "render0".

    Doesn't the .xsi format save information about the technique? I guess it does since loading the model back into ModTool works fine. So I'm guessing the problem is either in the content processor or the Model class. Am I on to something here?

    I guess I could do this by code but this really seems like a job for the 3d artist, not the coder. Apparently it knows which texture file to use correctly so I guess some kind of mapping have been done, so any idea why the technique mapping is missing? Or is this way of using shaders just fundamentally stupid? I'd really like to keep it to one effect file and use different techniques for different materials in the game.

  • 09-05-2008 7:49 PM In reply to

    Re: Models with multiple meshes sharing the same effect but using different techniques

    The .xsi format and the xsi xna runtime might not save or use the technique assignments you create in XSI. You could do this by passing this information to the shader when you call it in your draw method.
  • 09-05-2008 9:38 PM In reply to

    Re: Models with multiple meshes sharing the same effect but using different techniques

    Yes that was pretty much what I wrote. Does anyone actually know why it behaves like this? My guess is that the content processor doesn't read the current technique. Seems like a minor thing to store the technique of the xsi material somewhere in the Model class.

    And as I wrote earlier by setting the technique just before the draw calls puts the responsibility of "materials" in the hands of the programmer when I find this really to be the job of the 3d artist. Having a model with alot of meshes would be quite tedious to map the mesh name with the technique this way. I guess it's somewhat ok if it's below 10 but if it's something like 50 it starts to get rediculous. Also if the art direction changes it would seem strange that the programmer would have to change code for things like what technique is being used for i.e. character meshes.

    By using the "map mesh name to shader technique" by code also calls for specialized draw calls which seems like a dirty way of doing it

    So my question is. Does anyone know a better way of doing it? is it possible in any way to add some property in xsi for each mesh that I can retrieve in xna?

Page 1 of 1 (3 items) Previous Next