Weird backface glitch

I'm not sure what's going on here; I wouldn't be surprised if it's just my video card. But has anyone seen this before

cellphone_rendering_bugs.jpg

That's a series of screenshots I took as the model rotated... the original model in Maya has all its normals facing the right way. I exported it as an FBX200611 model. I'm (unfortunately) using a Compaq Presario with an NVIDIA GeForce 6150 LE video card.

I thought it might have been a matter of the near/far draw limits being too far apart and the Z buffer lacking the precision to draw this relatively small area properly, but I turned it down to 1.0 -> 100.0 and it still happens. Any thoughts


Answer this question

Weird backface glitch

  • Kathirvel

    I don't have an answer but wanted to state that the DX Viewer from the December SDK has crashed on every computer I've tried it on and I've heard the same from others.

    Looking through the code, this is the first version that attempts to use the DX10 libs. I was able to compile a version that at least starts, but still fails on loading a model. I haven't had time to get back to it to fix the next issue.

    Anyway, don't take that crashing as a "bad sign".

  • reza_a_m

    Perhaps this is a compability problem with DX10 and older video cards

    Post the model and I can try it on my machine as well. I have DX9.0c and the viewer works fine on mine.


  • AndersBank

    Well, this isn't a good sign; DirectX Viewer crashes immediately on my computer ;)

    I turned on backface culling in Maya (where I made the model) and the faces are definitely all facing the right way...

  • Paukstis

    Make sure that you have culling on, and make note of the direction (i.e. CCW - Counter Clockwise as opposed to CW - Clockwise). If you made the model yourself, then make sure that all the faces were constructed in the same manner. That is, if you constructed face 1 in a CCW manner, then construct the rest of the faces in the same manner. In most editors you can turn on face normals to see which way they are facing to make a quick and easy determination from there.

    Good luck.


  • g33kspeak

    I'm using code from a tutorial... this is all pretty new to me, but it looks roughly equivalent...

    Matrix[] transforms = new Matrix[myModel.Bones.Count];
    myModel.CopyAbsoluteBoneTransformsTo(transforms);

    foreach (ModelMesh mesh in myModel.Meshes)
    {
    foreach (BasicEffect effect in mesh.Effects)
    {
    effect.EnableDefaultLighting();
    effect.World = transforms[mesh.ParentBone.Index] * currentRotationMatrix * Matrix.CreateTranslation(modelPosition);
    effect.View = Matrix.CreateLookAt(cameraPosition, new Vector3(0, cameraYshift, 0), Vector3.Up);
    effect.Projection = Matrix.CreatePerspectiveFieldOfView(MathHelper.ToRadians(45.0f),aspectRatio, 1.0f, 100.0f);
    }
    mesh.Draw();
    }

    Where can I find this DirectX Viewer

  • upgraders

    I think that looks correct, unless I'm missing something.

    The DirectX Viewer comes with the DirectX SDK, and although the DirectX SDK isn't required to develop XNA applications, it has some useful tools and samples for the XNA developer.

    Bill



  • J Lim

    I saw some things like this when I wasn't taking the parent bone transform into account when rendering a mesh. I added the following code when initializing my model class wrapper:

    _boneTransforms = new Matrix[_model.Bones.Count];

    _model.CopyAbsoluteBoneTransformsTo(_boneTransforms);

    and then when drawing each of my meshes:

    effect.World = _boneTransforms[mesh.ParentBone.Index] * _rotationMatrixY * _rotationMatrixZ;

    Some of the examples that I have seen for drawing a model miss this code and if you have more than one mesh it will have odd behavior. Not sure if that's what you're seeing though.

    Question: Does it look ok in the DirectX viewer

    Bill

     



  • osamaT

    Did you turn on culling in XNA

    Microsoft.Xna.Framework.Graphics graphics;

    graphics.RenderState.CullMode =CullMode.CounterClockwise;
    graphics.RenderState.DepthBufferEnable = true;

    This makes sure that Culling is enabled and is set to CounterClockwise (the default), and that the DepthBuffer is enabled.

    Do this before drawing anything.  I hope it helps.


  • Gutek

    Hahah, success! :) That was it, B1narySh0t! I had to tweak the code a bit...

    graphics.GraphicsDevice.RenderState.CullMode = CullMode.CullCounterClockwiseFace;
    graphics.GraphicsDevice.RenderState.DepthBufferEnable = true;

    but that's the problem solved, thank you! :)

  • Nickus

    Yeah not a good sign. Well if you post your model somewhere I'll try to load it into the DirectX viewer and see what happens

  • Weird backface glitch