From e210ebc72da0e38b387e822e8949069f2b9106e9 Mon Sep 17 00:00:00 2001 From: Jared Miller Date: Wed, 11 Mar 2026 13:49:38 -0400 Subject: [PATCH] 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. --- src/shaders/world.frag | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/src/shaders/world.frag b/src/shaders/world.frag index 6febbf8..fae319b 100644 --- a/src/shaders/world.frag +++ b/src/shaders/world.frag @@ -12,25 +12,15 @@ void main() { vec4 lastState = texture(tLastState, vUv); vec4 discreteAnts = texture(tDiscreteAnts, vUv); - int cellData = int(lastState.x); - int isFood = cellData & 1; - int isHome = (cellData & 2) >> 1; - int isObstacle = (cellData & 4) >> 2; + 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 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.) { - isFood = 0; + materialId = float(MAT_AIR); } - int terrainType = (cellData >> TERRAIN_TYPE_SHIFT) & TERRAIN_TYPE_MASK; - int foodQuality = (cellData >> FOOD_QUALITY_SHIFT) & FOOD_QUALITY_MASK; - - // reconstruct cell data preserving all bit fields - int newCellData = isFood + (isHome << 1) + (isObstacle << 2) - + (terrainType << TERRAIN_TYPE_SHIFT) - + (foodQuality << FOOD_QUALITY_SHIFT); - - FragColor = vec4(float(newCellData), scentToHome, scentToFood, repellent); + FragColor = vec4(materialId, scentToHome, scentToFood, repellent); }