Noise filter

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By IvanVoirol

I’m looking for an easy noise filter to apply on sprites, or on a set of nodes. My project is completely in 2D, and I want to add some film grain to the render, to improve the flat zones a bit. I don’t need anything fancy, an effect with intensity and color saturation parameters would be enough.
Thanks !

Can’t you just add noise to the textures in the first place? Image editors often have effects like that.
Or do you actually want animated noise?

Zylann | 2020-09-17 12:19

Yes, animated noise.

IvanVoirol | 2020-09-17 12:56

so, to clarify, are you trying to make it look like an old film?

Millard | 2020-09-17 15:01

:bust_in_silhouette: Reply From: Reloecc

And what exactly is your question? Godot has built-in OpenSimpleNoise algo available…

In a case of “I need it for a film grain” you probably want on-screen effect, so easiest way to use it is to add TextureRect Control and in its “Texture” property select “New NoiseTexture”.

This way I can make a static noise texture, but how do I animate it, and apply it to a sprite?
Here’s an example of what I need : enter image description here

IvanVoirol | 2020-09-17 16:30

:bust_in_silhouette: Reply From: Zylann

You can try this shader:

shader_type canvas_item;

uniform float u_amount = 0.1;

float get_noise(vec2 uv) {
	return fract(sin(dot(uv ,vec2(12.9898,78.233))) * 43758.5453);

void fragment() {
	float n = 2.0 * get_noise(UV + vec2(TIME, 0.0)) - 1.0;
	COLOR = texture(TEXTURE, UV) + n * u_amount;

Pixelated version:

void fragment() {
	vec2 k = 1.0 / TEXTURE_PIXEL_SIZE;
	vec2 pixel_coords = floor(k * UV) + k * vec2(TIME);
	float n = 2.0 * get_noise(pixel_coords) - 1.0;
	COLOR = texture(TEXTURE, UV) + n * u_amount;

Exactly what I was needed, thanks!

IvanVoirol | 2020-09-17 18:45