summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Assets/Shaders/crt_shader.gdshader84
-rw-r--r--Assets/Shaders/crt_shader.tres21
-rw-r--r--Scenes/Texty.tscn87
-rw-r--r--project.godot12
4 files changed, 202 insertions, 2 deletions
diff --git a/Assets/Shaders/crt_shader.gdshader b/Assets/Shaders/crt_shader.gdshader
new file mode 100644
index 0000000..445472e
--- /dev/null
+++ b/Assets/Shaders/crt_shader.gdshader
@@ -0,0 +1,84 @@
+/*
+Godot 3 2D CRT Shader.
+A 2D shader for Godot 3 simulating a CRT..
+Author: hiulit
+Repository: https://github.com/hiulit/Godot-3-2D-CRT-Shader
+Issues: https://github.com/hiulit/Godot-3-2D-CRT-Shader/issues
+License: MIT https://github.com/hiulit/Godot-3-2D-CRT-Shader/blob/master/LICENSE
+*/
+
+shader_type canvas_item;
+
+const float PI = 3.14159265359;
+
+uniform vec2 screen_size = vec2(320.0, 180.0);
+uniform bool show_curvature = true;
+uniform float curvature_x_amount : hint_range(3.0, 15.0, 0.01) = float(6.0);
+uniform float curvature_y_amount : hint_range(3.0, 15.0, 0.01) = float(4.0);
+uniform vec4 corner_color : hint_color = vec4(0.0, 0.0, 0.0, 1.0);
+uniform bool show_vignette = true;
+uniform float vignette_opacity : hint_range(0.0, 1.0, 0.01) = 0.2;
+uniform bool show_horizontal_scan_lines = true;
+uniform float horizontal_scan_lines_amount : hint_range(0.0, 180.0, 0.1) = 180.0;
+uniform float horizontal_scan_lines_opacity : hint_range(0.0, 1.0, 0.01) = 1.0;
+uniform bool show_vertical_scan_lines = false;
+uniform float vertical_scan_lines_amount : hint_range(0.0, 320.0, 0.1) = 320.0;
+uniform float vertical_scan_lines_opacity : hint_range(0.0, 1.0, 0.01) = 1.0;
+uniform float boost : hint_range(1.0, 2.0, 0.01) = 1.2;
+uniform float aberration_amount : hint_range(0.0, 10.0, 0.01) = 0.0;
+
+vec2 uv_curve(vec2 uv) {
+ if (show_curvature) {
+ uv = uv * 2.0 - 1.0;
+ vec2 offset = abs(uv.yx) / vec2(curvature_x_amount, curvature_y_amount);
+ uv = uv + uv * offset * offset;
+ uv = uv * 0.5 + 0.5;
+ }
+
+ return uv;
+}
+
+
+void fragment() {
+ vec2 uv = uv_curve(UV);
+ vec2 screen_uv = uv_curve(SCREEN_UV);
+ vec3 color = texture(SCREEN_TEXTURE, screen_uv).rgb;
+
+ if (aberration_amount > 0.0) {
+ float adjusted_amount = aberration_amount / screen_size.x;
+ color.r = texture(SCREEN_TEXTURE, vec2(screen_uv.x + adjusted_amount, screen_uv.y)).r;
+ color.g = texture(SCREEN_TEXTURE, screen_uv).g;
+ color.b = texture(SCREEN_TEXTURE, vec2(screen_uv.x - adjusted_amount, screen_uv.y)).b;
+ }
+
+ if (show_vignette) {
+ float vignette = uv.x * uv.y * (1.0 - uv.x) * (1.0 - uv.y);
+ vignette = clamp(pow((screen_size.x / 4.0) * vignette, vignette_opacity), 0.0, 1.0);
+ color *= vignette;
+ }
+
+ if (show_horizontal_scan_lines) {
+ float s = sin(screen_uv.y * horizontal_scan_lines_amount * PI * 2.0);
+ s = (s * 0.5 + 0.5) * 0.9 + 0.1;
+ vec4 scan_line = vec4(vec3(pow(s, horizontal_scan_lines_opacity)), 1.0);
+ color *= scan_line.rgb;
+ }
+
+ if (show_vertical_scan_lines) {
+ float s = sin(screen_uv.x * vertical_scan_lines_amount * PI * 2.0);
+ s = (s * 0.5 + 0.5) * 0.9 + 0.1;
+ vec4 scan_line = vec4(vec3(pow(s, vertical_scan_lines_opacity)), 1.0);
+ color *= scan_line.rgb;
+ }
+
+ if (show_horizontal_scan_lines || show_vertical_scan_lines) {
+ color *= boost;
+ }
+
+ // Fill the blank space of the corners, left by the curvature, with black.
+ if (uv.x < 0.0 || uv.x > 1.0 || uv.y < 0.0 || uv.y > 1.0) {
+ color = corner_color.rgb;
+ }
+
+ COLOR = vec4(color, 1.0);
+} \ No newline at end of file
diff --git a/Assets/Shaders/crt_shader.tres b/Assets/Shaders/crt_shader.tres
new file mode 100644
index 0000000..1612d82
--- /dev/null
+++ b/Assets/Shaders/crt_shader.tres
@@ -0,0 +1,21 @@
+[gd_resource type="ShaderMaterial" load_steps=2 format=2]
+
+[ext_resource path="res://Assets/Shaders/crt_shader.gdshader" type="Shader" id=1]
+
+[resource]
+shader = ExtResource( 1 )
+shader_param/screen_size = Vector2( 640, 480 )
+shader_param/show_curvature = false
+shader_param/curvature_x_amount = 6.0
+shader_param/curvature_y_amount = 4.0
+shader_param/corner_color = Color( 0, 0, 0, 1 )
+shader_param/show_vignette = true
+shader_param/vignette_opacity = 0.1
+shader_param/show_horizontal_scan_lines = true
+shader_param/horizontal_scan_lines_amount = 90.0
+shader_param/horizontal_scan_lines_opacity = 0.1
+shader_param/show_vertical_scan_lines = false
+shader_param/vertical_scan_lines_amount = 320.0
+shader_param/vertical_scan_lines_opacity = 1.0
+shader_param/boost = 1.25
+shader_param/aberration_amount = 1.5
diff --git a/Scenes/Texty.tscn b/Scenes/Texty.tscn
index 1fb7b91..b40b2da 100644
--- a/Scenes/Texty.tscn
+++ b/Scenes/Texty.tscn
@@ -1,10 +1,93 @@
-[gd_scene load_steps=2 format=2]
+[gd_scene load_steps=3 format=2]
+[ext_resource path="res://Assets/Shaders/crt_shader.tres" type="Material" id=1]
[ext_resource path="res://Scripts/Texty.cs" type="Script" id=3]
[node name="Texty" type="Node"]
script = ExtResource( 3 )
-[node name="VBoxContainer" type="VBoxContainer" parent="."]
+[node name="Terminal" type="CanvasLayer" parent="."]
+
+[node name="Game" type="VBoxContainer" parent="Terminal"]
+anchor_right = 1.0
+anchor_bottom = 1.0
+
+[node name="StatusLine" type="PanelContainer" parent="Terminal/Game"]
+margin_right = 640.0
+margin_bottom = 53.0
+
+[node name="Container" type="HBoxContainer" parent="Terminal/Game/StatusLine"]
+margin_left = 14.0
+margin_top = 14.0
+margin_right = 626.0
+margin_bottom = 39.0
+size_flags_horizontal = 3
+
+[node name="Title" type="Label" parent="Terminal/Game/StatusLine/Container"]
+margin_right = 612.0
+margin_bottom = 25.0
+size_flags_horizontal = 3
+size_flags_vertical = 6
+text = "Adventure Title"
+max_lines_visible = 1
+
+[node name="Output" type="PanelContainer" parent="Terminal/Game"]
+margin_top = 61.0
+margin_right = 640.0
+margin_bottom = 399.0
+size_flags_horizontal = 3
+size_flags_vertical = 3
+
+[node name="Container" type="ScrollContainer" parent="Terminal/Game/Output"]
+margin_left = 14.0
+margin_top = 14.0
+margin_right = 626.0
+margin_bottom = 324.0
+mouse_filter = 1
+size_flags_horizontal = 3
+size_flags_vertical = 3
+scroll_horizontal_enabled = false
+
+[node name="Lines" type="VBoxContainer" parent="Terminal/Game/Output/Container"]
+margin_right = 612.0
+margin_bottom = 27.0
+size_flags_horizontal = 3
+
+[node name="RichTextLabel" type="RichTextLabel" parent="Terminal/Game/Output/Container/Lines"]
+margin_right = 612.0
+margin_bottom = 27.0
+text = "This is where the output goes"
+fit_content_height = true
+
+[node name="Input" type="PanelContainer" parent="Terminal/Game"]
+margin_top = 407.0
+margin_right = 640.0
+margin_bottom = 480.0
+
+[node name="Container" type="HBoxContainer" parent="Terminal/Game/Input"]
+margin_left = 14.0
+margin_top = 14.0
+margin_right = 626.0
+margin_bottom = 59.0
+
+[node name="Prompt" type="Label" parent="Terminal/Game/Input/Container"]
+margin_top = 10.0
+margin_right = 20.0
+margin_bottom = 35.0
+text = "?>"
+
+[node name="Text" type="LineEdit" parent="Terminal/Game/Input/Container"]
+margin_left = 28.0
+margin_right = 612.0
+margin_bottom = 45.0
+size_flags_horizontal = 3
+placeholder_text = "Command Input"
+
+[node name="Screen" type="CanvasLayer" parent="."]
+
+[node name="Shader" type="ColorRect" parent="Screen"]
+material = ExtResource( 1 )
anchor_right = 1.0
anchor_bottom = 1.0
+size_flags_horizontal = 3
+size_flags_vertical = 3
diff --git a/project.godot b/project.godot
index 7208175..9c03cd8 100644
--- a/project.godot
+++ b/project.godot
@@ -40,11 +40,21 @@ _global_script_class_icons={
config/name="Texty"
run/main_scene="res://Scenes/Texty.tscn"
+run/delta_sync_after_draw=true
config/icon="res://icon.png"
+[display]
+
+window/size/width=640
+window/size/height=480
+window/energy_saving/keep_screen_on=false
+window/stretch/mode="viewport"
+window/stretch/aspect="expand"
+
[editor]
script_templates_search_path="res://ScriptTemplates"
+version_control_autoload_on_startup=true
[editor_plugins]
@@ -53,6 +63,7 @@ enabled=PoolStringArray( "res://addons/ClassExporter/plugin.cfg", "res://addons/
[gui]
theme/use_hidpi=true
+theme/custom_font="res://Assets/Fonts/VT323Font24.tres"
[locale]
@@ -64,4 +75,5 @@ common/enable_pause_aware_picking=true
[rendering]
+quality/driver/driver_name="GLES2"
environment/default_environment="res://default_env.tres"