Fixed grain noise

This commit is contained in:
Mario Brandao 2023-12-13 23:07:09 +01:00
parent 80dd302a25
commit 77472b3c54
3 changed files with 69 additions and 8 deletions

View File

@ -5,18 +5,11 @@ void fragment() {
// Readbackground and foreground images.
vec4 col = texture(SCREEN_TEXTURE, UV);
// Sepia tone, from
// https://www.techrepublic.com/blog/how-do-i/how-do-i-convert-images-to-grayscale-and-sepia-tone-using-c
vec3 sepia = vec3(
col.r * .393 + col.g *.769 + col.b * .189,
col.r * .349 + col.g *.686 + col.b * .168,
col.r * .272 + col.g *.534 + col.b * .131);
// Film grain, from
// https://www.reddit.com/r/opengl/comments/1rr4fy/any_good_ways_of_generating_film_grain_noise
const float noiseStrength = 50.0;
float x = (UV.x + 4.0) * (UV.y + 4.0) * (TIME * 10.0);
vec3 grain = vec3(mod((mod(x, 13.0) + 1.0) * (mod(x, 123.0) + 1.0), 0.01) - 0.005) * noiseStrength;
COLOR = vec4(sepia + grain, 1.0);
COLOR = vec4(col.rgb + grain, 1.0);
}

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://dd670pxxqnj3a"
path="res://.godot/imported/grain-noise.png-636753a66ba8f58b76cc3e76d70bf8fb.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://docs/images/camera-effects/grain-noise.png"
dest_files=["res://.godot/imported/grain-noise.png-636753a66ba8f58b76cc3e76d70bf8fb.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://d1xdglibjvwm2"
path="res://.godot/imported/sepia.png-a48b21a7580480e9f99c417e24150326.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://docs/images/camera-effects/sepia.png"
dest_files=["res://.godot/imported/sepia.png-a48b21a7580480e9f99c417e24150326.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1