Flickering with Custom Shader in Client-Server Game

Topics: Developer Forum, User Forum
May 23, 2007 at 4:30 PM
I've created a shader (which duplicates the matrix palette skinning technique used in dastle's tutorial shader). The shader works fine when there is only one object using it in the scene.

My problem is that I'm creating a client-server game (taking advantage of .NET remoting) in which an instance of my PlayerCharacter class is created for each client, with both local PlayerCharacters and remote PlayerCharacters being shown all viewports. When more than one PlayerCharacter is logged into the server, and using my new shader, both PlayerCharacters are drawn with a flicker. I'm wondering if there is a possibility that something about the way the ModelAnimator stores world matrices or other info about the different Animations and BonePoses could be the cause of this.

My shader uses a World global variable, and allows that value to be set by the ModelAnimator (I remembered to InitializeEffectParams() ). It also uses WorldViewProj, ViewInverse, and WorldInverseTranspose matrices, which I update in the Update() method.

If anyone can help, I'd really appreciate it. Let me know if you need clarification or more info from me.

May 29, 2007 at 5:00 PM
I saw that in the content processor that if the X file referred to an effect, the processor would use that effect. So I've abandoned the approach used in the previous post, created a shader which supports matrix palette skinning, and assigned that to my model in its X file, along with appropriate parameters for the shader. I'm now experiencing the problem that when I build my game, I get an InvalidCastException when I try to set myModel = content.Load<model>("myModelXFile"); .

Examining the exception details, it looks like the exception occurs in the following method:
Microsoft.Xna.Framework.Graphics.EffectParameter.SetValue(String value)

But I can't figure out how to find out what the value of that string is. I've added System.Diagnostics.Debugger.Launch(); to the AnimatedModelProcessor.cs file in the animation component library, which allows me to step through that process. But I never get to the point where it calls Microsoft.Xna.Framework.Graphics.EffectParameter.SetValue(String value) . It just successfully goes through all the code in the processor, returns dict as the result of myModel = content.Load<model>("myModelXFile");, and then immediately throws an InvalidCastException.

Does anyone have a clue about how I might track down what is the invalid data that is being cast here?


Jun 6, 2007 at 11:49 PM
Sorry for taking so long to respond to this - I've had other commitments but will have a bit more time now to respond to questions on the forum.

You can track down the exception by going to start->debug, and it should stop at the line of code at which the exception is thrown. Does this not work for you?