# Help with terrain rendering

This topic is 3612 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

HI, Im having some problems with the way my terrain is rendering, it pretty much looks awful. I have based the whole engine around 1 unit being one meter, so that when i gather textures, and can recreate them to the correct ratio. For the terrain below, it consists of a plane 255x255, with each cell, being scaled by 10, such that a square face is 10x10 units, with the map being 2550x2550 in actual size. Thus i have scaled each face to wrap the UVS round 10 times. And this all looks great when you're looking straight down, but the terrain viewed from afar ends up being solid green, and not only that, the seamlessness seems to also disappear when you're viewing from afar, i seem to get horrible bandings, even though the texture is seamless. I gather that the solid green effect is being produced because of the mipmap level being used will probably end up being 2x2 or 4x4 or something, so i thought about having my shader set so that it doesnt use anything below 64x64 or something of that nature, but the only command i can find is to set the maximum mip not the minimum map.
MaxMipLevel[16]	int	Same values as D3DSAMP_MAXMIPLEVEL without the D3DSAMP_ prefix.

why is the banding occurring?

##### Share on other sites
Quote:
 Original post by wforlwhy is the banding occurring?

Looking at the snapshot, I'd have to say that it's simply due to the fact that you have repeating details which are more obvious with such a high repeat frequency.

Even fully seamless textures can exhibit banding because by definition they just repeat the same patterns. You will see the same effect in Paintshop if you tile the texture like 10 times and resize so it all fits on the screen so you can see it.

You're not doing anything wrong, per se, though you could probably make use of a detail texture that's tiled at a different frequency to break things up a bit.

##### Share on other sites
Its difficult to get individual textures that don't show some of this phenomenon.

Almost every terrain implementation uses some multitexturing method to improve the look of the terrain at distances.

Try this very easy solution: sample each texture twice, at two scales, one fairly large, and one the normal, up-close scale. Then just lerp between them using some normalized distance value (between 1-0). This will elminate both banding and the ugly solid-color thing.

Of course a number of other solutions exist, such as using a large macrotexture and then using detail textures as mentioned above, but that doesn't preclude using my method.

Also try using larger, more carefully designed textures. Try to eliminate any pattern that will appear too strongly in tiling. That doesnt mean you cant have reasonably bold variation within a texture but it must have a certain kind of randomness to it. Its takes some trial and error here.

Using perlin noise to create a faint detail texture over the whole terrain can also help to avoid the tiling problems.

NOTE: an easy way to control the mipmap levels is to use mipmaplodbias; this is a sampler state. Also, you can sample in the pixel shader using tex2DLOD to explicitly set the mipmap level or even better tex2Dbias (this ought to get around annoying poeple who change the bias setting in the driver).

##### Share on other sites

The textures im using are actually from existing games, 512x512.

Quote:
 Try this very easy solution: sample each texture twice, at two scales, one fairly large, and one the normal, up-close scale.

when you say this, do you mean sample one at say Mipmap 0, and then the other at mipmap 11, and them mix them, based on some experimental ratio?

##### Share on other sites
Quote:
Original post by wforl

The textures im using are actually from existing games, 512x512.

Quote:
 Try this very easy solution: sample each texture twice, at two scales, one fairly large, and one the normal, up-close scale.

when you say this, do you mean sample one at say Mipmap 0, and then the other at mipmap 11, and them mix them, based on some experimental ratio?

No. When you sample a texture you obviously scale it by some factor to set how many times it repeats....well, do something like this:

float4 texsmall = tex2D(texture,texcoord.xy*50);// for the base tile
float4 texbig = tex2D(texture,texcoord.xy*10);// for the distant tile

then:

float dist=saturate(In.dist*0.00005);//where In.dist is length(worldpos-viewpos)
finalcolor= lerp(texsmall,texbig,dist);

obviously you will have to play around with the numbers...

1. 1
Rutin
27
2. 2
3. 3
4. 4
5. 5

• 11
• 11
• 10
• 13
• 20
• ### Forum Statistics

• Total Topics
632948
• Total Posts
3009399
• ### Who's Online (See full list)

There are no registered users currently online

×