Custom effects

Feb 19, 2010 at 7:50 AM
Edited Feb 19, 2010 at 7:51 AM

I have decided to give XNAnimation a try since it seem to be able to play animations rather simple. I have a question about using a custom effect(shader) for my models.

I have used this guide mostly:

Any ideas on how to port that to XNAnimation Library. I downloaded, what I think what the latest source(under Source Code tab).

Or is there another way to set a new effectfile(when loading a model) without ruining the information already loaded with the content importer. I mean is there a built in method for this?


Edit: Another question, when using rigid models like a tree, should you still make bones and do bone animations for the tree moving in the wind since creating keyframed animations would give me 1 .x file for every frame? Using 3ds max.

Feb 19, 2010 at 10:06 AM

XNAnimation already does what the article describes with its own effect file (SkinnedModelEffect.fx). If you change your effect at runtime you will get pretty nasty side-effects, event the game crashing to back to the debugger. However, you can change that effect to add or take out functionality as needed.

If MAX is giving you a .X file for each frame... well, you aren't exporting it correctly :P The best way is doing it as in the samples: all of the animations in a single timeline and split them using a XML file.

Feb 19, 2010 at 11:01 AM

First, thanks for a quick reply.

I'll look into the max thing, so for animating a rigid body such as a tree it is best just to setup keyframes for those animations(without skins and bones)?

Is there some support for shadows? My knowledge is not top notch, but I would really like to implement shadows both on the animated models themselves but also so they cast on the background(the terrain)? Any ideas?


Feb 19, 2010 at 11:13 AM

I think I expressed myself wrong; XNAnimation only supports skeletal animation so far. But, if your rigid body doesn't have any animations and is completely static, you can still use XNAnimation to load and display it. Just have a look at how the weapon model is drawn in the AttachModel example.

The current version doesn't have any support for shadowing, but you can modify the SkinnedModelEffect.fx effect to add a simple shadowmap or whatever approach better fits your project. Currently the main direction of XNAnimation is fixing bugs and adding core features, but the rendering effect will be revised in a near future to add more functionality.

Feb 19, 2010 at 3:40 PM

Ok, I see. Will have to look into skinnedmodeleffect.fx. Might just copy all the saved effects and add them to an effect of my own. Have a weird issue, that model looses all the specular features when I port the code to an app of my own, the pointlight does not work. I position them almost on top of each other but no affect, weird.