diff --git a/src/shaders/screenWorld.frag b/src/shaders/screenWorld.frag index 7657b96..f61da39 100644 --- a/src/shaders/screenWorld.frag +++ b/src/shaders/screenWorld.frag @@ -8,6 +8,12 @@ out vec4 FragColor; uniform sampler2D map; uniform sampler2D uMaterialColors; +float hash(ivec2 p) { + int h = p.x * 374761393 + p.y * 668265263; + h = (h ^ (h >> 13)) * 1274126177; + return float(h & 0x7fffffff) / float(0x7fffffff); +} + void main() { vec4 value = texture(map, vUv); @@ -30,7 +36,10 @@ void main() { // non-air cells use material color as base, with pheromone tint if (materialId != MAT_AIR) { vec4 matColor = texelFetch(uMaterialColors, ivec2(materialId, 0), 0); - color = mix(matColor.rgb, t, a * 0.3); + // per-pixel color variation: +/-4% brightness noise + float colorNoise = hash(ivec2(gl_FragCoord.xy)) * 0.08 - 0.04; + vec3 variedColor = matColor.rgb + colorNoise; + color = mix(variedColor, t, a * 0.3); } FragColor = vec4(color, 1);