Checking how many agents are working

How this works
Kontakt
← Blog
A cinematic photograph of a cobblestone ground close up with a repeating but natural pattern running to the horizon, in teal and steel with a warm amber light, the AMARBARO mark and wordmark centered over it.
✎Post blogowy

Textures that repeat without seams

The short version

A texture tiles cleanly when its left edge meets its right edge and its top meets its bottom, and for our image model the most reliable way to get that is to render plainly, roll the picture by half and repaint the center seam.

What this is about

Think of a tiled kitchen floor. One small tile, laid again and again, covers the whole room. A game world does the same with pictures: a small picture of grass, asphalt or brick is repeated across a huge ground. If the picture is made badly, you see a line where each copy meets the next, like a grid drawn across the world.

A texture that avoids this is called seamless or tileable. This article shows how we make them with AI and how we check them.

Why it matters

A texture that does not tile gives the game away. The eye finds repeated lines at once. And it is expensive to paint tiles by hand for every floor and wall. An image model can make many materials fast, but only if the result really tiles.

We needed a set for each material: the color picture, a picture of surface angle (called the normal map) and one for how shiny or rough it is. All three at 2048 by 2048 pixels, made on our own graphics card.

How a seamless texture works

The rule is simple to say: if you put two copies side by side, the right edge of the first must flow into the left edge of the second. The same goes for top and bottom.

The obvious trick, and its price

Image models are built from layers that look at a pixel and its neighbors. At the edge of the picture there are no neighbors, so the layer pads with zeros. A known trick is circular padding: the left edge wraps round and treats the right edge as its neighbor. We wrote ComfyUI nodes that do this inside the model.

It works. The texture truly tiles. But it changed what the model drew. The model has learned that seamless, repeating patterns often look like cracked surfaces. Wet asphalt turned into cracked earth. We tried a split (plain model for the first part of the steps, then the seamless one), and it did not help. Two re-rolls gave the same cracked look, which tells us this is a habit of the model, not a fault of our prompt.

What we do now: render plain, roll, repaint the seam

Mode What it does Verdict
Circular padding edges wrap in every layer tiles, but adds cracks
Rolled latent shifts the working picture same crack shift
Plain normal render right look, but a visible seam
Inpaint seam (our default) render plain, roll the picture by half so the seam sits in the middle, repaint the middle band seamless, no crack bias

Why it works: rolling the picture by half moves the old edges into the center, where they become an ordinary seam in the middle. The model then repaints that band with real context on both sides, so it can blend it. Roll it back and the new edges were never touched.

The upscaler brings the seam back

We make the first picture at 1024 pixels and enlarge to 2048 with an upscaler. That step can bring a seam back even if the picture tiled before. Our fix upscales the picture and a half-rolled copy and uses the rolled pass in a band around the seam. On a gravel texture, this took the seam score from 1.77 to 1.11.

How to check one

You can look at it. Put four copies in a two by two grid and search for lines. We also run a script, texture_check, with three gates:

  • Seam: the difference across the edge divided by the typical difference between neighbors inside the picture. 1.0 means invisible. We fail anything above 1.6.
  • Light: the picture must not carry a baked gradient or a dark corner. We allow a standard deviation of luminance of 0.14 after a heavy blur. A gradient or vignette is 0.2 or more.
  • Normal z: the surface-angle map should mostly point up. We need an average of at least 0.6.

We calibrated the checker on 24 free textures from Poly Haven. 23 passed. The one that failed has a real seam, with a seam score of 2.17. So a FAIL is a real defect. A PASS is necessary and not enough, so we still look.

Prompts that help

  • Start with a fixed look phrase, then a view phrase: "top-down orthographic" for ground, "straight-on frontal" for walls.
  • End with: even density, flat light, pattern continues off every edge.
  • Do not write negations in the positive prompt. "No cracks" can give cracks.
  • Say "flat surface", never "plane".

More on prompts is in Writing picture prompts that work. The full story, with two GPU crashes we hit along the way, is in Seamless textures that really tile, and the crack prior that fought us.

Words you may meet

  • Texture: a picture wrapped onto a surface in a game or 3D scene.
  • Tileable or seamless: repeats with no visible edge.
  • Normal map: a picture that records which way each tiny part of the surface faces.
  • Roughness: how shiny or dull the surface is.
  • Inpainting: repainting a chosen part of a picture.
  • Upscaler: a model that makes a picture larger.

Try it

  1. Make any picture you like and shift it by half its width, wrapping the edge round. Most image editors call this offset. The old edge now runs through the middle. Look at it.
  2. See generated surfaces in use in the 3D shop at aiazic.com. Walk close to a floor and a wall and look for repeating lines. The world has 15 physically based materials of this kind.
  3. Try the offset test from step 1 on one of your own photos of a floor or a wall. Almost every photo shows its edge at once, which is why a tileable texture takes work.

What we do not claim

The seam score and its limits come from our own checker. A crack metric we tried did not tell our circular renders from plain ones, although the eye could, so we dropped it. Our numbers are for one model, RealVisXL, and one set of test textures.

Komentarze

Brak komentarzy.

Zaloguj się aby skomentować.