XNA Creators Club Online
Page 1 of 1 (8 items)
Sort Posts: Previous Next

Getting rid of texture patterns on terrain.

Last post 09-19-2008 11:27 AM by Maerius. 7 replies.
  • 05-17-2008 5:35 AM

    Getting rid of texture patterns on terrain.

    Hi.
    I have a terrain system that uses multiple textures. But as many people have experienced, texture patterns often occur when one texture is spread over a large area. If you look at the screenshot from my game, you will see that the grass texture generates a pattern (almost like a carpet).




    How can i make these patterns disappear? I have tried gently applying another texture on top of the grass, so you would have a smooth blend between the two textures, which would create com nuances. But this was very time consuming, and the result did not look good.

    Thanks
  • 05-18-2008 7:17 AM In reply to

    Re: Getting rid of texture patterns on terrain.

    This pattern appears because you are mirroring the texture in the U and V directions as it is being wrapped. You might get an acceptable result by turning off mirroring and just having the texture repeat normally. However, you might still get a visible seam at the edge of the texture. The main reason this sort of pattern becomes visible is because the texture is not uniform. It has darker regions near the edge and lighter colors in the center. You might be able to do some surgery on the texture with an image editing tool to even it out.

    Often it seems easiest to use a photograph for a texture, such as a photograph of some grass, but this sort of irregularity is common with photographs. While it is more labor intensive, you can often get a better result by creating your texture with special texture tools such as Texture Maker (http://www.texturemaker.com/videos.php) or Allegorithmic MapZone (http://creators.xna.com/Resources/Partners.aspx). I imagine this could be done with PhotoShop as well. With tools like these you could, for example, create your grass texture by creating several stamp brushes where each stamp brush is an image of an individual blade of grass. You would then randomly stamp these blades of grass into your new, blank texture image, and each successive stamp would overlap any previous stamps. Also, whenever you stamp at the edge of the texture, any part of the stamp which falls outside of the boundary of the texture would be automatically wrapped and stamped to the other side of the texture. This makes the texture seamless when you are using it as a repeating texture in your scene. Another thing is that when you use larger textures (wider and taller), the texture does not repeat as frequently in your scene, which helps to prevent the user from noticing a repeating pattern.

  • 05-18-2008 3:58 PM In reply to

    Re: Getting rid of texture patterns on terrain.

    This pattern appears because you are mirroring the texture in the U and V directions as it is being wrapped.

    Actually, the main problem is that there are noticeable differences between different areas of the texture. Either you could simplify the texture by evening out the saturation and luminosity of the texture, or you could create a much bigger texture. Try extending the texture you have to 2048x2048, and spreading each tile over a larger area, which will make the variation less obvious.

    More advanced methods include creating many variations of the same texture, that each tile with each other, and selecting a random variation for each tile. Even more advanced methods include allowing painting of arbitrary images anywhere on the level, a la "Megatexture," and paging in the necessary resolution of each texture on demand. That requires more data than you can fit in an XNA download, though, and requires custom tools development.

    Jon Watte, Direct3D MVP kW X-port 3ds Max .X exporter kW Animation source code
  • 05-19-2008 12:49 PM In reply to

    Re: Getting rid of texture patterns on terrain.

    You can also use multitexturing to obscure the repeated patterns. Have several different textures (I would typically use three layers, one very fine detail, one like you have in the screenshot above, and one very coarse lumpy one) tiling with different frequencies (make sure these frequencies are not multiples of each other, in order to avoid the different repetitions ever falling into phase!) and modulate all the textures together in your shader (multiplying usually works well, as long as you have color in only one of your texture layers and keep the others monochrome).

    I would also second the previous point about using a properly wrapping texture image rather than mirroring. Mirroring is a quick and easy way to make an image tile without seams, but it creates patterns that tend to be pretty obvious.

    Finally, the high pass filter tool found in many paint programs is a great way to remove low frequency patterns from tiled terrain textures.
    XNA Framework Developer - blog - homepage
  • 06-12-2008 5:25 PM In reply to

    Re: Getting rid of texture patterns on terrain.

    And, since Shawn is too modest to plug his own blog, have a look at his blog entry here. It might give you some guidance on cleaning up the texture for tiling.

     

  • 08-20-2008 10:56 AM In reply to

    Re: Getting rid of texture patterns on terrain.

    Genetica takes care of these issues for you.  It generates seamless textures.
  • 08-20-2008 9:07 PM In reply to

    Re: Getting rid of texture patterns on terrain.

    I don't have anything helpful to add, steffanp, but I just wanted to say that your screenshot looks really really good (despite the pattern).  That's excellent work.
  • 09-19-2008 11:27 AM In reply to

    Re: Getting rid of texture patterns on terrain.

    Hi.

    @steffanp: Please, take a look at the picture below:

    Image Hosted by ImageShack.us

     

    This is an example of an usage of very simple and old technique called texture splating. It was commonly used in variety of 3D games. I used Pudget Sound as a height map and ground map. Four pattern textures and a blend map are borrowed from Caesar IV, which uses this technique. You can freely add more than four layers by multipassing; NWN2 uses 6 layers. To drastically increase the overall atractiveness of this terrain one could increase the ground map resolution (e.g. 16k x 16k) read in chunks in diffrent LOD and applying commonly fasionable toroidal update.

     This is the piece of HLSL which determines drawn colors drawn:

    // ... 
     
    // These are global, no matter the instancing: 
    texture GroundMap; 
    texture BlendMap; 
    texture BlendRedComponentTexture; 
    texture BlendGreenComponentTexture; 
    texture BlendBlueComponentTexture; 
    texture BlendAlphaComponentTexture; 
    float DetailTextureCoordsMultiplier; 
     
    // ... 
     
    float4 PixelShader(OutputVertex input) : COLOR 
        float3 baseColor = tex2D(GroundMapSampler, input.TextureCoords); 
         
        float2 detailTextureCoords = input.TextureCoords * DetailTextureCoordsMultiplier; 
        float4 blendFactors = tex2D(BlendMapSampler, input.TextureCoords); 
        float3 finalColor = baseColor * 
            (blendFactors.r * tex2D(BlendRedComponentTextureSampler, detailTextureCoords) + 
            blendFactors.g * tex2D(BlendGreenComponentTextureSampler, detailTextureCoords) + 
            blendFactors.b * tex2D(BlendBlueComponentTextureSampler, detailTextureCoords) + 
            blendFactors.a * tex2D(BlendAlphaComponentTextureSampler, detailTextureCoords)); 
     
        // Apply the lightning... 
     
        return float4(finalColor, 1.0f); 
     
    // ... 

     

    PS Your work looks cool.
    PPS My english sucks lately.
Page 1 of 1 (8 items) Previous Next