varying vec2 v_texcoord;uniform sampler2D u_texture;float fractFp16(in float value) { float exponent = min(ceil(-log2(value + 1.4013e-045) - 1.0), 127.0); float scaled = value * pow(2.0, exponent); float result = fract(scaled * 65536.0) + ((exponent + 1.0) / 65536.0); return result; } vec3 noise(in float variation, in float intensity) { float value = sin(fractFp16(variation * 0.180654321)); value = fractFp16(value); return vec3(value) / intensity; } void main() { vec3 color = texture2D(u_texture, v_texcoord).rgb; vec3 noise_factor = noise(length(color), 3.0); color += noise_factor; gl_FragColor = vec4(color, 1.0); }
varying vec2 v_texcoord;uniform sampler2D u_texture;vec3 grainNoise(in vec3 color, in float intensity){ float variation = v_texcoord.x * v_texcoord.y * 1000.0; variation = mod(variation, 13.0) * mod(variation, 123.0); float grain = mod(variation, 0.01); vec3 result = color + color * clamp(0.1 + grain * (intensity * 100.0), 0.0, 1.0); return result;}void main(){ vec3 color = texture2D(u_texture, v_texcoord).rgb; color = grainNoise(color, 1.0); gl_FragColor = vec4(color, 1.0);}