Question

My terrain gets weird colors like this:

http://tinypic.com/view.php?pic=307w421&s=7

Does anyone have any idea what is going wrong here? In what area of my code (conceptually) should I look to debug this?

Update:

Its from a tutorial from my school based on: http://www.riemers.net/eng/Tutorials/XNA/Csharp/Series1/Starting_a_project.php

We made use of the BasicEffect shader and made various parts of the engine such as: a camera, a 3d vertices terrain derived from a heigthmap, basic lighting, basic soft normals and an buffers for optimalization.

VertexPositionColorNormal Struct:

public struct VertexPositionColorNormal : IVertexType
{
    #region Field
    public Vector3 Position, Normal;
    public Color Color;

    #endregion

    #region Constructor

    public VertexPositionColorNormal(Vector3 position, Color color, Vector3 normal)
    {
        Position = position;
        Color = color;
        Normal = normal; 
    }

    #endregion

    #region properties

    public static VertexElement[] VertexElements =
    {
        new VertexElement(0, VertexElementFormat.Vector3, VertexElementUsage.Position, 0),
        new VertexElement(sizeof(float) * 3, VertexElementFormat.Color, VertexElementUsage.Color, 0),
        new VertexElement(sizeof(float)*3+4,VertexElementFormat.Vector3, VertexElementUsage.Normal,0),
    };

    public readonly static VertexDeclaration VertexDeclaration = new VertexDeclaration(VertexElements);

    VertexDeclaration IVertexType.VertexDeclaration
    {
        get { return VertexDeclaration; }
    }

    #endregion
Was it helpful?

Solution

Try removing the , at the end of this line:

new VertexElement(sizeof(float)*3+4,VertexElementFormat.Vector3, VertexElementUsage.Normal,0),

I also noticed that you've added a constructor to your code but there isn't one on Riemer's site.

Also, it might be easier for you to post your code somewhere as a zip file so we can take a look that way.

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