diff --git a/README.md b/README.md index 0ba1b0d..98133dc 100644 --- a/README.md +++ b/README.md @@ -44,6 +44,14 @@ These effects should be place in a CanvasLayer object in any scene ![Chromatic Aberration](./docs/images/camera-effects/chromatic-aberration.png) +### Sepia + +![Sepia](./docs/images/camera-effects/sepia.png) + +### Grain Noise + +![Grain Noise](./docs/images/camera-effects/grain-noise.png) + ## License * Kenney Particle Pack is copyrighted by Kenney, and can be found at https://kenney.nl/assets/particle-pack diff --git a/camera-effects.tscn b/camera-effects.tscn index 743ca3f..f8bdb42 100644 --- a/camera-effects.tscn +++ b/camera-effects.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=13 format=3 uid="uid://c051w6upl0t16"] +[gd_scene load_steps=15 format=3 uid="uid://c051w6upl0t16"] [ext_resource type="PackedScene" uid="uid://bydyult2k5rcb" path="res://addons/kenney_prototype_tools/scenes/green/green_01.tscn" id="1_61jfr"] [ext_resource type="PackedScene" uid="uid://bjupt5nu14hth" path="res://addons/kenney_prototype_tools/scenes/dark/dark_05.tscn" id="2_xlmfj"] @@ -9,6 +9,8 @@ [ext_resource type="PackedScene" uid="uid://sy04esp2kle1" path="res://camera-effects/chromatic_aberration.tscn" id="7_uoado"] [ext_resource type="PackedScene" uid="uid://djsrvtsqjesw8" path="res://camera-effects/pixelate.tscn" id="8_fshcg"] [ext_resource type="PackedScene" uid="uid://ds5xw2us1br3q" path="res://camera-effects/vignette.tscn" id="9_q1phu"] +[ext_resource type="PackedScene" uid="uid://dv3o1u4hc11vn" path="res://camera-effects/sepia.tscn" id="10_rqewe"] +[ext_resource type="PackedScene" uid="uid://cf1adbox8xy7e" path="res://camera-effects/grain_noise.tscn" id="11_3qobw"] [sub_resource type="Environment" id="Environment_tln01"] glow_blend_mode = 4 @@ -157,3 +159,9 @@ visible = false visible = false [node name="Vignette" parent="CanvasLayer" instance=ExtResource("9_q1phu")] +visible = false + +[node name="Sepia" parent="CanvasLayer" instance=ExtResource("10_rqewe")] +visible = false + +[node name="Grain Noise" parent="CanvasLayer" instance=ExtResource("11_3qobw")] diff --git a/camera-effects/grain-noise.gdshader b/camera-effects/grain-noise.gdshader new file mode 100644 index 0000000..2f95492 --- /dev/null +++ b/camera-effects/grain-noise.gdshader @@ -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); +} diff --git a/camera-effects/grain_noise.tscn b/camera-effects/grain_noise.tscn new file mode 100644 index 0000000..5caaa60 --- /dev/null +++ b/camera-effects/grain_noise.tscn @@ -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 diff --git a/camera-effects/sepia.gdshader b/camera-effects/sepia.gdshader new file mode 100644 index 0000000..97dcb31 --- /dev/null +++ b/camera-effects/sepia.gdshader @@ -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); +} diff --git a/camera-effects/sepia.tscn b/camera-effects/sepia.tscn new file mode 100644 index 0000000..95a9b76 --- /dev/null +++ b/camera-effects/sepia.tscn @@ -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 diff --git a/docs/images/camera-effects/chromatic-aberration.png.import b/docs/images/camera-effects/chromatic-aberration.png.import new file mode 100644 index 0000000..9a3eecc --- /dev/null +++ b/docs/images/camera-effects/chromatic-aberration.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://b2arsem4u8ix" +path="res://.godot/imported/chromatic-aberration.png-c2a5bd7a5d90f5d312977160e8e24d50.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://docs/images/camera-effects/chromatic-aberration.png" +dest_files=["res://.godot/imported/chromatic-aberration.png-c2a5bd7a5d90f5d312977160e8e24d50.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 diff --git a/docs/images/camera-effects/grain-noise.png b/docs/images/camera-effects/grain-noise.png new file mode 100644 index 0000000..fba1ae3 Binary files /dev/null and b/docs/images/camera-effects/grain-noise.png differ diff --git a/docs/images/camera-effects/sepia.png b/docs/images/camera-effects/sepia.png new file mode 100644 index 0000000..e83da2b Binary files /dev/null and b/docs/images/camera-effects/sepia.png differ