Thumbstick deadzone and texture

May 13, 2010 at 11:33 PM
Edited May 14, 2010 at 4:32 PM

Hello again.


Two hopefully easy questions popped up this late-night.


Was checking out your input code but couldn't really get my head around if there is a possibility that you are able to ignore the thumbstick deadzone? Is it possible with XEN or do I have to use XNA input for that?


Second Is there a simple way to change the texture of a model without having to exporting the model itself several times with different diffuse maps...?


Model.ModelData.Meshes[0].Geometry[0].MaterialShader.TextureMap = "Player" + sPlayerIdx;


Where Model is a ModelInstance. That's what I'm trying to do now but all the players who share the same .fbx file end up using the same shader for their model and thus end up with the same texture(the last one I assigned), reference issue I guess.

Also tried to change the TextureMap in the MaterialShader class that I bind before drawing the model without any success.


Regarding Specular / Alpha. I've been searching all over here in the 'Discussion' part and am I right when I say that XEN has support for 'specular maps' wich they read from the alpha channel of the normal-map(?). Is there anything one have to do in code to activate this specular map?

Looked around in the classes and have only seen that you can set texture/normal for the MaterialShader.


Almost the same for alpha-maps, they are read from the alpha-channel of the diffuse-map(?).


Thanks on beforehand, any directions or help will be appriciated! Regards Joakim.

May 18, 2010 at 11:37 PM

Yes, you can still change the deadzone using standard XNA code.
The Xen input code just wraps on top of XNA. The primary reason why it exists it to prevent people doing things like this:

if (Keyboard.GetState().IsKeyDown(Keys.Left) && Keyboard.GetState().IsKeyDown(Keys.Ctrl)) ...

etc etc. Which can be quite amazingly slow.


As for textures in a model, I will be separating the materials from model content in Xen 2.0, but that won't be out for a while. Unfortunately, what you have written is pretty much the only way to use custom textures (or use shader overrides). I understand your pain, it's not a nice API :-(

The ModelInstances class will bind it's own shaders (either those specified by a shader override class, otherwise it will default to internal MaterialShaders), so anything you have bound when you start drawing the model will be ignored (this is another thing I'm improving in 2.0).


MaterialShader itself does multiply the calculated specular value by the alpha channel of the normal map. However, you need to be careful here as I've found that the content pipeline does not preserve RGB very well when the alpha is low. The best bet is to use the DirectX SDK texture converter and manually convert the textures to DDS yourself. Xen models have a content pipeline property called 'Manual Texture Import' which allows you to manually add the textures to the content project yourself (instead of them being implicitly processed). This generally gives a lot more control over the textures.

Another MaterialShader gotcha to note (which in hindsight was a really bad idea): By default per-pixel lights will not have a specular reflection unless you set MaterialShader.UsePerPixelSpecular to true!

The MaterialShader should also output the alpha of the texture unmodified (well, multiplied by MaterialShader.Alpha).