Agent Harness
Публичная копия обвязки агентной разработки: гейты, journeys, скиллы и шаблоны. Без ключей и личных данных.
Публичная копия обвязки агентной разработки: гейты, journeys, скиллы и шаблоны. Без ключей и личных данных.
import * as THREE from 'three';
import { FullscreenQuad, rawPass } from '../engine/fullscreen.js';
import { U } from './common.js';
// Procedural noise, baked on the GPU at load (no assets):
// noise3D N^3 RGBA8, tileable on all axes. r = Perlin-Worley fbm (Schneider 2015: Perlin fbm
// dilated by Worley fbm), g/b/a = inverted Worley F1 fbm at base frequencies 2/4/8.
// curl3D 64^3 RGBA8, tileable. rgb = curl * 0.5 + 0.5 of a 3-field gradient-noise vector
// potential (Bridson et al. 2007), divergence-free by construction.
// blackbody 256x1 RGBA16F, CPU: Planck x Wyman-Sloan-Shirley 2013 CIE fit -> linear sRGB, Y = 1.
// Sampling contract: NOISE_GLSL in common.js.
const HASH = /* glsl */`
precision highp float;
precision highp int;
in vec2 vUv;
uniform float uZ;
// always 1. Loop bounds read it so ANGLE's D3D compiler (FXC) can't unroll the 27-cell
// searches into megabytes of HLSL: unrolled, these two bakes spend ~300 ms compiling.
uniform int uOne;
out vec4 outColor;
// pcg3d (Jarzynski & Olano 2020): cheap and free of lattice artefacts
uvec3 pcg3d(uvec3 v) {
v = v * 1664525u + 1013904223u;
v.x += v.y * v.z; v.y += v.z * v.x; v.z += v.x * v.y;
v ^= v >> 16u;
v.x += v.y * v.z; v.y += v.z * v.x; v.z += v.x * v.y;
return v;
}
// lattice point -> hash, wrapped at period P so every octave tiles the unit cube. c is always
// within one period of [0, P), so a select replaces two integer modulos per component.
uvec3 hashL(ivec3 c, int P, uint seed) {
c += P * (ivec3(lessThan(c, ivec3(0))) - ivec3(greaterThanEqual(c, ivec3(P))));
return pcg3d(uvec3(c) + seed * uvec3(0x9E3779B9u, 0x85EBCA6Bu, 0xC2B2AE35u));
}
vec3 hash3(ivec3 c, int P, uint seed) { return vec3(hashL(c, P, seed) >> 8u) * (1.0 / 16777216.0); }
// inverted Worley F1: 1 at feature points, ~0 on cell borders. x in cells (= p * P)
float worley(vec3 x, int P, uint seed) {
ivec3 i = ivec3(floor(x));
vec3 f = fract(x);
float d = 8.0;
for (int z = -uOne; z <= uOne; z++) for (int y = -uOne; y <= uOne; y++) for (int k = -uOne; k <= uOne; k++) {
ivec3 o = ivec3(k, y, z);
vec3 r = vec3(o) + hash3(i + o, P, seed) - f;
d = min(d, dot(r, r));
}
return 1.0 - clamp(sqrt(d), 0.0, 1.0);
}
// quintic gradient noise, ~[-1, 1]; corners in a loop (one inlined hash instead of eight)
float gnoise(vec3 x, int P, uint seed) {
ivec3 i = ivec3(floor(x));
vec3 f = fract(x), u = f * f * f * (f * (f * 6.0 - 15.0) + 10.0);
float v = 0.0;
for (int c = 0; c < 8 * uOne; c++) {
ivec3 o = ivec3(c & 1, (c >> 1) & 1, c >> 2);
vec3 s = mix(1.0 - u, u, vec3(o));
v += s.x * s.y * s.z * dot(hash3(i + o, P, seed) * 2.0 - 1.0, f - vec3(o));
}
return v;
}
// gradients (d/dx) of three independent gradient-noise fields at once, as mat3 columns. One
// hash per corner carries all three gradients (10 bits per component).
mat3 gnoiseGrad3(vec3 x, int P, uint seed) {
ivec3 i = ivec3(floor(x));
vec3 f = fract(x), u = f * f * f * (f * (f * 6.0 - 15.0) + 10.0), du = 30.0 * f * f * (f * (f - 2.0) + 1.0);
mat3 J = mat3(0.0);
for (int c = 0; c < 8 * uOne; c++) {
ivec3 o = ivec3(c & 1, (c >> 1) & 1, c >> 2);
vec3 fo = f - vec3(o), s = mix(1.0 - u, u, vec3(o)), ds = mix(-du, du, vec3(o));
float w = s.x * s.y * s.z;
vec3 dw = vec3(ds.x * s.y * s.z, s.x * ds.y * s.z, s.x * s.y * ds.z);
uvec3 h = hashL(i + o, P, seed);
vec3 g0 = vec3((h >> 22u) & 1023u) / 511.5 - 1.0, g1 = vec3((h >> 12u) & 1023u) / 511.5 - 1.0, g2 = vec3((h >> 2u) & 1023u) / 511.5 - 1.0;
J[0] += w * g0 + dot(g0, fo) * dw;
J[1] += w * g1 + dot(g1, fo) * dw;
J[2] += w * g2 + dot(g2, fo) * dw;
}
return J;
}
keys k k
mat frag keys
quad mat
rendererquad bakeCam
quad
bakeCam
rt size size size
rt
mat quad
gl renderer px
t0
z z size z
mat z size
rendererrt z
rendererquad bakeCam
z gl gl gl px rt t0
gl gl gl px
rt t0 rt
mat
rt
cmf
t x mu x mu s1 s2 t t
i i i
l i
cmfi l l l
cmfi l l
cmfi l l
c2
i i i
l i
b l c2 l kelvin
b cmfi b cmfi b cmfi
r
g
b
lum r g b
outo r lum outo g lum outo b lum
bbLUT
u
i i i i bbLUT i
kelvin outColor
u kelvin
x u
i x t x i a i b a
outColorbbLUTa bbLUTb bbLUTa t bbLUTa bbLUTb bbLUTa t
bbLUTa bbLUTb bbLUTa t
data
i i i
c c c datai c bbLUTi c
datai
tex data
tex tex
tex
tex
ok msg
c
w c
w w
o
o o o o
prev
i i i
r bbLUTi g bbLUTi b bbLUTi
r g b
hue b r
hue prev
prev hue
t0
prevTarget renderer
noisePass renderer
curlPass renderer
noise renderer noisePass noiseSize
curl renderer curlPass
blackbody
rendererprevTarget
ms t0
noise
curl
blackbody
noise curl blackbody ms noise curl