From 239cdf7a188ce6a38cca1aeb3dd55811d51e35b3 Mon Sep 17 00:00:00 2001 From: henriquelalves Date: Tue, 3 Sep 2024 00:57:02 +0300 Subject: Updated the project for Godot 4.x --- addons/crt_shader/CRTCanvasLayer.tscn | 442 -------------------------------- addons/crt_shader/CRTFrame.png.import | 31 ++- addons/crt_shader/CRTShader.gd | 23 -- addons/crt_shader/CRTShader.gdshader | 65 +++++ addons/crt_shader/CRTShader.shader | 65 ----- addons/crt_shader/ShaderScreen.material | Bin 392 -> 416 bytes addons/crt_shader/crt_screen.gd | 18 ++ addons/crt_shader/crt_shader.gd | 6 +- addons/crt_shader/icon.png | Bin 0 -> 273950 bytes addons/crt_shader/icon.png.import | 34 +++ 10 files changed, 135 insertions(+), 549 deletions(-) delete mode 100644 addons/crt_shader/CRTCanvasLayer.tscn delete mode 100644 addons/crt_shader/CRTShader.gd create mode 100644 addons/crt_shader/CRTShader.gdshader delete mode 100644 addons/crt_shader/CRTShader.shader create mode 100644 addons/crt_shader/crt_screen.gd create mode 100644 addons/crt_shader/icon.png create mode 100644 addons/crt_shader/icon.png.import (limited to 'addons/crt_shader') diff --git a/addons/crt_shader/CRTCanvasLayer.tscn b/addons/crt_shader/CRTCanvasLayer.tscn deleted file mode 100644 index 7292765..0000000 --- a/addons/crt_shader/CRTCanvasLayer.tscn +++ /dev/null @@ -1,442 +0,0 @@ -[gd_scene load_steps=8 format=2] - -[ext_resource path="res://addons/crt_shader/CRTShader.gd" type="Script" id=1] -[ext_resource path="res://addons/crt_shader/ShaderScreen.material" type="Material" id=2] -[ext_resource path="res://addons/crt_shader/CRTFrame.png" type="Texture" id=3] - -[sub_resource type="Animation" id=4] -resource_name = "Glitch" -length = 0.4 -step = 0.02 -tracks/0/type = "value" -tracks/0/path = NodePath(".:material:shader_param/BarrelPower") -tracks/0/interp = 1 -tracks/0/loop_wrap = true -tracks/0/imported = false -tracks/0/enabled = true -tracks/0/keys = { -"times": PoolRealArray( 0, 0.18, 0.2, 0.4 ), -"transitions": PoolRealArray( 1, 1, 1, 1 ), -"update": 0, -"values": [ 1.1, 1.1, 1.15, 1.1 ] -} -tracks/1/type = "value" -tracks/1/path = NodePath(".:material:shader_param/color_bleeding") -tracks/1/interp = 1 -tracks/1/loop_wrap = true -tracks/1/imported = false -tracks/1/enabled = true -tracks/1/keys = { -"times": PoolRealArray( 0, 0.16, 0.2, 0.4 ), -"transitions": PoolRealArray( 1, 1, 1, 1 ), -"update": 0, -"values": [ 2.0, 5.0, 5.0, 2.0 ] -} -tracks/2/type = "value" -tracks/2/path = NodePath(".:material:shader_param/bleeding_range_x") -tracks/2/interp = 1 -tracks/2/loop_wrap = true -tracks/2/imported = false -tracks/2/enabled = true -tracks/2/keys = { -"times": PoolRealArray( 0, 0.16, 0.2, 0.4 ), -"transitions": PoolRealArray( 1, 1, 1, 1 ), -"update": 0, -"values": [ 1.5, -4.0, -4.0, 1.5 ] -} -tracks/3/type = "value" -tracks/3/path = NodePath(".:material:shader_param/bleeding_range_y") -tracks/3/interp = 1 -tracks/3/loop_wrap = true -tracks/3/imported = false -tracks/3/enabled = true -tracks/3/keys = { -"times": PoolRealArray( 0, 0.16, 0.2, 0.4 ), -"transitions": PoolRealArray( 1, 1, 1, 1 ), -"update": 0, -"values": [ 1.5, -1.0, -1.0, 1.5 ] -} -tracks/4/type = "value" -tracks/4/path = NodePath(".:material:shader_param/lines_distance") -tracks/4/interp = 1 -tracks/4/loop_wrap = true -tracks/4/imported = false -tracks/4/enabled = true -tracks/4/keys = { -"times": PoolRealArray( 0, 0.16, 0.2, 0.4 ), -"transitions": PoolRealArray( 1, 1, 1, 1 ), -"update": 0, -"values": [ 3.0, 0.0, 0.0, 3.0 ] -} -tracks/5/type = "value" -tracks/5/path = NodePath(".:material:shader_param/scan_size") -tracks/5/interp = 1 -tracks/5/loop_wrap = true -tracks/5/imported = false -tracks/5/enabled = true -tracks/5/keys = { -"times": PoolRealArray( 0, 0.16, 0.2, 0.4 ), -"transitions": PoolRealArray( 1, 1, 1, 1 ), -"update": 0, -"values": [ 2.0, 1.0, 1.0, 2.0 ] -} -tracks/6/type = "value" -tracks/6/path = NodePath(".:material:shader_param/scanline_alpha") -tracks/6/interp = 1 -tracks/6/loop_wrap = true -tracks/6/imported = false -tracks/6/enabled = true -tracks/6/keys = { -"times": PoolRealArray( 0, 0.16, 0.2, 0.4 ), -"transitions": PoolRealArray( 1, 1, 1, 1 ), -"update": 0, -"values": [ 0.9, 0.0, 0.0, 0.9 ] -} -tracks/7/type = "value" -tracks/7/path = NodePath(".:material:shader_param/lines_velocity") -tracks/7/interp = 1 -tracks/7/loop_wrap = true -tracks/7/imported = false -tracks/7/enabled = true -tracks/7/keys = { -"times": PoolRealArray( 0, 0.16, 0.2, 0.4 ), -"transitions": PoolRealArray( 1, 1, 1, 1 ), -"update": 0, -"values": [ 40.0, 0.0, 0.0, 40.0 ] -} -tracks/8/type = "method" -tracks/8/path = NodePath(".") -tracks/8/interp = 1 -tracks/8/loop_wrap = true -tracks/8/imported = false -tracks/8/enabled = true -tracks/8/keys = { -"times": PoolRealArray( 0.18 ), -"transitions": PoolRealArray( 1 ), -"values": [ { -"args": [ ], -"method": "call_funcref" -} ] -} - -[sub_resource type="Animation" id=6] -resource_name = "GlitchLoop" -length = 0.6 -loop = true -step = 0.02 -tracks/0/type = "value" -tracks/0/path = NodePath(".:material:shader_param/BarrelPower") -tracks/0/interp = 1 -tracks/0/loop_wrap = true -tracks/0/imported = false -tracks/0/enabled = true -tracks/0/keys = { -"times": PoolRealArray( 0 ), -"transitions": PoolRealArray( 1 ), -"update": 0, -"values": [ 1.1 ] -} -tracks/1/type = "value" -tracks/1/path = NodePath(".:material:shader_param/color_bleeding") -tracks/1/interp = 1 -tracks/1/loop_wrap = true -tracks/1/imported = false -tracks/1/enabled = true -tracks/1/keys = { -"times": PoolRealArray( 0, 0.3, 0.34 ), -"transitions": PoolRealArray( 1, 1, 1 ), -"update": 0, -"values": [ 2.0, 3.0, 3.0 ] -} -tracks/2/type = "value" -tracks/2/path = NodePath(".:material:shader_param/bleeding_range_x") -tracks/2/interp = 1 -tracks/2/loop_wrap = true -tracks/2/imported = false -tracks/2/enabled = true -tracks/2/keys = { -"times": PoolRealArray( 0, 0.3, 0.34 ), -"transitions": PoolRealArray( 1, 1, 1 ), -"update": 0, -"values": [ 2.0, -4.0, -4.0 ] -} -tracks/3/type = "value" -tracks/3/path = NodePath(".:material:shader_param/bleeding_range_y") -tracks/3/interp = 1 -tracks/3/loop_wrap = true -tracks/3/imported = false -tracks/3/enabled = true -tracks/3/keys = { -"times": PoolRealArray( 0, 0.3, 0.34 ), -"transitions": PoolRealArray( 1, 1, 1 ), -"update": 0, -"values": [ 2.0, -2.0, -2.0 ] -} -tracks/4/type = "value" -tracks/4/path = NodePath(".:material:shader_param/lines_distance") -tracks/4/interp = 1 -tracks/4/loop_wrap = true -tracks/4/imported = false -tracks/4/enabled = true -tracks/4/keys = { -"times": PoolRealArray( 0 ), -"transitions": PoolRealArray( 1 ), -"update": 0, -"values": [ 3.0 ] -} -tracks/5/type = "value" -tracks/5/path = NodePath(".:material:shader_param/scan_size") -tracks/5/interp = 1 -tracks/5/loop_wrap = true -tracks/5/imported = false -tracks/5/enabled = true -tracks/5/keys = { -"times": PoolRealArray( 0, 0.3, 0.34 ), -"transitions": PoolRealArray( 1, 1, 1 ), -"update": 0, -"values": [ 3.0, 1.0, 1.0 ] -} -tracks/6/type = "value" -tracks/6/path = NodePath(".:material:shader_param/scanline_alpha") -tracks/6/interp = 1 -tracks/6/loop_wrap = true -tracks/6/imported = false -tracks/6/enabled = true -tracks/6/keys = { -"times": PoolRealArray( 0 ), -"transitions": PoolRealArray( 1 ), -"update": 0, -"values": [ 0.8 ] -} -tracks/7/type = "value" -tracks/7/path = NodePath(".:material:shader_param/lines_velocity") -tracks/7/interp = 1 -tracks/7/loop_wrap = true -tracks/7/imported = false -tracks/7/enabled = true -tracks/7/keys = { -"times": PoolRealArray( 0, 0.3, 0.34 ), -"transitions": PoolRealArray( 1, 1, 1 ), -"update": 0, -"values": [ 20.0, 0.0, 0.0 ] -} - -[sub_resource type="Animation" id=7] -resource_name = "Glitch_Start" -length = 0.22 -step = 0.02 -tracks/0/type = "value" -tracks/0/path = NodePath(".:material:shader_param/BarrelPower") -tracks/0/interp = 1 -tracks/0/loop_wrap = true -tracks/0/imported = false -tracks/0/enabled = true -tracks/0/keys = { -"times": PoolRealArray( 0, 0.02, 0.22 ), -"transitions": PoolRealArray( 1, 1, 1 ), -"update": 0, -"values": [ 1.1, 1.15, 1.1 ] -} -tracks/1/type = "value" -tracks/1/path = NodePath(".:material:shader_param/color_bleeding") -tracks/1/interp = 1 -tracks/1/loop_wrap = true -tracks/1/imported = false -tracks/1/enabled = true -tracks/1/keys = { -"times": PoolRealArray( 0, 0.02, 0.22 ), -"transitions": PoolRealArray( 1, 1, 1 ), -"update": 0, -"values": [ 5.0, 5.0, 2.0 ] -} -tracks/2/type = "value" -tracks/2/path = NodePath(".:material:shader_param/bleeding_range_x") -tracks/2/interp = 1 -tracks/2/loop_wrap = true -tracks/2/imported = false -tracks/2/enabled = true -tracks/2/keys = { -"times": PoolRealArray( 0, 0.02, 0.22 ), -"transitions": PoolRealArray( 1, 1, 1 ), -"update": 0, -"values": [ -4.0, -4.0, 1.5 ] -} -tracks/3/type = "value" -tracks/3/path = NodePath(".:material:shader_param/bleeding_range_y") -tracks/3/interp = 1 -tracks/3/loop_wrap = true -tracks/3/imported = false -tracks/3/enabled = true -tracks/3/keys = { -"times": PoolRealArray( 0, 0.02, 0.22 ), -"transitions": PoolRealArray( 1, 1, 1 ), -"update": 0, -"values": [ -1.0, -1.0, 1.5 ] -} -tracks/4/type = "value" -tracks/4/path = NodePath(".:material:shader_param/lines_distance") -tracks/4/interp = 1 -tracks/4/loop_wrap = true -tracks/4/imported = false -tracks/4/enabled = true -tracks/4/keys = { -"times": PoolRealArray( 0, 0.02, 0.22 ), -"transitions": PoolRealArray( 1, 1, 1 ), -"update": 0, -"values": [ 0.0, 0.0, 3.0 ] -} -tracks/5/type = "value" -tracks/5/path = NodePath(".:material:shader_param/scan_size") -tracks/5/interp = 1 -tracks/5/loop_wrap = true -tracks/5/imported = false -tracks/5/enabled = true -tracks/5/keys = { -"times": PoolRealArray( 0, 0.02, 0.22 ), -"transitions": PoolRealArray( 1, 1, 1 ), -"update": 0, -"values": [ 1.0, 1.0, 2.0 ] -} -tracks/6/type = "value" -tracks/6/path = NodePath(".:material:shader_param/scanline_alpha") -tracks/6/interp = 1 -tracks/6/loop_wrap = true -tracks/6/imported = false -tracks/6/enabled = true -tracks/6/keys = { -"times": PoolRealArray( 0, 0.02, 0.22 ), -"transitions": PoolRealArray( 1, 1, 1 ), -"update": 0, -"values": [ 0.0, 0.0, 0.9 ] -} -tracks/7/type = "value" -tracks/7/path = NodePath(".:material:shader_param/lines_velocity") -tracks/7/interp = 1 -tracks/7/loop_wrap = true -tracks/7/imported = false -tracks/7/enabled = true -tracks/7/keys = { -"times": PoolRealArray( 0, 0.02, 0.22 ), -"transitions": PoolRealArray( 1, 1, 1 ), -"update": 0, -"values": [ 0.0, 0.0, 40.0 ] -} - -[sub_resource type="Animation" id=5] -length = 0.001 -tracks/0/type = "value" -tracks/0/path = NodePath(".:material:shader_param/BarrelPower") -tracks/0/interp = 1 -tracks/0/loop_wrap = true -tracks/0/imported = false -tracks/0/enabled = true -tracks/0/keys = { -"times": PoolRealArray( 0 ), -"transitions": PoolRealArray( 1 ), -"update": 0, -"values": [ 1.1 ] -} -tracks/1/type = "value" -tracks/1/path = NodePath(".:material:shader_param/color_bleeding") -tracks/1/interp = 1 -tracks/1/loop_wrap = true -tracks/1/imported = false -tracks/1/enabled = true -tracks/1/keys = { -"times": PoolRealArray( 0 ), -"transitions": PoolRealArray( 1 ), -"update": 0, -"values": [ 2.0 ] -} -tracks/2/type = "value" -tracks/2/path = NodePath(".:material:shader_param/bleeding_range_x") -tracks/2/interp = 1 -tracks/2/loop_wrap = true -tracks/2/imported = false -tracks/2/enabled = true -tracks/2/keys = { -"times": PoolRealArray( 0 ), -"transitions": PoolRealArray( 1 ), -"update": 0, -"values": [ 1.5 ] -} -tracks/3/type = "value" -tracks/3/path = NodePath(".:material:shader_param/bleeding_range_y") -tracks/3/interp = 1 -tracks/3/loop_wrap = true -tracks/3/imported = false -tracks/3/enabled = true -tracks/3/keys = { -"times": PoolRealArray( 0 ), -"transitions": PoolRealArray( 1 ), -"update": 0, -"values": [ 1.5 ] -} -tracks/4/type = "value" -tracks/4/path = NodePath(".:material:shader_param/lines_distance") -tracks/4/interp = 1 -tracks/4/loop_wrap = true -tracks/4/imported = false -tracks/4/enabled = true -tracks/4/keys = { -"times": PoolRealArray( 0 ), -"transitions": PoolRealArray( 1 ), -"update": 0, -"values": [ 3.0 ] -} -tracks/5/type = "value" -tracks/5/path = NodePath(".:material:shader_param/scan_size") -tracks/5/interp = 1 -tracks/5/loop_wrap = true -tracks/5/imported = false -tracks/5/enabled = true -tracks/5/keys = { -"times": PoolRealArray( 0 ), -"transitions": PoolRealArray( 1 ), -"update": 0, -"values": [ 2.0 ] -} -tracks/6/type = "value" -tracks/6/path = NodePath(".:material:shader_param/scanline_alpha") -tracks/6/interp = 1 -tracks/6/loop_wrap = true -tracks/6/imported = false -tracks/6/enabled = true -tracks/6/keys = { -"times": PoolRealArray( 0 ), -"transitions": PoolRealArray( 1 ), -"update": 0, -"values": [ 0.9 ] -} -tracks/7/type = "value" -tracks/7/path = NodePath(".:material:shader_param/lines_velocity") -tracks/7/interp = 1 -tracks/7/loop_wrap = true -tracks/7/imported = false -tracks/7/enabled = true -tracks/7/keys = { -"times": PoolRealArray( 0 ), -"transitions": PoolRealArray( 1 ), -"update": 0, -"values": [ 40.0 ] -} - -[node name="CRTCanvasLayer" type="CanvasLayer"] - -[node name="CRTShader" type="ColorRect" parent="."] -material = ExtResource( 2 ) -anchor_right = 1.0 -anchor_bottom = 1.0 -script = ExtResource( 1 ) - -[node name="GlitchAnimation" type="AnimationPlayer" parent="CRTShader"] -anims/Glitch = SubResource( 4 ) -anims/GlitchLoop = SubResource( 6 ) -anims/Glitch_Start = SubResource( 7 ) -anims/RESET = SubResource( 5 ) - -[node name="FrameTexture" type="TextureRect" parent="."] -anchor_right = 1.0 -anchor_bottom = 1.0 -texture = ExtResource( 3 ) -expand = true diff --git a/addons/crt_shader/CRTFrame.png.import b/addons/crt_shader/CRTFrame.png.import index 0ecb5d8..8a3d11d 100644 --- a/addons/crt_shader/CRTFrame.png.import +++ b/addons/crt_shader/CRTFrame.png.import @@ -1,8 +1,9 @@ [remap] importer="texture" -type="StreamTexture" -path="res://.import/CRTFrame.png-872eedb156a5c6ffe1f1a64a1e49445b.stex" +type="CompressedTexture2D" +uid="uid://b7rrbl58e5lm6" +path="res://.godot/imported/CRTFrame.png-872eedb156a5c6ffe1f1a64a1e49445b.ctex" metadata={ "vram_texture": false } @@ -10,26 +11,24 @@ metadata={ [deps] source_file="res://addons/crt_shader/CRTFrame.png" -dest_files=[ "res://.import/CRTFrame.png-872eedb156a5c6ffe1f1a64a1e49445b.stex" ] +dest_files=["res://.godot/imported/CRTFrame.png-872eedb156a5c6ffe1f1a64a1e49445b.ctex"] [params] compress/mode=0 +compress/high_quality=false compress/lossy_quality=0.7 -compress/hdr_mode=0 -compress/bptc_ldr=0 +compress/hdr_compression=1 compress/normal_map=0 -flags/repeat=0 -flags/filter=true -flags/mipmaps=false -flags/anisotropic=false -flags/srgb=2 +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/HDR_as_SRGB=false -process/invert_color=false process/normal_map_invert_y=false -stream=false -size_limit=0 -detect_3d=true -svg/scale=1.0 +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/addons/crt_shader/CRTShader.gd b/addons/crt_shader/CRTShader.gd deleted file mode 100644 index 464b275..0000000 --- a/addons/crt_shader/CRTShader.gd +++ /dev/null @@ -1,23 +0,0 @@ -extends ColorRect - -onready var glitch_loop = false -onready var fun = null - -func _ready(): - $GlitchAnimation.connect("animation_finished", self, "_on_animation_finished") - -func _on_animation_finished(anim): - if anim == "Glitch" and glitch_loop: - $GlitchAnimation.play("GlitchLoop") - -func start_glitch_loop(): - $GlitchAnimation.play("GlitchLoop") - glitch_loop = true - -func tween(fun : FuncRef, force = false): - if not force and $GlitchAnimation.is_playing() and $GlitchAnimation.current_animation == "Glitch": return - $GlitchAnimation.play("Glitch") - self.fun = fun - -func call_funcref(): - if fun: fun.call_func() diff --git a/addons/crt_shader/CRTShader.gdshader b/addons/crt_shader/CRTShader.gdshader new file mode 100644 index 0000000..d7ca24f --- /dev/null +++ b/addons/crt_shader/CRTShader.gdshader @@ -0,0 +1,65 @@ +shader_type canvas_item; + +uniform sampler2D screen_texture : hint_screen_texture; +uniform float screen_width = 1024; +uniform float screen_height = 600; + +// Curvature +uniform float BarrelPower =1.1; +// Color bleeding +uniform float color_bleeding = 1.2; +uniform float bleeding_range_x = 3; +uniform float bleeding_range_y = 3; +// Scanline +uniform float lines_distance = 4.0; +uniform float scan_size = 2.0; +uniform float scanline_alpha = 0.9; +uniform float lines_velocity = 30.0; + +vec2 distort(vec2 p) +{ + float angle = p.y / p.x; + float theta = atan(p.y,p.x); + float radius = pow(length(p), BarrelPower); + + p.x = radius * cos(theta); + p.y = radius * sin(theta); + + return 0.5 * (p + vec2(1.0, 1.0)); +} + +void get_color_bleeding(inout vec4 current_color,inout vec4 color_left){ + current_color = current_color * vec4(color_bleeding, 0.5, 1.0 - color_bleeding, 1); + color_left = color_left * vec4(1.0 - color_bleeding, 0.5, color_bleeding, 1); +} + +void get_color_scanline(vec2 uv, inout vec4 c, float time){ + float line_row = floor((uv.y * screen_height/scan_size) + mod(time * lines_velocity, lines_distance)); + float n = 1.0 - ceil( (mod(line_row,lines_distance) / lines_distance)); + c = c - n * c * (1.0 - scanline_alpha); + c.a = 1.0; +} + +void fragment() +{ + vec2 xy = SCREEN_UV * 2.0; + xy.x -= 1.0; + xy.y -= 1.0; + + float d = length(xy); + if(d < 1.5){ + xy = distort(xy); + } + else{ + xy = SCREEN_UV; + } + + float pixel_size_x = 1.0/screen_width * bleeding_range_x; + float pixel_size_y = 1.0/screen_height * bleeding_range_y; + vec4 color_left = texture(screen_texture, xy - vec2(pixel_size_x, pixel_size_y)); + vec4 current_color = texture(screen_texture, xy); + get_color_bleeding(current_color, color_left); + vec4 c = current_color + color_left; + get_color_scanline(xy,c,TIME); + COLOR = c; +} diff --git a/addons/crt_shader/CRTShader.shader b/addons/crt_shader/CRTShader.shader deleted file mode 100644 index d7e8afd..0000000 --- a/addons/crt_shader/CRTShader.shader +++ /dev/null @@ -1,65 +0,0 @@ -shader_type canvas_item; - -uniform float screen_width = 1024; -uniform float screen_height = 600; - -// Curvature -uniform float BarrelPower =1.1; -// Color bleeding -uniform float color_bleeding = 1.2; -uniform float bleeding_range_x = 3; -uniform float bleeding_range_y = 3; -// Scanline -uniform float lines_distance = 4.0; -uniform float scan_size = 2.0; -uniform float scanline_alpha = 0.9; -uniform float lines_velocity = 30.0; - -vec2 distort(vec2 p) -{ - float angle = p.y / p.x; - float theta = atan(p.y,p.x); - float radius = pow(length(p), BarrelPower); - - p.x = radius * cos(theta); - p.y = radius * sin(theta); - - return 0.5 * (p + vec2(1.0,1.0)); -} - -void get_color_bleeding(inout vec4 current_color,inout vec4 color_left){ - current_color = current_color*vec4(color_bleeding,0.5,1.0-color_bleeding,1); - color_left = color_left*vec4(1.0-color_bleeding,0.5,color_bleeding,1); -} - -void get_color_scanline(vec2 uv,inout vec4 c,float time){ - float line_row = floor((uv.y * screen_height/scan_size) + mod(time*lines_velocity, lines_distance)); - float n = 1.0 - ceil((mod(line_row,lines_distance)/lines_distance)); - c = c - n*c*(1.0 - scanline_alpha); - c.a = 1.0; -} - -void fragment() -{ - vec2 xy = SCREEN_UV * 2.0; - xy.x -= 1.0; - xy.y -= 1.0; - - float d = length(xy); - if(d < 1.5){ - xy = distort(xy); - } - else{ - xy = SCREEN_UV; - } - - float pixel_size_x = 1.0/screen_width*bleeding_range_x; - float pixel_size_y = 1.0/screen_height*bleeding_range_y; - vec4 color_left = texture(SCREEN_TEXTURE,xy - vec2(pixel_size_x, pixel_size_y)); - vec4 current_color = texture(SCREEN_TEXTURE,xy); - get_color_bleeding(current_color,color_left); - vec4 c = current_color+color_left; - get_color_scanline(xy,c,TIME); - COLOR = c; - -} diff --git a/addons/crt_shader/ShaderScreen.material b/addons/crt_shader/ShaderScreen.material index b7432da..03171f3 100644 Binary files a/addons/crt_shader/ShaderScreen.material and b/addons/crt_shader/ShaderScreen.material differ diff --git a/addons/crt_shader/crt_screen.gd b/addons/crt_shader/crt_screen.gd new file mode 100644 index 0000000..5674626 --- /dev/null +++ b/addons/crt_shader/crt_screen.gd @@ -0,0 +1,18 @@ +@tool +extends ColorRect + +const ShaderScreenMaterial: ShaderMaterial = preload("res://addons/crt_shader/ShaderScreen.material") + + +func _ready() -> void: + if material == null: + material = ShaderScreenMaterial + + item_rect_changed.connect(_update_screen_parameters) + _update_screen_parameters() + + +func _update_screen_parameters(): + var shader_material : ShaderMaterial = material + shader_material.set_shader_parameter("screen_width", size.x) + shader_material.set_shader_parameter("screen_height", size.y) diff --git a/addons/crt_shader/crt_shader.gd b/addons/crt_shader/crt_shader.gd index 49e712e..50053a9 100644 --- a/addons/crt_shader/crt_shader.gd +++ b/addons/crt_shader/crt_shader.gd @@ -1,10 +1,10 @@ -tool +@tool extends EditorPlugin func _enter_tree(): - pass + add_custom_type("CRTScreen", "ColorRect", preload("res://addons/crt_shader/crt_screen.gd"), preload("res://addons/crt_shader/icon.png")) func _exit_tree(): - pass + remove_custom_type("CRTScreen") diff --git a/addons/crt_shader/icon.png b/addons/crt_shader/icon.png new file mode 100644 index 0000000..a39bb38 Binary files /dev/null and b/addons/crt_shader/icon.png differ diff --git a/addons/crt_shader/icon.png.import b/addons/crt_shader/icon.png.import new file mode 100644 index 0000000..853d9fd --- /dev/null +++ b/addons/crt_shader/icon.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://c7pxefljbvdfo" +path="res://.godot/imported/icon.png-258ab7dc402d28bf674efd9b9f590b1f.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://addons/crt_shader/icon.png" +dest_files=["res://.godot/imported/icon.png-258ab7dc402d28bf674efd9b9f590b1f.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 -- cgit v1.2.3