Question

Let me post the images first...

Solid shot where tearing occurs enter image description here

And wireframe shot of that place enter image description here

I am mostly using mostly using Riemers tutorial while the render code is..

Main render

    public void Render()
    {
        device.Clear(Color.CornflowerBlue);
        RasterizerState rs = new RasterizerState();
        rs.CullMode = cullmode;
        rs.FillMode = fillmode;
        device.RasterizerState = rs;

        effect.Parameters["xView"].SetValue(camera.ViewMatrix);
        effect.Parameters["xProjection"].SetValue(camera.ProjectionMatrix);
        effect.Parameters["xWorld"].SetValue(Matrix.Identity);
        effect.Parameters["xEnableLighting"].SetValue(true);
        effect.Parameters["xLightDirection"].SetValue(lightDirection);
        effect.Parameters["xAmbient"].SetValue(0.5f);

        globals.game.terrain.Render();

        globals.game.spriteBatch.Begin();
        globals.console.Render();
        globals.game.spriteBatch.End();
    }

Terrain.Render()

    public void Render()
    {
        globals.game.graphics.effect.CurrentTechnique = globals.game.graphics.effect.Techniques["Colored"];

        globals.game.graphics.effect.Parameters["xWorld"].SetValue(worldMatrix);
        foreach (EffectPass pass in  globals.game.graphics.effect.CurrentTechnique.Passes)
        {
            pass.Apply();

            globals.game.graphics.device.Indices = indexBuffer;
            globals.game.graphics.device.SetVertexBuffer(vertexBuffer);
            globals.game.graphics.device.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, vertices.Length, 0, indices.Length / 3);          

        }
    }

I was stuck with this problem for pretty long now (not knowing if it is caused by my coding skills, xna or some g-card configuration...) so i wonder if someone have some ideas what might cause it?

Was it helpful?

Solution

Temporarily comment out the spritebatch begin, draw, & end code and see if that makes a difference. It may or may not depending on the vertex order in the buffer.

If it does help, your solution can be found here: http://blogs.msdn.com/b/shawnhar/archive/2010/06/18/spritebatch-and-renderstates-in-xna-game-studio-4-0.aspx

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top