Seamless procedural PBR textures: WebGL2 & Godot 4

1. How 4-tap C1 toroidal blending eliminates tile seams

Cropping a procedural raymarched slab directly produces hard discontinuities when wrapped with RepeatWrapping because Voronoi stone cells, brushed metal grooves, and lighting gradients do not match across opposite borders. PixelFx Shader Studio solves this on the GPU by sampling four half-period phase offsets on the torus T^2 = R^2 / Z^2 weighted by raised-cosine windows whose value and first derivative both vanish on each tap’s wrap line:

// q in [0, 1)^2; wx = 0 at q.x = 0, and (1 - wx) = 0 at q.x = 0.5
float wx = 0.5 - 0.5 * cos(6.28318530718 * q.x);
float wy = 0.5 - 0.5 * cos(6.28318530718 * q.y);

vec3 c00 = sampleMacroCrop(fract(q));
vec3 c10 = sampleMacroCrop(fract(q + vec2(0.5, 0.0)));
vec3 c01 = sampleMacroCrop(fract(q + vec2(0.0, 0.5)));
vec3 c11 = sampleMacroCrop(fract(q + vec2(0.5, 0.5)));

float w00 = wx * wy, w10 = (1.0 - wx) * wy;
float w01 = wx * (1.0 - wy), w11 = (1.0 - wx) * (1.0 - wy);
vec3 mean = 0.25 * (
  sampleMacroCrop(vec2(0.25, 0.25)) +
  sampleMacroCrop(vec2(0.75, 0.25)) +
  sampleMacroCrop(vec2(0.25, 0.75)) +
  sampleMacroCrop(vec2(0.75, 0.75))
);
vec3 lin  = c00 * w00 + c10 * w10 + c01 * w01 + c11 * w11;
float invVar = inversesqrt(w00*w00 + w10*w10 + w01*w01 + w11*w11);
vec3 seamless = mix(lin, mean + (lin - mean) * invVar, 0.55);

The variance-preserving normalization factor invVar restores crisp aggregate, yarn, and metal grain across the 0.25 equal-weight overlap zones so tiled dungeon walls and armor plates never look blurry.

2. Multi-map PBR baking workflow (Albedo + Height/Roughness)

You can bake aligned 1024×1024 or 2048×2048 texture maps from the same procedural frame by pausing animation and switching the studio’s Lighting selector between exports:

Target PBR slot Studio Camera Studio Lighting Engine color space
Base Color / Albedo 2.5x Macro Hero Lit (0) sRGB (source_color / SRGBColorSpace)
Height / Roughness mask 2.5x Macro Neutral Height (1) Linear (hint_default_white / NoColorSpace)
Cavity / Micro-relief 2.5x Macro Grazing Relief (2) Linear multiply AO

3. Importing baked PNG tiles in Godot 4 & Three.js

Test your tile density live in the browser at 2×2 or 4×4 UV tiling on studies like Radial Brushed Aluminum, Dry-Stone Rubble Wall, Deep Ocean Water Swell, or Cooling Magma & Ember Cracks, then apply anisotropic mipmaps in your engine so grazing floor angles stay shimmer-free:

import * as THREE from 'three';

const loader = new THREE.TextureLoader();
const albedo = loader.load('/textures/dry-stone-rubble-wall-seamless-1024.png');
albedo.colorSpace = THREE.SRGBColorSpace;
albedo.wrapS = THREE.RepeatWrapping;
albedo.wrapT = THREE.RepeatWrapping;
albedo.anisotropy = 8;
albedo.repeat.set(4, 4);

const heightRough = loader.load('/textures/dry-stone-rubble-wall-height-1024.png');
heightRough.colorSpace = THREE.NoColorSpace;
heightRough.wrapS = THREE.RepeatWrapping;
heightRough.wrapT = THREE.RepeatWrapping;
heightRough.repeat.set(4, 4);

In Godot 4’s Import dock, keep Mipmaps -> Generate enabled, set StandardMaterial3D -> Sampling -> Filter to Linear Mipmap Anisotropic, and adjust UV1 -> Scale to tile across large architectural meshes.

Open the 108 WebGL2 Shader Studio · All engine & VFX guides