createCanvas(1280, 720, WEBGL)
seatShader = baseMaterialShader().modify({
vertexDeclarations: 'out vec3 pos;',
return fract(sin(dot(n, vec2(12.9898, 4.1414))) * 43758.5453);
float rand(float n){return fract(sin(n) * 43758.5453123);}
return mix(rand(fl), rand(fl + 1.0), fc);
const vec2 d = vec2(0.0, 1.0);
vec2 b = floor(n), f = smoothstep(vec2(0.0), vec2(1.0), fract(n));
return mix(mix(rand(b), rand(b + d.yx), f.x), mix(rand(b + d.xy), rand(b + d.yy), f.x), f.y);
'int style': () => floor(millis() / 2000) % 3,
'vec3 getLocalPosition': `(vec3 position) {
'Inputs getPixelInputs': `(Inputs inputs) {
float t = fract(pos.z * 0.004);
inputs.ambientLight += 0.3 *
smoothstep(-90., -20., pos.x) *
(1. - smoothstep(140., 150., pos.x)) *
(1. - smoothstep(0.8, 0.9, t));
p.x += 10. * sin(p.z * 0.5 + p.y * 0.8);
inputs.color.xyz *= sin(p.x * 0.2 + p.y * 0.5)*0.5 + 0.5;
vec3 cell = floor(pos*0.1)/0.1;
inputs.color.xyz *= length(pos - cell)/10.;
inputs.color.xyz *= pow(noise(pos.xy * 0.2) * noise(pos.xz * 0.3), 0.5);
// inputs.ambientMaterial = inputs.color.xyz;
directionalLight(50, 50, 50, 0, 1, 0)
directionalLight(100, 100, 100, 1, 1, 0)
directionalLight(100, 100, 100, -1, 1, 0)
const xOff = (t*0.1)%1000
const iOff = floor(t*0.1/1000)
camera(-100, -150, xOff, 500, 400, 700+xOff)
translate(0, 0, 1000 * (numCars - 1))
for (let i = 0; i < numCars; i++) {
rotateY(PI*0.0002*sin(((t*0.001) % 1000)/1000 * TWO_PI))