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.
This commit is contained in:
Jared Miller 2026-03-11 13:49:38 -04:00
parent 0f9c1b47f2
commit e210ebc72d
Signed by: shmup
GPG key ID: 22B5C6D66A38B06C

View file

@ -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);
}