From 4c119245809180d7208728962a689dbc23bdc9c0 Mon Sep 17 00:00:00 2001 From: Jared Miller Date: Wed, 11 Mar 2026 20:57:13 -0400 Subject: [PATCH] Add per-pixel hash noise to material colors --- src/shaders/screenWorld.frag | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) 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);