mirror of
https://github.com/marinho/godot-visual-effects.git
synced 2025-09-19 04:06:15 +08:00
Sepia and Grain Noise
This commit is contained in:
22
camera-effects/grain-noise.gdshader
Normal file
22
camera-effects/grain-noise.gdshader
Normal file
@ -0,0 +1,22 @@
|
||||
shader_type canvas_item;
|
||||
|
||||
uniform sampler2D SCREEN_TEXTURE : hint_screen_texture, filter_linear;
|
||||
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);
|
||||
}
|
14
camera-effects/grain_noise.tscn
Normal file
14
camera-effects/grain_noise.tscn
Normal file
@ -0,0 +1,14 @@
|
||||
[gd_scene load_steps=3 format=3 uid="uid://cf1adbox8xy7e"]
|
||||
|
||||
[ext_resource type="Shader" path="res://camera-effects/grain-noise.gdshader" id="1_r8x04"]
|
||||
|
||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_pwuts"]
|
||||
shader = ExtResource("1_r8x04")
|
||||
|
||||
[node name="Grain Noise" type="ColorRect"]
|
||||
material = SubResource("ShaderMaterial_pwuts")
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
16
camera-effects/sepia.gdshader
Normal file
16
camera-effects/sepia.gdshader
Normal file
@ -0,0 +1,16 @@
|
||||
shader_type canvas_item;
|
||||
|
||||
// inspired by: https://www.shadertoy.com/view/Xl3cDn
|
||||
|
||||
uniform sampler2D SCREEN_TEXTURE : hint_screen_texture, filter_linear;
|
||||
|
||||
void fragment() {
|
||||
vec4 col = texture(SCREEN_TEXTURE, UV);
|
||||
|
||||
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);
|
||||
|
||||
COLOR = vec4(sepia, 1.0);
|
||||
}
|
14
camera-effects/sepia.tscn
Normal file
14
camera-effects/sepia.tscn
Normal file
@ -0,0 +1,14 @@
|
||||
[gd_scene load_steps=3 format=3 uid="uid://dv3o1u4hc11vn"]
|
||||
|
||||
[ext_resource type="Shader" path="res://camera-effects/sepia.gdshader" id="1_5124a"]
|
||||
|
||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_qria4"]
|
||||
shader = ExtResource("1_5124a")
|
||||
|
||||
[node name="Sepia" type="ColorRect"]
|
||||
material = SubResource("ShaderMaterial_qria4")
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
Reference in New Issue
Block a user