← Blog
✎blog post

Seamless textures that really tile, and the crack prior that fought us

A cinematic photograph of a close view of wet cobblestone ground receding to the horizon in a repeating but natural pattern, in teal and steel with a warm amber light, the AMARBARO mark and wordmark centred over it.

Circular padding makes textures tile but changes what SDXL draws, so a plain render, a half-roll and a seam-band inpaint is the better default.

The obvious trick for seamless textures makes the texture tile, but it also changes what the model draws. We now use a plainer method, and a checker that catches real seams.

A game ground texture has to tile: the left edge must meet the right edge, and the top must meet the bottom, or you see a grid of lines across the world. We needed matching 2048x2048 color, surface-angle (normal), and roughness textures for each material, generated locally in ComfyUI.

The pipeline

texgen run    RealVisXL at 1024 -> seamless mode -> 4x-UltraSharp upscale -> 2048 PNG
texgen post   height from luminance -> normal map (OpenGL +Y), roughness = inverse darkness
texture_check seam, light and normal gates
texgen install  sets that pass go into the game art folder

RealVisXL is an SDXL model. It is the only SDXL base we have that works with IPAdapter, ControlNet Union and our seamless nodes, so it is our tile engine. Z-Image makes the best pictures but, as you will see, it did not survive the tiling step.

Prompts that SDXL understands

These came from many renders.

  • A fixed look phrase (photo texture, overcast), a view phrase per batch (top-down orthographic for ground, straight-on frontal for walls), the subject, and a tail: even density, flat light, pattern continues off every edge.
  • No negations in the positive prompt. SDXL reads "no cracks" as cracks and "no text" as text. Negatives go in the negative prompt.
  • Say "flat surface", never "plane". "Plane" draws aircraft.
  • Decals are made by Z-Image: "single isolated object, centered, from above, plain mid grey background".

Making it tile: circular padding

A convolution layer looks at its neighbours, and at an image edge it pads with zeros. Configuring image convolutions with circular padding makes the left edge wrap around to sample the right edge, ensuring seamless borders. We wrote ComfyUI nodes (v3 API) to do that on the UNet, the VAE and the upscaler. A second mechanism rolls the latent by a seeded random offset around each model call, which is the only way to do it on a transformer model like Z-Image.

It does produce a texture that truly tiles. It also changed the content. The image model associates seamless repeating patterns with cracked surfaces. Smooth asphalt turned into cracked desert mud.

We tried to cheat. A step split (plain model for the first 60, 75 or 85 % of steps, then seamless) hoped to take content from the plain model and edges from the seamless one. It did not help. Two re-rolls repeated the same look, which says this is a model prior and not a prompt problem, so re-prompting stops.

The mode we kept: inpaint the seam

Mode What it does Verdict
conv circular padding on every conv tiles, but cracks
roll rolled latent same crack shift
off plain render right content, visible seam
inpaint (default) plain render, roll by half to center seam, inpaint middle band seamless, no crack bias

The seam of a plain render ends up in the centre after the half-roll, where inpainting can repaint it with the real context on both sides. Nodes: BaroRollImage, BaroSeamMask and the stock inpaint conditioning.

The upscaler brings the seam back

4x-UltraSharp takes 1024 to 2048, and it reintroduces a seam even with circular padding. BaroSeamlessUpscale upscales the image as is and a half-rolled copy, rolls that back, and takes the rolled pass inside a band of pixels around the seam cross. The gravel seam score went from 1.77 to 1.11.

The checker

texture_check.py has gates:

  • seam: edge to edge difference divided by the mean neighbour difference inside. 1.0 is invisible. We fail above 1.6.
  • light: the standard deviation of luminance after a heavy blur, max 0.14 (a baked gradient or vignette is 0.2 or more).
  • nz: mean decoded normal z at least 0.6.

We calibrated on Poly Haven textures. 23 of 24 pass, and the one that fails (roof_slates_02, seam 2.17) has a real seam. So a FAIL is a real defect and a PASS is necessary, not sufficient. A crack metric we tried did not separate our circular renders from plain ones, though the eye separates them at once, so we dropped it.

Speed on a 2048 set

Warm, RealVisXL 34 steps:

no MIOpen            22 s
MIOpen on            12 s   (+334 s once per new conv shape)
+ seam-band upscale  about 16 s
Lightning 4-step     about 6 s   (draft, 18 % less edge energy)
2 latents in a batch 148 s       (rejected: VRAM thrash)

MIOpen is AMD's convolution library with tuned kernels. It helps textures because the UNet is conv-heavy. Props do not benefit.

We tested four other tuning options on the same workflow. None beat the baseline 23 seconds, so we left defaults alone. The base was 23 s. No winner, no defaults changed.

Two GPU crashes, both with a convolution in them

Z-Image at 2048 with a circular VAE. We tried Z-Image as the tile engine, with a 2048 latent and the circular padding VAE, MIOpen on. The sampler ran its 9 steps, then the VAE decode raised a GPU hang and the server aborted. SDXL at 1024 with the same node and MIOpen had run 20 jobs clean. The cause is not isolated: it could be circular padding, MIOpen's kernel, or VRAM. Rule: no circular VAE decode above 1024.

A memory fault at the upscaler. A metal-surfaces batch faulted right after loading the RRDBNet upscaler, after 5 and then 6 good sets, with MIOpen on. The second time it reset the GPU. Removing a deepcopy in our node did not fix it. Turning MIOpen off gave 6 of 6 clean, so texgen's default is now MIOpen off, at a cost of 22 to 40 s per set. That is the newest note and it replaces the earlier MIOpen-on advice. The sample is small and a bisect run is still to do.

Both failures taught the same runner rule: check the server's process after every arm, and give up after 3 polls of 30 s instead of waiting minutes on a dead port.

A PASS that looked wrong

That metal batch passed texture_check 20 of 20, but looking at it: diamond plate, perforated, tread and corrugated metal came out wrong. Rust-light read as bricks and rust-corrugated as cobbles. SDXL's prior for those words is not metal. The numbers cannot see that. Our plan is to build regular metal patterns procedurally.

Comments

No comments yet.

Log in to comment.