Robin Sarac

I've been struggling with shaders and effects for a while, but I'm starting to understand the basics. The content pipeline in XNA Game Studio Express makes dealing with all of it so nice! I love how I can keep my art assets separated from my engine code The problem I have now is when dealing with models I've loaded from .x files I've built using something like GameSpace.

Is there a place I can go to understand what is and what isn't included in an .x file I read that an .x file can include effects right in the file. Is that true Where this all causes a problem is in knowing how to write my shaders and in setting parameters within the XNA framework. What vertex format will be passed in Is this something that I can get from the meshes in the .x file Is there something in XNA thatdeals with this I've found plenty of information on how it all works when you explicitly define the vertices, indices, and vertex declaration. But what if you're just loading models from an .x file

I guess what it boils down to is that I'm not sure of the best way to connect models in XNA with effects in XNA. I'm not looking for the lazy way out. :) I would really like to understand how this works. Books, articles, blogs...any and all of the above is much appreciated!



Re: XNA Game Studio Express Dealing With .X Files To Effects / Shaders

cronholio

There's a whole series of tutorials on building a game library here:

http://www.thehazymind.com/XNAEngine.htm

Two of them deal with shaders, a new surface shader being applied to an X file, and a new post processing shader. They don't explicit explain how everything works, but it's pretty easy to figure out if you work through the tutorial.

Here's a dated explanation of the X file format:

http://local.wasp.uwa.edu.au/~pbourke/dataformats/directx/

Between this and the documentation in the SDK you should be able to work out the X file format. You can store a lot of infomration in X files, but personally I kind of like to keep things separate. I wrote an X File converter for Houdini and all I store are Vertex and Face information for a rest pose, normals, texture assignments, maybe some color, and UVs. Anything else, animation, effects whatever, is stored outside the X file.





Re: XNA Game Studio Express Dealing With .X Files To Effects / Shaders

Robin Sarac

Thanks for pointing those links out. I've read through some of the earlier Hazy Mind stuff, but never got as far as the shaders. Seeing how thigns are done there does offer a lot of information, thanks. :)



Re: XNA Game Studio Express Dealing With .X Files To Effects / Shaders

Robin Sarac

I also just found this blog entry that answers a lot of the questions I have (or had as the case may be :)...

http://blogs.msdn.com/shawnhar/archive/2006/11/20/models-meshes-parts-and-bones.aspx




Re: XNA Game Studio Express Dealing With .X Files To Effects / Shaders

v.hong

usually, a .x file will contain things like; vertex positions, normals, texture coordinates, materials, bones, animations. here is an article that defines everything that can be contained in a .x file (link).

yes, .x files can contains references to .fx shaders. here's a tutorial for linking your shaders to your .x models in 3ds max (link). you could also manually link them within your .x file if your handy with notepad.

for writing your shader and setting the parameters in XNA, here is a tutorial provided in the XNA Documentation (link).

you can find out what vertex declaration XNA passes in by accessing the VertexDeclaration in Microsoft.Xna.Framework.Graphics.Model.Meshes.MeshPart. you can get the VertexDeclaration from a .x file, that data is contained in the DeclData template (although, from what i've seen, not many meshes contain this).

but a lot of this is simplified by the XNA Framework. here is a tutorial for the simplest way to load and render a mesh with effects (link).




Re: XNA Game Studio Express Dealing With .X Files To Effects / Shaders

Robin Sarac

This is great! Thank you very much for posting this information and these links. I will read them all!

:)