diff options
author | henriquelalves <henriquelalves@gmail.com> | 2024-09-03 00:57:02 +0300 |
---|---|---|
committer | henriquelalves <henriquelalves@gmail.com> | 2024-09-03 00:57:02 +0300 |
commit | 239cdf7a188ce6a38cca1aeb3dd55811d51e35b3 (patch) | |
tree | 868c2e7472a61a7512dd8ebca049439d0876b510 /addons/crt_shader | |
parent | 1b13dfdd3768c172c7c0abe644383df14de12fb6 (diff) | |
download | plugin-godot-simple-crt-shader-239cdf7a188ce6a38cca1aeb3dd55811d51e35b3.tar.gz plugin-godot-simple-crt-shader-239cdf7a188ce6a38cca1aeb3dd55811d51e35b3.tar.bz2 plugin-godot-simple-crt-shader-239cdf7a188ce6a38cca1aeb3dd55811d51e35b3.zip |
Updated the project for Godot 4.x
Diffstat (limited to 'addons/crt_shader')
-rw-r--r-- | addons/crt_shader/CRTCanvasLayer.tscn | 442 | ||||
-rw-r--r-- | addons/crt_shader/CRTFrame.png.import | 31 | ||||
-rw-r--r-- | addons/crt_shader/CRTShader.gd | 23 | ||||
-rw-r--r-- | addons/crt_shader/CRTShader.gdshader (renamed from addons/crt_shader/CRTShader.shader) | 38 | ||||
-rw-r--r-- | addons/crt_shader/ShaderScreen.material | bin | 392 -> 416 bytes | |||
-rw-r--r-- | addons/crt_shader/crt_screen.gd | 18 | ||||
-rw-r--r-- | addons/crt_shader/crt_shader.gd | 6 | ||||
-rw-r--r-- | addons/crt_shader/icon.png | bin | 0 -> 273950 bytes | |||
-rw-r--r-- | addons/crt_shader/icon.png.import | 34 |
9 files changed, 89 insertions, 503 deletions
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.shader b/addons/crt_shader/CRTShader.gdshader index d7e8afd..d7ca24f 100644 --- a/addons/crt_shader/CRTShader.shader +++ b/addons/crt_shader/CRTShader.gdshader @@ -1,5 +1,6 @@ shader_type canvas_item; +uniform sampler2D screen_texture : hint_screen_texture; uniform float screen_width = 1024; uniform float screen_height = 600; @@ -15,27 +16,27 @@ uniform float scan_size = 2.0; uniform float scanline_alpha = 0.9; uniform float lines_velocity = 30.0; -vec2 distort(vec2 p) +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)); + + 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); + 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); +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; } @@ -44,7 +45,7 @@ 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); @@ -52,14 +53,13 @@ void fragment() 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; + + 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 Binary files differindex b7432da..03171f3 100644 --- a/addons/crt_shader/ShaderScreen.material +++ b/addons/crt_shader/ShaderScreen.material 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 Binary files differnew file mode 100644 index 0000000..a39bb38 --- /dev/null +++ b/addons/crt_shader/icon.png 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 |