diff --git a/camera-effects.tscn b/camera-effects.tscn index 56ca25d..35e237d 100644 --- a/camera-effects.tscn +++ b/camera-effects.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=21 format=3 uid="uid://c051w6upl0t16"] +[gd_scene load_steps=22 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="Script" path="res://camera-effects/camera-effects-scene.gd" id="1_ct3xk"] @@ -13,6 +13,7 @@ [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"] [ext_resource type="PackedScene" uid="uid://dwppksddt4t0x" path="res://camera-effects/hexagon_mosaic.tscn" id="12_uvrob"] +[ext_resource type="PackedScene" uid="uid://dxnm4sgbeu22g" path="res://camera-effects/camera_shake.tscn" id="14_qhoe5"] [ext_resource type="Texture2D" uid="uid://etnwfy334jt" path="res://addons/kenney_particle_pack/window_03.png" id="14_ydbvf"] [sub_resource type="Environment" id="Environment_tln01"] @@ -201,6 +202,9 @@ visible = false [node name="Hexagon Mosaic" parent="CanvasLayer Effects" instance=ExtResource("12_uvrob")] +[node name="Camera Shake" parent="CanvasLayer Effects" instance=ExtResource("14_qhoe5")] +visible = false + [node name="CanvasLayer UI" type="CanvasLayer" parent="."] [node name="SideBar" type="HBoxContainer" parent="CanvasLayer UI"] @@ -274,6 +278,12 @@ theme_override_font_sizes/font_size = 24 button_pressed = true text = "Hexagon Mosaic" +[node name="ButtonCameraShake" type="CheckButton" parent="CanvasLayer UI/SideBar/SideBar Menu/MarginContainer/VBoxContainer"] +unique_name_in_owner = true +layout_mode = 2 +theme_override_font_sizes/font_size = 24 +text = "Camera Shake" + [node name="ToggleButton" type="TextureButton" parent="CanvasLayer UI/SideBar"] custom_minimum_size = Vector2(64, 2.08165e-12) layout_mode = 2 @@ -314,4 +324,5 @@ libraries = { [connection signal="toggled" from="CanvasLayer UI/SideBar/SideBar Menu/MarginContainer/VBoxContainer/ButtonSepia" to="." method="updateVisibleEffects"] [connection signal="toggled" from="CanvasLayer UI/SideBar/SideBar Menu/MarginContainer/VBoxContainer/ButtonGrainNoise" to="." method="updateVisibleEffects"] [connection signal="toggled" from="CanvasLayer UI/SideBar/SideBar Menu/MarginContainer/VBoxContainer/ButtonHexagonMosaic" to="." method="updateVisibleEffects"] +[connection signal="toggled" from="CanvasLayer UI/SideBar/SideBar Menu/MarginContainer/VBoxContainer/ButtonCameraShake" to="." method="updateVisibleEffects"] [connection signal="pressed" from="CanvasLayer UI/SideBar/ToggleButton" to="." method="toggleSideBar"] diff --git a/camera-effects/camera-effects-scene.gd b/camera-effects/camera-effects-scene.gd index 7b65d16..8af04c0 100644 --- a/camera-effects/camera-effects-scene.gd +++ b/camera-effects/camera-effects-scene.gd @@ -9,6 +9,7 @@ extends Node3D @onready var buttonSepia = %ButtonSepia @onready var buttonGrainNoise = %ButtonGrainNoise @onready var buttonHexagonMosaic = %ButtonHexagonMosaic +@onready var buttonCameraShake = %ButtonCameraShake @onready var effectChromaticAberration = $"CanvasLayer Effects/Chromatic Aberration" @onready var effectPixelate = $"CanvasLayer Effects/Pixelate" @@ -16,6 +17,7 @@ extends Node3D @onready var effectSepia = $"CanvasLayer Effects/Sepia" @onready var effectGrainNoise = $"CanvasLayer Effects/Grain Noise" @onready var effectHexagonMosaic = $"CanvasLayer Effects/Hexagon Mosaic" +@onready var effectCameraShake = $"CanvasLayer Effects/Camera Shake" @onready var animationPlayer = $AnimationPlayer @onready var sideBarMenu = $"CanvasLayer UI/SideBar/SideBar Menu" @@ -38,6 +40,7 @@ func updateVisibleEffects(toggled_on): effectSepia.visible = buttonSepia.button_pressed effectGrainNoise.visible = buttonGrainNoise.button_pressed effectHexagonMosaic.visible = buttonHexagonMosaic.button_pressed + effectCameraShake.visible = buttonCameraShake.button_pressed updateEffectsLabel() func disableAllEffects(): @@ -47,6 +50,7 @@ func disableAllEffects(): buttonSepia.button_pressed = false buttonGrainNoise.button_pressed = false buttonHexagonMosaic.button_pressed = false + buttonCameraShake.button_pressed = false updateEffectsLabel() @@ -58,6 +62,7 @@ func updateEffectsLabel(): "Sepia" if buttonSepia.button_pressed else "", "Grain Noise" if buttonGrainNoise.button_pressed else "", "Hexagon Mosaic" if buttonHexagonMosaic.button_pressed else "", + "Camera Shake" if buttonCameraShake.button_pressed else "", ] var text = " ".join(textParts) labelVisibleEffects.text = "[center]" + text diff --git a/camera-effects/camera-shake.gdshader b/camera-effects/camera-shake.gdshader new file mode 100644 index 0000000..0e30912 --- /dev/null +++ b/camera-effects/camera-shake.gdshader @@ -0,0 +1,13 @@ +shader_type canvas_item; + +uniform sampler2D SCREEN_TEXTURE : hint_screen_texture, filter_linear; +uniform float strength = 20.0; +uniform float speed = 1.0; + +void fragment() { + float deviation = strength * sin(TIME * speed); + vec2 offset = vec2(deviation, 0.0) * SCREEN_PIXEL_SIZE; + vec4 color = texture(SCREEN_TEXTURE, UV + offset); + + COLOR = color; +} diff --git a/camera-effects/camera_shake.tscn b/camera-effects/camera_shake.tscn new file mode 100644 index 0000000..f29b57f --- /dev/null +++ b/camera-effects/camera_shake.tscn @@ -0,0 +1,16 @@ +[gd_scene load_steps=3 format=3 uid="uid://dxnm4sgbeu22g"] + +[ext_resource type="Shader" path="res://camera-effects/camera-shake.gdshader" id="1_jjc8p"] + +[sub_resource type="ShaderMaterial" id="ShaderMaterial_a78ec"] +shader = ExtResource("1_jjc8p") +shader_parameter/strength = 20.0 +shader_parameter/speed = 100.0 + +[node name="Camera Shake" type="ColorRect"] +material = SubResource("ShaderMaterial_a78ec") +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 diff --git a/project.godot b/project.godot index 8158965..1fadad8 100644 --- a/project.godot +++ b/project.godot @@ -15,6 +15,11 @@ run/main_scene="res://particle-effects.tscn" config/features=PackedStringArray("4.2", "C#", "Forward Plus") config/icon="res://icon.svg" +[display] + +window/size/viewport_width=2304 +window/size/viewport_height=1296 + [dotnet] project/assembly_name="godot-visual-effects"