Traditional texture tiling methods produce visible artifacts at texture boundaries. The diamond pattern texture tiling algorithm presents a solution through overlapping rotated texture samples arranged in a diamond pattern, effectively minimizing these artifacts through strategic sampling and blending.
The algorithm operates on two overlapping grids:
Primary Grid (Corner-Centered)
Secondary Grid (Center-Centered)
For any point
Nearest Corner Position:
Nearest Center Position:
The rotation transformation matrix
$ R(\theta) = \begin{bmatrix} \cos(\theta) & -\sin(\theta) \ \sin(\theta) & \cos(\theta) \end{bmatrix} $
Applied to point
The deterministic random function for position
Final rotation angle:
Distance calculations:
-
$d_C = |P - C|^2$ (squared distance to nearest corner) -
$d_M = |P - M|^2$ (squared distance to nearest center)
Blend factor computation:
where:
-
$offset$ controls the relative influence of center points -
$falloff$ controls the transition sharpness
- Input UV coordinates are normalized to the texture space
- Grid positions are computed using floor and fractional operations
- Distances are calculated using dot products for efficiency
- Calculate rotated coordinates for both grid positions
- Sample texture at both rotated positions
- Blend samples using computed blend factor:
$color_{final} = lerp(color_1, color_2, \beta)$
The algorithm primarily uses:
- Basic vector operations
- Trigonometric functions (sin, cos)
- Two texture samples per fragment
- Simple distance calculations via dot products
-
Corner Artifacts
- Four-way intersections of diamond patterns can show subtle discontinuities
- Severity depends on texture content and parameter selection
-
Computational Cost
- Two texture samples per fragment versus one in simple tiling
- Additional trigonometric operations for rotation
The algorithm is particularly effective for:
- Large-scale terrain texturing
- Procedural texture generation
- Architectural visualization
- Dynamic texture mapping