Skip to content

Instantly share code, notes, and snippets.

var resize = {
time: 0,
delay: 300,
handled: true
}
var circleDiameter;
function setup() {
let s = min(window.innerWidth, window.innerHeight);
//
// Handles browser window resizing, with a delay to avoid constant resizes
//
var resize = {
time: 0,
delay: 300,
handled: true
}
// Reset
#pragma kernel ResetTextureKernel
#pragma kernel ResetAgentsKernel
// Step
#pragma kernel MoveAgentsKernel
#pragma kernel WriteTrailsKernel
#pragma kernel DiffuseTextureKernel
// Render
// Reset
#pragma kernel ResetTextureKernel
#pragma kernel ResetAgentsKernel
// Step
#pragma kernel MoveAgentsKernel
#pragma kernel WriteTrailsKernel
// Render
#pragma kernel AgentsDebugKernel
neighborhood0 = new Vector4[] {
new Vector4(-1,-14), new Vector4(0,-14), new Vector4(1, -14),
new Vector4(-4,-13), new Vector4(-3,-13), new Vector4(-2, -13), new Vector4(2,-13), new Vector4(3,-13), new Vector4(4, -13),
new Vector4(-6,-12), new Vector4(-5,-12), new Vector4(5, -12), new Vector4(6, -12),
new Vector4(-8,-11), new Vector4(-7,-11), new Vector4(7, -11), new Vector4(8, -11),
new Vector4(-9, -10), new Vector4(9, -10), new Vector4(-1,-10), new Vector4(0,-10), new Vector4(1, -10),
new Vector4(-10, -9), new Vector4(10, -9), new Vector4(-4,-9), new Vector4(-3,-9), new Vector4(-2, -9), new Vector4(2,-9), new Vector4(3,-9), new Vector4(4, -9),
new Vector4(-11, -8), new Vector4(11, -8), new Vector4(-6,-8), new Vector4(-5,-8), new Vector4(5, -8), new Vector4(6, -8),
new Vector4(-11, -7), new Vector4(-6, -7), new Vector4(-2, -7), new Vector4(-1, -7), new Vector4(-0, -7), new Vector4(1, -7), new Vector4(2, -7), new Vector4(11, -7), new Vector4(6, -7),
ne
[numthreads(1, 1, 1)]
void StepKernel(uint3 id: SV_DispatchThreadID)
{
// READ STATE
uint state = readTex[id.xy];
uint count0 = 0;
uint count1 = 0;
uint count2 = 0;