Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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 am rendering a simple flat plane + texture to use as the floor for a game. I'm rendering it using a custom effect I've written.

The problem I have is that the ground in the distance gets a bit distorted and shakey when the camera moves forwards and backwards.

If I render the same model + texture using the BasicEffect instead of a custom shader it appears smooth and works correctly.

Here's the XNA code setting up the custom effect:

Matrix worldMatrix = Matrix.CreateScale(0.2f);
_floorEffect.CurrentTechnique = _floorEffect.Techniques["Textured"];
_floorEffect.Parameters["ViewProjection"].SetValue(camera.view * camera.projection);


foreach (EffectPass pass in _floorEffect.CurrentTechnique.Passes)
     device.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, meshPart.NumVertices, meshPart.StartIndex, meshPart.PrimitiveCount);

Here's the shader code:

float4x4 World;
float4x4 ViewProjection;
Texture diffuseTexture;

sampler TextureSampler = sampler_state { texture = <diffuseTexture>; magfilter = LINEAR; minfilter = LINEAR; mipfilter=LINEAR; AddressU = wrap; AddressV = wrap;};

struct TexturedVertexToPixel
    float4 position : POSITION0;
    float2 textureCoords : TEXCOORD0;

TexturedVertexToPixel TextureVertextShader(float4 inPos : POSITION, float2 inTextureCoords : TEXCOORD0)
    TexturedVertexToPixel output;
    float4x4 preWorldViewProjection = mul (World, ViewProjection);
    output.position = mul(inPos, preWorldViewProjection);    
    output.textureCoords = inTextureCoords;

    return output;

float4 TexturePixelShader(TexturedVertexToPixel input) : COLOR0
    return tex2D(TextureSampler, input.textureCoords);

technique Textured
    pass Pass1
        VertexShader = compile vs_2_0 TextureVertextShader();
        PixelShader = compile ps_2_0 TexturePixelShader();

Videos to demonstrate what I mean:

Using the BasicEffect
Using the Custom Shader (see it clearest in 1080p full screen)

Notice the difference when looking at the ground in the distance.

share|improve this question
up vote 0 down vote accepted

I managed to fix the issue by enabling the generation of MipMaps for the texture used by the model. This is done within visual studio by finding the texture in the content project right clicking going to properties and then expanding "Content Processors" and enabling the option "Generate MipMaps"

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.