ants/src/shaders/world.frag
Jared Miller e210ebc72d
Update world shader to use material IDs
Replace bit-packed cell flags in the R channel with a direct material ID float pass-through. Food clearing now writes MAT_AIR instead of clearing a bit.
2026-03-11 14:01:33 -04:00

26 lines
708 B
GLSL

precision highp float;
precision highp int;
in vec2 vUv;
out vec4 FragColor;
uniform sampler2D tLastState;
uniform sampler2D tDiscreteAnts;
void main() {
vec4 lastState = texture(tLastState, vUv);
vec4 discreteAnts = texture(tDiscreteAnts, vUv);
float materialId = lastState.x;
float scentToHome = min(SCENT_MAX_PER_CELL, lastState.y + discreteAnts.x);
float scentToFood = min(SCENT_MAX_PER_CELL, lastState.z + discreteAnts.y);
float repellent = min(REPELLENT_MAX_PER_CELL, lastState.w);
// ant picked up food from this cell
if (discreteAnts.z == 1.) {
materialId = float(MAT_AIR);
}
FragColor = vec4(materialId, scentToHome, scentToFood, repellent);
}