ants/src/scenes/WorldBlurScene.ts
Jared Miller d91b5a9b5e
Block pheromone diffusion through solid materials
Checks each blur neighbor's material behavior before including it in
the average. Solid and non-gas cells are excluded so pheromones don't
bleed through walls, sand, or rock.
2026-03-11 16:36:22 -04:00

41 lines
1.3 KiB
TypeScript

import * as THREE from "three";
import type Renderer from "../Renderer";
import fragmentShader from "../shaders/worldBlur.frag";
import vertexShader from "../shaders/worldBlur.vert";
import FullScreenTriangleGeometry from "../utils/FullScreenTriangleGeometry";
import AbstractScene from "./AbstractScene";
export default class WorldBlurScene extends AbstractScene {
public readonly camera: THREE.OrthographicCamera =
new THREE.OrthographicCamera();
public readonly material: THREE.RawShaderMaterial;
constructor(renderer: Renderer) {
super(renderer);
const geometry = new FullScreenTriangleGeometry();
const material = new THREE.RawShaderMaterial({
uniforms: {
tWorld: { value: null },
uMaterialProps: { value: null },
},
vertexShader,
fragmentShader,
defines: this.renderer.getCommonMaterialDefines(),
glslVersion: THREE.GLSL3,
});
const mesh = new THREE.Mesh(geometry, material);
this.add(mesh);
this.material = material;
}
public recompileMaterials() {
this.material.defines = this.renderer.getCommonMaterialDefines();
this.material.needsUpdate = true;
}
public resize(_width: number, _height: number) {}
public update() {}
}