summaryrefslogtreecommitdiff
path: root/addons/crt_shader
diff options
context:
space:
mode:
authorHenrique Alves <henriquelalves@gmail.com>2022-07-26 13:01:56 -0300
committerHenrique Alves <henriquelalves@gmail.com>2022-07-26 13:01:56 -0300
commit0edaddac2193bb84de5b9bd915ac9264de6fe8e8 (patch)
tree7cb700c3ddb1027072ad6f0b9dc20f400f79892b /addons/crt_shader
parentd9a49f12fc1dce1c2ea04c157bc5ef4bff5e3b2e (diff)
downloadplugin-godot-simple-crt-shader-0edaddac2193bb84de5b9bd915ac9264de6fe8e8.tar.gz
plugin-godot-simple-crt-shader-0edaddac2193bb84de5b9bd915ac9264de6fe8e8.tar.bz2
plugin-godot-simple-crt-shader-0edaddac2193bb84de5b9bd915ac9264de6fe8e8.zip
created addon folder
Diffstat (limited to 'addons/crt_shader')
-rw-r--r--addons/crt_shader/CRTFrame.pngbin0 -> 17559 bytes
-rw-r--r--addons/crt_shader/CRTFrame.png.import35
-rw-r--r--addons/crt_shader/CRTShader.shader65
-rw-r--r--addons/crt_shader/ShaderScreen.materialbin0 -> 395 bytes
-rw-r--r--addons/crt_shader/crt_shader.gd10
-rw-r--r--addons/crt_shader/plugin.cfg7
6 files changed, 117 insertions, 0 deletions
diff --git a/addons/crt_shader/CRTFrame.png b/addons/crt_shader/CRTFrame.png
new file mode 100644
index 0000000..9c5ca46
--- /dev/null
+++ b/addons/crt_shader/CRTFrame.png
Binary files differ
diff --git a/addons/crt_shader/CRTFrame.png.import b/addons/crt_shader/CRTFrame.png.import
new file mode 100644
index 0000000..0ecb5d8
--- /dev/null
+++ b/addons/crt_shader/CRTFrame.png.import
@@ -0,0 +1,35 @@
+[remap]
+
+importer="texture"
+type="StreamTexture"
+path="res://.import/CRTFrame.png-872eedb156a5c6ffe1f1a64a1e49445b.stex"
+metadata={
+"vram_texture": false
+}
+
+[deps]
+
+source_file="res://addons/crt_shader/CRTFrame.png"
+dest_files=[ "res://.import/CRTFrame.png-872eedb156a5c6ffe1f1a64a1e49445b.stex" ]
+
+[params]
+
+compress/mode=0
+compress/lossy_quality=0.7
+compress/hdr_mode=0
+compress/bptc_ldr=0
+compress/normal_map=0
+flags/repeat=0
+flags/filter=true
+flags/mipmaps=false
+flags/anisotropic=false
+flags/srgb=2
+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
diff --git a/addons/crt_shader/CRTShader.shader b/addons/crt_shader/CRTShader.shader
new file mode 100644
index 0000000..d7e8afd
--- /dev/null
+++ b/addons/crt_shader/CRTShader.shader
@@ -0,0 +1,65 @@
+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
new file mode 100644
index 0000000..6ca3664
--- /dev/null
+++ b/addons/crt_shader/ShaderScreen.material
Binary files differ
diff --git a/addons/crt_shader/crt_shader.gd b/addons/crt_shader/crt_shader.gd
new file mode 100644
index 0000000..49e712e
--- /dev/null
+++ b/addons/crt_shader/crt_shader.gd
@@ -0,0 +1,10 @@
+tool
+extends EditorPlugin
+
+
+func _enter_tree():
+ pass
+
+
+func _exit_tree():
+ pass
diff --git a/addons/crt_shader/plugin.cfg b/addons/crt_shader/plugin.cfg
new file mode 100644
index 0000000..a267e3e
--- /dev/null
+++ b/addons/crt_shader/plugin.cfg
@@ -0,0 +1,7 @@
+[plugin]
+
+name="CRT Shader"
+description="A Simple CRT Shader material"
+author="Henrique Alves"
+version="1.0"
+script="crt_shader.gd"