Add per-pixel hash noise to material colors
This commit is contained in:
parent
aa3c94091b
commit
4c11924580
1 changed files with 10 additions and 1 deletions
|
|
@ -8,6 +8,12 @@ out vec4 FragColor;
|
||||||
uniform sampler2D map;
|
uniform sampler2D map;
|
||||||
uniform sampler2D uMaterialColors;
|
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() {
|
void main() {
|
||||||
vec4 value = texture(map, vUv);
|
vec4 value = texture(map, vUv);
|
||||||
|
|
||||||
|
|
@ -30,7 +36,10 @@ void main() {
|
||||||
// non-air cells use material color as base, with pheromone tint
|
// non-air cells use material color as base, with pheromone tint
|
||||||
if (materialId != MAT_AIR) {
|
if (materialId != MAT_AIR) {
|
||||||
vec4 matColor = texelFetch(uMaterialColors, ivec2(materialId, 0), 0);
|
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);
|
FragColor = vec4(color, 1);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue