The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates. | Twitter

0 votes

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 !

in Engine by (188 points)

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?

Yes, animated noise.

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

2 Answers

+1 vote
Best answer

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;
by (29,360 points)
selected by

Exactly what I was needed, thanks!

+2 votes

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".

by (206 points)

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

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.