Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to create a very simple game, and am working with HLSL. I got this error in my draw method:

The current vertex declaration does not include all the elements required by the current vertex shader. TextureCoordinate0 is missing.

Here is my draw method:

public void Draw(Matrix View, Matrix Projection,Vector3 CameraPosition)
        // Calculate the base transformation by combining
        // translation, rotation, and scaling

        Matrix baseWorld = Matrix.CreateScale(Scale) *
            Matrix.CreateFromYawPitchRoll(Rotation.X, Rotation.Y, Rotation.Z) *
        foreach (ModelMesh mesh in Model.Meshes)
            Matrix localWorld = modelTransforms[mesh.ParentBone.Index] * baseWorld;

            foreach (ModelMeshPart part in mesh.MeshParts)
                Effect effect = part.Effect;
                if (part.Effect is BasicEffect)
                    ((BasicEffect)effect).World = localWorld;
                    ((BasicEffect)effect).View = View;
                    ((BasicEffect)effect).Projection = Projection;
                    setEffectParameter(effect, "World", localWorld);
                    setEffectParameter(effect, "View", View);
                    setEffectParameter(effect, "Projection", Projection);
                    setEffectParameter(effect, "CameraPosition", CameraPosition);


But in VertexShaderFunction (in LightingEffect), instead of output.UV = input.UV I put output.UV=float2(somefloat,somefloat) I get no error.

There is a another thing, I got this error when I try to load my "Cathedral" model and others, but for "teapot" model I get no error.

Here is my complete code and models.

share|improve this question
up vote 2 down vote accepted

The problem is that your vertex buffer's data doesn't contain a channel for texture coordinates, and your shader requires it. You have to edit your model and add proper UV mapping to it.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.