A scrolling energy, fire or distortion shader repeats its noise texture, and if the right edge does not continue into the left edge, a line runs across the effect where they meet. It is hard to see in the texture itself and easy to see when it moves. The script below measures it: how much the pixels change across the edge where the texture repeats, divided by how much they change between neighbours inside it. In our Godot 4.7 test a NoiseTexture2D with seamless off scored 9.46 left to right and 7.23 top to bottom, and 28 to 34 at a lower frequency. With seamless on: 0.93 and 1.01. A square cut out of the middle of a bigger noise image, a common way to make one by hand, scored 11.17.
The code
Save it as seam_check.gd and load it with const Seam := preload("res://seam_check.gd"). Then print(Seam.check(preload("res://textures/energy_noise.png"))) prints two numbers, left_right and top_bottom. Near 1 means the edges continue like the rest of the texture. Several times higher means a seam. For a NoiseTexture2D, wait for its changed signal before checking, because the image is made in the background.
extends RefCounted
## Check whether a texture repeats without a seam. It compares the pixels that meet when the
## texture repeats (last column with the first, last row with the first) with neighbouring
## pixels inside the texture.
## const Seam := preload("res://seam_check.gd")
## print(Seam.check(preload("res://textures/energy_noise.png")))
## A ratio near 1 repeats cleanly. Well above 1, a line shows where the texture repeats or scrolls.
static func check(tex: Texture2D) -> Dictionary:
var img := tex.get_image()
if img.is_compressed():
img.decompress()
var w := img.get_width()
var h := img.get_height()
var inside := 0.0
for y in h:
for x in range(w - 1):
inside += _diff(img.get_pixel(x, y), img.get_pixel(x + 1, y))
var step := inside / float(h * (w - 1)) # the usual change from one pixel to the next
var across_x := 0.0
for y in h:
across_x += _diff(img.get_pixel(w - 1, y), img.get_pixel(0, y))
var across_y := 0.0
for x in w:
across_y += _diff(img.get_pixel(x, h - 1), img.get_pixel(x, 0))
return {
"left_right": snappedf(across_x / h / maxf(step, 0.00001), 0.01),
"top_bottom": snappedf(across_y / w / maxf(step, 0.00001), 0.01),
}
static func _diff(a: Color, b: Color) -> float:
return (absf(a.r - b.r) + absf(a.g - b.g) + absf(a.b - b.b)) / 3.0
What we measured
NoiseTexture2D, 256 by 256, FastNoiseLite seed 7, checked with the script. Two runs gave the same numbers.
- Seamless off, frequency 0.02: left_right 9.46, top_bottom 7.23.
- Seamless on: 0.93 and 1.01. With the blend skirt at 0.02 instead of 0.1: 0.90 and 0.98.
- Frequency 0.005, larger shapes: seamless off 28.36 and 34.46, seamless on 0.84 and 0.63.
- A 256 px square cut from the middle of a 512 px noise image: 11.17 and 9.81.
- A flat grey texture: 0 and 0, since nothing changes anywhere.
Why it happens
When a texture repeats, its last column is drawn right next to its first. Noise is smooth from one pixel to the next, but the two edges of a normal noise image come from places far apart in the noise, so they do not match. The smoother the noise, the smaller the change between neighbours and the more the jump at the edge stands out, which is why the lower frequency scored higher. With seamless on, Godot makes the noise wrap around so the edges meet. Cutting a square from a bigger image does not help, its edges still come from different places.
What to change
- Run the check on every noise you scroll, once, while you build the effect. It reads every pixel, so do not run it every frame.
- The seam can also come from the shader instead: texture repeat left off and a scroll that jumps every hour.
Ready-made textures that tile: 60 VFX Textures has 20 seamless noise textures to scroll for energy, dissolves and distortion, plus 26 shape masks and 14 flipbooks.
Tested in Godot 4.7 with the Compatibility renderer.
Ready-made: 60 VFX Textures has 20 seamless noise textures to scroll for energy, dissolves and distortion, plus 26 shape masks and 14 flipbooks.
More how-tos: Shaders, materials and lights
- A 3D outline that stays the same width on screen
- PS1 vertex wobble that is the same near and far
- Snow that stays on the roofs
- Packed ORM maps on a StandardMaterial3D
- Neon signs that share a material but not a colour
- A MatCap that stays the right way up from every side
- Scroll or tile a 2D texture without stretched edge lines
- Keep floors, roads and roofs sharp when the camera looks along them
- Make WorldEnvironment color grading apply to a 2D game
- Get a hard cel-shaded light edge from StandardMaterial3D's Toon mode
- Make metallic materials stop looking black or flat
- Make a glowing sign or screen actually light the wall around it
- Use a LUT strip for color grading in Godot 4
- Tiling textures that keep their size on any mesh
- A sharp low-resolution PS1 look
- Only 8 lights show on a long wall in Compatibility
- Hit flash shader for 2D sprites
- Flash a 3D enemy white when it takes a hit
- Dissolve shader for 3D models
- 2D outline shader that is not cut off
- 3D outline shader without gaps at the corners
- A force field shield with a hit ripple
- Normal map inverted: DirectX vs OpenGL
- Full-screen post-process shader in 3D
- Scroll a shader texture for hours without the once-an-hour jump