Encode deposit material ID in discretize pass
This commit is contained in:
parent
34bd1e95c2
commit
489f121064
2 changed files with 11 additions and 1 deletions
|
|
@ -5,9 +5,11 @@ in vec2 vUv;
|
||||||
in float vIsCarryingFood;
|
in float vIsCarryingFood;
|
||||||
in float vScentFactor;
|
in float vScentFactor;
|
||||||
in float vIsCellCleared;
|
in float vIsCellCleared;
|
||||||
|
in float vDepositMaterialId;
|
||||||
|
|
||||||
out vec4 FragColor;
|
out vec4 FragColor;
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
FragColor = vec4(vIsCarryingFood * vScentFactor, (1. - vIsCarryingFood) * vScentFactor, vIsCellCleared, 1);
|
// encode deposit material ID in alpha: divide by 255 to fit in UnsignedByte channel
|
||||||
|
FragColor = vec4(vIsCarryingFood * vScentFactor, (1. - vIsCarryingFood) * vScentFactor, vIsCellCleared, vDepositMaterialId / 255.);
|
||||||
}
|
}
|
||||||
|
|
@ -8,6 +8,7 @@ out vec2 vUv;
|
||||||
out float vIsCarryingFood;
|
out float vIsCarryingFood;
|
||||||
out float vScentFactor;
|
out float vScentFactor;
|
||||||
out float vIsCellCleared;
|
out float vIsCellCleared;
|
||||||
|
out float vDepositMaterialId;
|
||||||
|
|
||||||
uniform sampler2D tDataCurrent;
|
uniform sampler2D tDataCurrent;
|
||||||
uniform sampler2D tDataLast;
|
uniform sampler2D tDataLast;
|
||||||
|
|
@ -38,6 +39,13 @@ void main() {
|
||||||
vScentFactor = storage / SCENT_MAX_STORAGE;
|
vScentFactor = storage / SCENT_MAX_STORAGE;
|
||||||
vIsCellCleared = isCellCleared;
|
vIsCellCleared = isCellCleared;
|
||||||
|
|
||||||
|
// detect deposit: was carrying, now not — read cargo ID from extended state
|
||||||
|
float isDepositing = float(wasCarrying == 1. && isCarrying == 0.);
|
||||||
|
vec4 extSample = texture(tDataExtCurrent, vec2(sampleX, sampleY) / dataTextureSize);
|
||||||
|
// cargoMaterialId is kept non-zero on the deposit frame (zeroed next frame for food drops,
|
||||||
|
// and stays as-is for powder deposits until the ant picks something else up)
|
||||||
|
vDepositMaterialId = isDepositing * extSample.g;
|
||||||
|
|
||||||
gl_Position = vec4(
|
gl_Position = vec4(
|
||||||
(position.xy * cellSize + floor(offset * WORLD_SIZE) / WORLD_SIZE + cellSize * 0.5) * 2. - 1.,
|
(position.xy * cellSize + floor(offset * WORLD_SIZE) / WORLD_SIZE + cellSize * 0.5) * 2. - 1.,
|
||||||
0,
|
0,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue