Jump to content
  • Advertisement
Sign in to follow this  
Norman Barrows

Moire' patterns

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm getting issues with moire' patterns from tiled seamless ground textures when large amounts of the ground mesh are visible.

 

My workaround to date has been to use sets of 4 ground texture tiles, and assign each 10 foot ground quad one of four texture tiles at random.  to create the tiles, i create a seamless texture for the first, and the rest are copies of the first with different images in the centers, so the edges still match.  This works ok, but i was wondering if there was another way, such as sampling a single texture at two different scales and offsets and blending the results. 

 

say i have a seamless texture per quad, then blend a second copy of that texture over say 4 quads. that's should cut Moire' in half.     with 3 blends that don't repeat for 100 feet or so,  i might be ok.

 

i'm thinking calculate a second set of UV's based on position, something like:

 

u2 = ((int)(pos.x/10.0f) % 4)*0.25f

v2 = ((int)(pos.z/10.0f) % 4)*0.25f

 

this assumes VS_3_0 supports stuff likes ints and mod - i have yet to find out.

 

what about texture splatting to break things up a bit?

Share this post


Link to post
Share on other sites
Advertisement

Have you enabled mip mapping for the textures?

 

If that's not enough, maybe you can use a better filter for generating the mip maps?

Share this post


Link to post
Share on other sites

VS3 does not support integer operations natively. Some ops can be emulated using floating point math (and the HLSL compiler will strive to do this automatically when it can), but bitwise operations won't generally work.

 

In order to reduce apparent visual repeating of the textures, you should use sufficiently large prime numbers as scale factors of the different layers. This is based on the fact that any given prime is divisible by only 1 and itself; thus, 2 primes as scale factors will never reach the same texture coordinate at any integer interval, except at the origin. If you choose to use this strategy, pick a prime like 29 (not too small, not too large), take the next primes so that the next one is approximately 1.3 to 1.7 times the last one (the precise numbers are not important), and follow this for each additional scale factor you need.

Share this post


Link to post
Share on other sites

Splatting is what you are looking for mate. Build up a nice mask weight each texture visibility properly so you get a consistent blend between them. I used three very different textures (obviously each of them separatedly had a  lot of patterns when tiled lonely). As an addition you can also add a random occlusion factor via a noise texture(blurred in my case worked so nice).

 

i'm thinking calculate a second set of UV's based on position, something like: u2 = ((int)(pos.x/10.0f) % 4)*0.25f v2 = ((int)(pos.z/10.0f) % 4)*0.25f

 

That didnt work to me due to the high identity lose of the textures. Although it contributes reducing the patterns, its true, It produces chaotic results if you are trying to get well defined faithful results.

 

Hope it helps to you!

Share this post


Link to post
Share on other sites
Have you enabled mip mapping for the textures?   If that's not enough, maybe you can use a better filter for generating the mip maps?

 

You know me, all the knobs are already cranked up to 11.  Full mip chain and tri-linear filtering with MAX_ANISOTROPY for non-sprite textures.

 

I'm not getting Moire' in individual textures, its the fact that the same seamless texture is repeated every 10 feet.  if you look out over a hilly area with few plants, you can see for hundreds of feet. and repeating ground tile textures.

 

this render i found online shows what i'm talking about.  note how the green ground texture pattern repeats with every tile. while its seamless, there are repeating patterns.

 

tile.png


 

 

but bitwise operations won't generally work.

 

all I really need is modulo for something that periodically repeats based on location.  odds are i can figure out something using floats.

 

 

 

 

you should use sufficiently large prime numbers as scale factors of the different layers.

 

I suspected primes would be a good candidate.

 

 

 

That didnt work to me due to the high identity lose of the textures.

 

 
 
Blending at different scales messes up your images - i get it.  Yeah, splatting would be the way to go then.  That's why i chose high rez textures over detail texturing. the detail doesn't match the images.
 
I checked into splatting before, but i was getting such good results with my tile sets that i didn't go for it at the time.  But textures were not high-rez, so the fact they were tile sets was not that noticeable.
 
My only concern is that its a seamless world, proceedurally generated, and dynamic. so i can't use anything that requires pre-computed data such as a level map.
 
Time to read up on texture splatting again!
 
Thanks for the tip.
 
If anyone thinks of anything else, please speak up. i often find the common solutions in games are inadequate for my needs, with detail texturing vs exclusive use of true high rez textures being the latest example.  Texture splatting may turn out to be one of those cases, or maybe not. If it can all be done 100% on the fly in realtime, it might work.
Edited by Norman Barrows

Share this post


Link to post
Share on other sites

Instead of assigning each tile one of the images at random, what about using all 4, then having a vertex weight for each.  This will let all 4 tiles surrounding a vertex use the same weight (to prevent seams), but then you randomly distribute the weights per vertex (or use noise, or etc) to break up the look per quad.  The downside though is that you're dnow doing a lot more texture fetches, 4 blended together vs 1 that varies per tile.

 

I just realized you said about texture splatting, which is basically what I'm suggesting.  Instead of using a separate texture for the splat though, you could just use additional vertex data for the blend weights (even just a single RGBA value).

Edited by xycsoscyx

Share this post


Link to post
Share on other sites
Instead of assigning each tile one of the images at random, what about using all 4, then having a vertex weight for each

 

ground mesh quads don't share verts. its just 4 lists (VBs and IBs) of individual quads - one list per texture - not a true planar mesh.   each quad is assigned one of 4 tileable ground textures at random. all quads for a texture go in their own VB and IB. So the entire mesh data for a terrian chunk is spread across 4 VBs of individual quads. trying to get one quad to know about adjacent quads would be a bit of work.

 

 

The downside though is that you're dnow doing a lot more texture fetches, 4 blended together vs 1 that varies per tile.

 

any kind of blending will incur additional lookup overhead.  that's why in general i try to avoid blending when possible.

 

 

This isn't so much about moiré, more about just being able to observe low-frequency changes when you examine a larger period of data

 

precisely.

 

 

What you probably want to do is to remove that low-frequency signal - i.e. eliminate the obvious patches of darker, brighter, or more saturated areas - and add that sort of interest in different ways (eg. splatting, decals, detail textures).

 

mips sort of helps there, but it depends on  the amount of detail in the texture. for example, bland washed out sand looks ok at a distance (but dark).  if i cut brightness and increase contrast in the texture, it amplifies shadows, making the texture really "pop".  sort of like bump mapping.  look down, and its real GD sand!   look up, and its a single tiled texture every 10 feet out to about 100 feet or so when the mipmap detail drops enough to blur things out a bit.

 

sounds like the thing to do is have high and low detail versions of each texture, and use high detail at short range.  LOD texturing you might say.  or perhaps even blend based on zbuf value, similar to detail mapping,  or maybe 1024 for close up, and 256 for far away.  The low rez at loinger ranges might blur things enough to make the repetition less noticeable.

 

in the texture blending article here on gamedev, they mention some things:

 

from:  https://www.gamedev.net/resources/_/technical/game-programming/texture-splatting-in-direct3d-r2238

 

" Each chunk has the base textures repeated several times over it ....    Try to make sure they repeat enough to make detail up close, but not so much that the repetition is obvious from far away."

 

my up close detail is acceptable w/ 10 ft quads and one 1024x1024 texture per quad.     but they repeat 30 times within visual range, and its obvious from far away.

 

So they are assuming i don't have a repetition problem to begin with.   But repetition is the problem i'm trying to solve.

 

They also say:

 

"If texture splatting has a downfall, it is this: when two neighboring splats come together, an unattractive seam forms between them....

 

The one [alpha map] on the left does not know the border values of the one on the right. When the video card performs its linear blend, it has no way of knowing that there is in fact a black texel right next to a white one. It simply assumes the same color is on the border....

 

This is not an easy problem to fix and many games leave it untouched. It can be disguised a little by properly wrapping textures and a skilled level designer, but I have not thought of an elegant solution."

 

 

ok, so maybe restate the problem.

 

Its not Moire' patterns in the textures.

 

its "being able to observe low-frequency changes when you examine a larger period of data"  IE: repeating "so much that the repetition is obvious from far away".

 

what can i do?  high rez and low rez textures, and choose one or blend based on zbuf value?

 

Back to tile sets and interleaved ground meshes?

 

Both?

 

And just how would i go about making a low rez version?  resize to 256x256, then cut contrast?

 

I'm finding a lot of this is part code, part paint program.  cut brightness, increase contrast, increase saturation, tweak hue, decrease saturation, adjust levels, then export to game and set materials in code. "massaging" textures this way REALLY makes a big difference.

 

or resize textures in paint and resize ground quads in code.

 

Being both the artist and coder is giving me insights into how the texture and code interact, and what is best handled where - in the texture, or the code.

 

I suppose LOD texturing is the next thing to try.

 

what if you double the sample period for the texture?  not, you can't do that....

 

you need a lower rez or "blander" texture to sample.

 

change miplevel? can you do that? i think you can with an effect parameter.  force mip level smaller at longer ranges. not sure you can do that though....

 

 

 

 

 

Edited by Norman Barrows

Share this post


Link to post
Share on other sites

mips sort of helps there

 

Mip-mapping is there to fix aliasing of high frequency data. Your problem is being able to spot low frequency data when you zoom out far enough.

 

what can i do? high rez and low rez textures

 

I don't think resolution is an issue; you just need to remove the low frequency information from the texture. If it then looks too boring, that's a different problem. Some suggestions include (copy-pasted from the Unity Answers site, since this is a common problem):

  • Blend with a detail texture (or bump map, or normal map) that repeats at a different rate.

  • Use decals, texture splats, props, and lights to break it up visually.

  • Use vertex coloring or vertex blending with an alternate texture, hand painted or at some pattern that repeats at a different rate

  • Have multiple textures that match all edges and procedurally map a random one to the UV space for each tile.

Share this post


Link to post
Share on other sites
Blend with a detail texture (or bump map, or normal map) that repeats at a different rate.

 

i ended up blending it with itself! <g>. a single 1024 tex, one per quad, and one per 3x3 quads.  

 

in the vertex shader:

Output.pos2=mul(vPos,g_mWorld);
 
in the pixel shader:
float2 a;
a.x=fmod(In.pos2.x,30.0f)/30.0f;
a.y=fmod(In.pos2.z,30.0f)/30.0f;
Output.RGBColor = tex2D(MeshTextureSampler,In.TextureUV)*tex2D(MeshTextureSampler,a)*In.Diffuse*3.0f;
 
that *3.0f is a fudge factor until i get the lighting right.
 
Works great. Can only notice a little repetition in 3pv zoomed all the way out (2-3x as far as you can zoom out in your typical game).
 

 

Use decals, texture splats, props, and lights to break it up visually.
 
Its really only a problem in scrub lands and rocky deserts where its basically a whole lot of nothing <g>.  i think what i'll do is use the shader with the double blended texture just for SCRUB and DIRT coverage types, and use fixed function for the rest. The repetition in SAND actually is nice.  makes it look like an endless sea of wavy sand dunes.   I also noticed double blending can blur fine detail, such as grains of sand or blades of grass. But it works ok for small stones or anything bigger.  so a single high rez texture, with double blending for rocky ground textures. and if they see a little bit of repeating patterns in 3pv zoomed out 50 feet, so be it. I see them in Skyrim all the time.
 

 

Have multiple textures that match all edges and procedurally map a random one to the UV space for each tile
 
that's what i used to do.  actually i still do, but each of the 4 textures is set to the same high rez texture right now. i could always whip up a new set of 4 textures. there are only 7 or so types of ground textures in the game.
 
between double sampling the texture at different rates, and using the texture tile sets, i think i can call this problem solved.
 
Thanks all!
Edited by Norman Barrows

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!