mirror of
https://github.com/Steffo99/hella-farm.git
synced 2024-11-25 09:34:24 +00:00
Add basic post processing shader
This commit is contained in:
parent
c3eb2226e9
commit
484c61caa3
4 changed files with 27 additions and 5 deletions
4
main.gd
4
main.gd
|
@ -3,7 +3,7 @@ class_name Main
|
||||||
|
|
||||||
|
|
||||||
@onready var tree: SceneTree = get_tree()
|
@onready var tree: SceneTree = get_tree()
|
||||||
@onready var container: Control = $"PrimaryCanvas/SafeMarginContainer"
|
@onready var ui_container: Control = $"InterfaceCanvas/SafeMarginContainer"
|
||||||
|
|
||||||
|
|
||||||
## The possible states the game can be in.
|
## The possible states the game can be in.
|
||||||
|
@ -61,7 +61,7 @@ func build_menu() -> void:
|
||||||
scene_menu = SCENE_MENU.instantiate()
|
scene_menu = SCENE_MENU.instantiate()
|
||||||
scene_menu.selected_play.connect(_on_menu_selected_play)
|
scene_menu.selected_play.connect(_on_menu_selected_play)
|
||||||
scene_menu.selected_options.connect(_on_menu_selected_options)
|
scene_menu.selected_options.connect(_on_menu_selected_options)
|
||||||
container.add_child(scene_menu)
|
ui_container.add_child(scene_menu)
|
||||||
|
|
||||||
## Destroy the [MainGame].
|
## Destroy the [MainGame].
|
||||||
func destroy_game() -> void:
|
func destroy_game() -> void:
|
||||||
|
|
18
main.tscn
18
main.tscn
|
@ -1,15 +1,27 @@
|
||||||
[gd_scene load_steps=3 format=3 uid="uid://b38wkla8e7rmo"]
|
[gd_scene load_steps=4 format=3 uid="uid://b38wkla8e7rmo"]
|
||||||
|
|
||||||
[ext_resource type="Script" path="res://main.gd" id="1_jyg3q"]
|
[ext_resource type="Script" path="res://main.gd" id="1_jyg3q"]
|
||||||
|
[ext_resource type="Material" uid="uid://dpumcyplql08q" path="res://postprocess.material" id="2_3o1ux"]
|
||||||
[ext_resource type="PackedScene" uid="uid://bkm7id1wdwywg" path="res://scenes/menu/safe_margin_container.tscn" id="2_ah6n8"]
|
[ext_resource type="PackedScene" uid="uid://bkm7id1wdwywg" path="res://scenes/menu/safe_margin_container.tscn" id="2_ah6n8"]
|
||||||
|
|
||||||
[node name="Main" type="Node"]
|
[node name="Main" type="Node"]
|
||||||
script = ExtResource("1_jyg3q")
|
script = ExtResource("1_jyg3q")
|
||||||
starting_stage = 3
|
starting_stage = 3
|
||||||
|
|
||||||
[node name="PrimaryCanvas" type="CanvasLayer" parent="."]
|
[node name="PostprocessingCanvas" type="CanvasLayer" parent="."]
|
||||||
|
|
||||||
[node name="SafeMarginContainer" parent="PrimaryCanvas" instance=ExtResource("2_ah6n8")]
|
[node name="ColorRect" type="ColorRect" parent="PostprocessingCanvas"]
|
||||||
|
material = ExtResource("2_3o1ux")
|
||||||
|
anchors_preset = 15
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
grow_horizontal = 2
|
||||||
|
grow_vertical = 2
|
||||||
|
color = Color(0, 0, 0, 1)
|
||||||
|
|
||||||
|
[node name="InterfaceCanvas" type="CanvasLayer" parent="."]
|
||||||
|
|
||||||
|
[node name="SafeMarginContainer" parent="InterfaceCanvas" instance=ExtResource("2_ah6n8")]
|
||||||
min_margin_left = 16
|
min_margin_left = 16
|
||||||
min_margin_right = 16
|
min_margin_right = 16
|
||||||
min_margin_top = 16
|
min_margin_top = 16
|
||||||
|
|
10
postprocess.gdshader
Normal file
10
postprocess.gdshader
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
shader_type canvas_item;
|
||||||
|
|
||||||
|
uniform float intensity = 0.1;
|
||||||
|
uniform sampler2D screen_texture : hint_screen_texture, repeat_disable, filter_nearest;
|
||||||
|
|
||||||
|
void fragment() {
|
||||||
|
float color = round(fract(UV * 360.0).y);
|
||||||
|
vec4 tex = texture(screen_texture, SCREEN_UV);
|
||||||
|
COLOR = tex * (1.0 - intensity) + (tex * color * intensity);
|
||||||
|
}
|
BIN
postprocess.material
Normal file
BIN
postprocess.material
Normal file
Binary file not shown.
Loading…
Reference in a new issue