diff --git a/Shaders/GodotRetro/Object Shaders/Debug/helloworld-2d.gdshader b/Shaders/GodotRetro/Object Shaders/Debug/helloworld-2d.gdshader new file mode 100644 index 00000000..b8731f89 --- /dev/null +++ b/Shaders/GodotRetro/Object Shaders/Debug/helloworld-2d.gdshader @@ -0,0 +1,12 @@ +//SHADER GRABED FROM THE BOOK OF SHADERS +//PORTED AND MODIFYED TO GODOT BY AHOPNESS (@ahopness) +//LICENSE : CC0 +//SHADERTOY LINK : https://thebookofshaders.com/edit.php#03/space.frag + +shader_type canvas_item; + +void fragment(){ + vec2 st = UV; + vec4 final = vec4(st.x, st.y, 0.0, 1.0); + COLOR = final; +} \ No newline at end of file diff --git a/Shaders/GodotRetro/Object Shaders/Debug/helloworld-2d.gdshader.uid b/Shaders/GodotRetro/Object Shaders/Debug/helloworld-2d.gdshader.uid new file mode 100644 index 00000000..97cb05d0 --- /dev/null +++ b/Shaders/GodotRetro/Object Shaders/Debug/helloworld-2d.gdshader.uid @@ -0,0 +1 @@ +uid://8as2y65btjp4 diff --git a/Shaders/GodotRetro/Object Shaders/Debug/helloworld.gdshader b/Shaders/GodotRetro/Object Shaders/Debug/helloworld.gdshader new file mode 100644 index 00000000..4b305bc7 --- /dev/null +++ b/Shaders/GodotRetro/Object Shaders/Debug/helloworld.gdshader @@ -0,0 +1,13 @@ +//SHADER GRABED FROM THE BOOK OF SHADERS +//PORTED AND MODIFYED TO GODOT BY AHOPNESS (@ahopness) +//LICENSE : CC0 +//SHADERTOY LINK : https://thebookofshaders.com/edit.php#03/space.frag + +shader_type spatial; +render_mode cull_disabled, specular_disabled, diffuse_lambert; + +void fragment(){ + vec2 st = UV; + vec3 final = vec3(st.x, st.y, 0.0); + ALBEDO = final; +} \ No newline at end of file diff --git a/Shaders/GodotRetro/Object Shaders/Debug/helloworld.gdshader.uid b/Shaders/GodotRetro/Object Shaders/Debug/helloworld.gdshader.uid new file mode 100644 index 00000000..3dfc6cda --- /dev/null +++ b/Shaders/GodotRetro/Object Shaders/Debug/helloworld.gdshader.uid @@ -0,0 +1 @@ +uid://d2ih5u13312pd diff --git a/Shaders/GodotRetro/Object Shaders/Debug/helloworld2-2d.gdshader b/Shaders/GodotRetro/Object Shaders/Debug/helloworld2-2d.gdshader new file mode 100644 index 00000000..b7d3256a --- /dev/null +++ b/Shaders/GodotRetro/Object Shaders/Debug/helloworld2-2d.gdshader @@ -0,0 +1,31 @@ +//SHADER GRABED FROM THE BOOK OF SHADERS +//PORTED AND MODIFYED TO GODOT BY AHOPNESS (@ahopness) +//LICENSE : CC0 +//SHADERTOY LINK : https://thebookofshaders.com/edit.php#06/hsb-colorwheel.frag + +shader_type canvas_item; + +const float TWO_PI = 6.28318530718; + +vec3 hsb2rgb( in vec3 c ){ + vec3 rgb = clamp(abs(mod(c.x*6.0+vec3(0.0,4.0,2.0), + 6.0)-3.0)-1.0, + 0.0, + 1.0 ); + rgb = rgb*rgb*(3.0-2.0*rgb); + return c.z * mix( vec3(1.0), rgb, c.y); +} + +void fragment(){ + vec2 st = UV; + vec3 color = vec3(0.0); + + // Use polar coordinates instead of cartesian + vec2 toCenter = vec2(0.5)-st; + float angle = atan(toCenter.y,toCenter.x); + float radius = length(toCenter)*2.0; + + // Map the angle (-PI to PI) to the Hue (from 0 to 1) + // and the Saturation to the radius + COLOR = vec4(hsb2rgb(vec3((angle/TWO_PI)+0.5,radius,1.0)), 1); +} \ No newline at end of file diff --git a/Shaders/GodotRetro/Object Shaders/Debug/helloworld2-2d.gdshader.uid b/Shaders/GodotRetro/Object Shaders/Debug/helloworld2-2d.gdshader.uid new file mode 100644 index 00000000..9631328f --- /dev/null +++ b/Shaders/GodotRetro/Object Shaders/Debug/helloworld2-2d.gdshader.uid @@ -0,0 +1 @@ +uid://d3a6phlfxob2t diff --git a/Shaders/GodotRetro/Object Shaders/Debug/helloworld2.gdshader b/Shaders/GodotRetro/Object Shaders/Debug/helloworld2.gdshader new file mode 100644 index 00000000..72f05709 --- /dev/null +++ b/Shaders/GodotRetro/Object Shaders/Debug/helloworld2.gdshader @@ -0,0 +1,34 @@ +//SHADER GRABED FROM THE BOOK OF SHADERS +//PORTED AND MODIFYED TO GODOT BY AHOPNESS (@ahopness) +//LICENSE : CC0 +//SHADERTOY LINK : https://thebookofshaders.com/edit.php#06/hsb-colorwheel.frag + +shader_type spatial; +render_mode cull_disabled, specular_disabled, diffuse_lambert, unshaded; + +const float TWO_PI = 6.28318530718; + +vec3 hsb2rgb( in vec3 c ){ + vec3 rgb = clamp(abs(mod(c.x*6.0+vec3(0.0,4.0,2.0), + 6.0)-3.0)-1.0, + 0.0, + 1.0 ); + rgb = rgb*rgb*(3.0-2.0*rgb); + return c.z * mix( vec3(1.0), rgb, c.y); +} + +void fragment(){ + vec2 st = UV; + vec3 color = vec3(0.0); + + // Use polar coordinates instead of cartesian + vec2 toCenter = vec2(0.5)-st; + float angle = atan(toCenter.y,toCenter.x); + float radius = length(toCenter)*2.0; + + // Map the angle (-PI to PI) to the Hue (from 0 to 1) + // and the Saturation to the radius + color = hsb2rgb(vec3((angle/TWO_PI)+0.5,radius,1.0)); + + ALBEDO = color; +} \ No newline at end of file diff --git a/Shaders/GodotRetro/Object Shaders/Debug/helloworld2.gdshader.uid b/Shaders/GodotRetro/Object Shaders/Debug/helloworld2.gdshader.uid new file mode 100644 index 00000000..7b2f1348 --- /dev/null +++ b/Shaders/GodotRetro/Object Shaders/Debug/helloworld2.gdshader.uid @@ -0,0 +1 @@ +uid://c1jm0ircxs1gf diff --git a/Shaders/GodotRetro/Object Shaders/PSX Shaders/psx_lit.gdshader b/Shaders/GodotRetro/Object Shaders/PSX Shaders/psx_lit.gdshader new file mode 100644 index 00000000..3e942889 --- /dev/null +++ b/Shaders/GodotRetro/Object Shaders/PSX Shaders/psx_lit.gdshader @@ -0,0 +1,38 @@ +//SHADER ORIGINALY CREADED BY "marmitoTH" FROM GITHUB +// +//GITHUB LINK : https://github.com/marmitoTH/godot-psx-shaders + +shader_type spatial; +render_mode skip_vertex_transform, diffuse_lambert_wrap, specular_disabled, cull_disabled, depth_draw_opaque; + +uniform vec4 color : source_color; +uniform sampler2D albedoTex : filter_nearest, repeat_enable; +uniform float specular_intensity : hint_range(0, 1); +uniform float resolution = 256; +uniform float cull_distance = 5; +uniform float affine_texture_mapping_amount : hint_range(0,2); +uniform vec2 uv_scale = vec2(1.0, 1.0); +uniform vec2 uv_offset = vec2(.0, .0); + +varying vec4 vertex_coordinates; + +void vertex() { + UV = UV * uv_scale + uv_offset; + + float vertex_distance = length((MODELVIEW_MATRIX * vec4(VERTEX, 1.0))); + + VERTEX = (MODELVIEW_MATRIX * vec4(VERTEX, 1.0)).xyz; + float vPos_w = (PROJECTION_MATRIX * vec4(VERTEX, 1.0)).w; + VERTEX.xy = vPos_w * floor(resolution * VERTEX.xy / vPos_w) / resolution; + vertex_coordinates = vec4(UV * VERTEX.z, VERTEX.z, .0); + + if (vertex_distance > cull_distance) + VERTEX = vec3(.0); +} + +void fragment() { + vec4 tex = texture(albedoTex, mix(vertex_coordinates.xy /vertex_coordinates.z, UV.xy, affine_texture_mapping_amount)); + + ALBEDO = tex.rgb * color.rgb; + SPECULAR = specular_intensity; +} \ No newline at end of file diff --git a/Shaders/GodotRetro/Object Shaders/PSX Shaders/psx_lit.gdshader.uid b/Shaders/GodotRetro/Object Shaders/PSX Shaders/psx_lit.gdshader.uid new file mode 100644 index 00000000..60f80e27 --- /dev/null +++ b/Shaders/GodotRetro/Object Shaders/PSX Shaders/psx_lit.gdshader.uid @@ -0,0 +1 @@ +uid://c1smrkliedgrn diff --git a/Shaders/GodotRetro/Object Shaders/PSX Shaders/psx_unlit.gdshader b/Shaders/GodotRetro/Object Shaders/PSX Shaders/psx_unlit.gdshader new file mode 100644 index 00000000..60e067fe --- /dev/null +++ b/Shaders/GodotRetro/Object Shaders/PSX Shaders/psx_unlit.gdshader @@ -0,0 +1,39 @@ +//SHADER ORIGINALY CREADED BY "marmitoTH" FROM GITHUB +// +//GITHUB LINK : https://github.com/marmitoTH/godot-psx-shaders + +shader_type spatial; +render_mode skip_vertex_transform, diffuse_lambert_wrap, specular_disabled, cull_disabled, unshaded, depth_draw_opaque; + +uniform vec4 color : source_color; +uniform sampler2D albedoTex : filter_nearest; +uniform float specular_intensity : hint_range(0, 1); +uniform float resolution = 256; +uniform float cull_distance = 5; +uniform float affine_texture_mapping_amount : hint_range(0,2); +uniform vec2 uv_scale = vec2(1.0, 1.0); +uniform vec2 uv_offset = vec2(.0, .0); + +varying vec4 vertex_coordinates; + +void vertex() { + UV = UV * uv_scale + uv_offset; + + float vertex_distance = length((MODELVIEW_MATRIX * vec4(VERTEX, 1.0))); + + VERTEX = (MODELVIEW_MATRIX * vec4(VERTEX, 1.0)).xyz; + float vPos_w = (PROJECTION_MATRIX * vec4(VERTEX, 1.0)).w; + VERTEX.xy = vPos_w * floor(resolution * VERTEX.xy / vPos_w) / resolution; + vertex_coordinates = vec4(UV * VERTEX.z, VERTEX.z, .0); + + if (vertex_distance > cull_distance) + VERTEX = vec3(.0); +} + +void fragment() { + vec4 tex = texture(albedoTex, mix(vertex_coordinates.xy /vertex_coordinates.z, UV.xy, affine_texture_mapping_amount)); + + ALBEDO = tex.rgb * color.rgb; + ALPHA = tex.a * color.a; + SPECULAR = specular_intensity; +} \ No newline at end of file diff --git a/Shaders/GodotRetro/Object Shaders/PSX Shaders/psx_unlit.gdshader.uid b/Shaders/GodotRetro/Object Shaders/PSX Shaders/psx_unlit.gdshader.uid new file mode 100644 index 00000000..a501a17c --- /dev/null +++ b/Shaders/GodotRetro/Object Shaders/PSX Shaders/psx_unlit.gdshader.uid @@ -0,0 +1 @@ +uid://ftf15wwqpgg diff --git a/Shaders/GodotRetro/Other/Images/CRT Frame.png b/Shaders/GodotRetro/Other/Images/CRT Frame.png new file mode 100644 index 00000000..a7d342dd --- /dev/null +++ b/Shaders/GodotRetro/Other/Images/CRT Frame.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c0d0dc6d59409a9405ff004b4fc13441b8cce011065fd591af5e76810122a640 +size 17559 diff --git a/Shaders/GodotRetro/Other/Images/CRT Frame.png.import b/Shaders/GodotRetro/Other/Images/CRT Frame.png.import new file mode 100644 index 00000000..7aa378cb --- /dev/null +++ b/Shaders/GodotRetro/Other/Images/CRT Frame.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://b7ciqwsttyf1i" +path="res://.godot/imported/CRT Frame.png-5ac35b1477fd9c4f06d001f8fbb56c36.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Shaders/GodotRetro/Other/Images/CRT Frame.png" +dest_files=["res://.godot/imported/CRT Frame.png-5ac35b1477fd9c4f06d001f8fbb56c36.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/uastc_level=0 +compress/rdo_quality_loss=0.0 +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/channel_remap/red=0 +process/channel_remap/green=1 +process/channel_remap/blue=2 +process/channel_remap/alpha=3 +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 diff --git a/Shaders/GodotRetro/Other/Images/bayer2x2.png b/Shaders/GodotRetro/Other/Images/bayer2x2.png new file mode 100644 index 00000000..b5de5dd0 --- /dev/null +++ b/Shaders/GodotRetro/Other/Images/bayer2x2.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c72ba6befd461e7436e30bfe2d58dc1c978b60dcd6491162c0a77b74472e4a82 +size 79 diff --git a/Shaders/GodotRetro/Other/Images/bayer2x2.png.import b/Shaders/GodotRetro/Other/Images/bayer2x2.png.import new file mode 100644 index 00000000..869e672b --- /dev/null +++ b/Shaders/GodotRetro/Other/Images/bayer2x2.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dqkxv17ex71c" +path="res://.godot/imported/bayer2x2.png-a0dd2d4f112145fde0fcc29485409834.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Shaders/GodotRetro/Other/Images/bayer2x2.png" +dest_files=["res://.godot/imported/bayer2x2.png-a0dd2d4f112145fde0fcc29485409834.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/uastc_level=0 +compress/rdo_quality_loss=0.0 +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/channel_remap/red=0 +process/channel_remap/green=1 +process/channel_remap/blue=2 +process/channel_remap/alpha=3 +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 diff --git a/Shaders/GodotRetro/Other/Images/bayer8x8.png b/Shaders/GodotRetro/Other/Images/bayer8x8.png new file mode 100644 index 00000000..53aea15f --- /dev/null +++ b/Shaders/GodotRetro/Other/Images/bayer8x8.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4033bd30262f53e189ea3d0287c5b50327aea462b4969ec8795434d0d4b03d96 +size 308 diff --git a/Shaders/GodotRetro/Other/Images/bayer8x8.png.import b/Shaders/GodotRetro/Other/Images/bayer8x8.png.import new file mode 100644 index 00000000..c0202341 --- /dev/null +++ b/Shaders/GodotRetro/Other/Images/bayer8x8.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://b1duf8fx5l6m5" +path="res://.godot/imported/bayer8x8.png-debe6599d301742c2811cc4636d4fdb3.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Shaders/GodotRetro/Other/Images/bayer8x8.png" +dest_files=["res://.godot/imported/bayer8x8.png-debe6599d301742c2811cc4636d4fdb3.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/uastc_level=0 +compress/rdo_quality_loss=0.0 +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/channel_remap/red=0 +process/channel_remap/green=1 +process/channel_remap/blue=2 +process/channel_remap/alpha=3 +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 diff --git a/Shaders/GodotRetro/Other/Images/bluenoise128x128.png b/Shaders/GodotRetro/Other/Images/bluenoise128x128.png new file mode 100644 index 00000000..a4c19407 --- /dev/null +++ b/Shaders/GodotRetro/Other/Images/bluenoise128x128.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a7f49ac82737674ffad54afc2dabdb05dbb4c7f71b411c609c012434fa449c8e +size 16727 diff --git a/Shaders/GodotRetro/Other/Images/bluenoise128x128.png.import b/Shaders/GodotRetro/Other/Images/bluenoise128x128.png.import new file mode 100644 index 00000000..b833c8e6 --- /dev/null +++ b/Shaders/GodotRetro/Other/Images/bluenoise128x128.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dygry4gihu7k" +path="res://.godot/imported/bluenoise128x128.png-90554eeeb00e878f740419b07c610a25.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Shaders/GodotRetro/Other/Images/bluenoise128x128.png" +dest_files=["res://.godot/imported/bluenoise128x128.png-90554eeeb00e878f740419b07c610a25.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/uastc_level=0 +compress/rdo_quality_loss=0.0 +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/channel_remap/red=0 +process/channel_remap/green=1 +process/channel_remap/blue=2 +process/channel_remap/alpha=3 +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 diff --git a/Shaders/GodotRetro/Other/Images/grain.jpg b/Shaders/GodotRetro/Other/Images/grain.jpg new file mode 100644 index 00000000..006be2d7 --- /dev/null +++ b/Shaders/GodotRetro/Other/Images/grain.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:cd260911ab26f58fa0dc06e0a8738f711b2a9351ea8fd355e7ff8e18812508fb +size 196631 diff --git a/Shaders/GodotRetro/Other/Images/grain.jpg.import b/Shaders/GodotRetro/Other/Images/grain.jpg.import new file mode 100644 index 00000000..da1bdcf6 --- /dev/null +++ b/Shaders/GodotRetro/Other/Images/grain.jpg.import @@ -0,0 +1,41 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dsrfu3ootv571" +path.s3tc="res://.godot/imported/grain.jpg-868ec7f55511fb8c612b05731c4fafaa.s3tc.ctex" +metadata={ +"imported_formats": ["s3tc_bptc"], +"vram_texture": true +} + +[deps] + +source_file="res://Shaders/GodotRetro/Other/Images/grain.jpg" +dest_files=["res://.godot/imported/grain.jpg-868ec7f55511fb8c612b05731c4fafaa.s3tc.ctex"] + +[params] + +compress/mode=2 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/uastc_level=0 +compress/rdo_quality_loss=0.0 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=true +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/channel_remap/red=0 +process/channel_remap/green=1 +process/channel_remap/blue=2 +process/channel_remap/alpha=3 +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=0 diff --git a/Shaders/GodotRetro/Other/Images/psxdither.png b/Shaders/GodotRetro/Other/Images/psxdither.png new file mode 100644 index 00000000..a56887f8 --- /dev/null +++ b/Shaders/GodotRetro/Other/Images/psxdither.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6dd62486553a3609082d2f6b3c66e900ebf71c5cd849562c52917ad7f0c676f5 +size 117 diff --git a/Shaders/GodotRetro/Other/Images/psxdither.png.import b/Shaders/GodotRetro/Other/Images/psxdither.png.import new file mode 100644 index 00000000..e3d9e088 --- /dev/null +++ b/Shaders/GodotRetro/Other/Images/psxdither.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://df4g8i1baak33" +path="res://.godot/imported/psxdither.png-6761ec10768e2d30034768a794210e9e.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Shaders/GodotRetro/Other/Images/psxdither.png" +dest_files=["res://.godot/imported/psxdither.png-6761ec10768e2d30034768a794210e9e.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/uastc_level=0 +compress/rdo_quality_loss=0.0 +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/channel_remap/red=0 +process/channel_remap/green=1 +process/channel_remap/blue=2 +process/channel_remap/alpha=3 +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 diff --git a/Shaders/GodotRetro/Screen Shaders/AccurateCRT.gdshader b/Shaders/GodotRetro/Screen Shaders/AccurateCRT.gdshader new file mode 100644 index 00000000..06ebe213 --- /dev/null +++ b/Shaders/GodotRetro/Screen Shaders/AccurateCRT.gdshader @@ -0,0 +1,278 @@ +//SHADER ORIGINALY CREADED BY "TimothyLottes" FROM SHADERTOY +//MODIFIED AND PORTED TO GODOT BY AHOPNESS (@ahopness) +//LICENSE : CC0 +//COMATIBLE WITH : GLES2, GLES3, WEBGL +//SHADERTOY LINK : https://www.shadertoy.com/view/MsjXzh + +// PUBLIC DOMAIN CRT STYLED SCAN-LINE SHADER +// +// by Timothy Lottes +// +// This is more along the style of a really good CGA arcade monitor. +// With RGB inputs instead of NTSC. +// The shadow mask example has the mask rotated 90 degrees for less chromatic aberration. +// +// Left it unoptimized to show the theory behind the algorithm. +// +// It is an example what I personally would want as a display option for pixel art games. +// Please take and use, change, or whatever. + +shader_type canvas_item; + +uniform sampler2D SCREEN_TEXTURE : hint_screen_texture, filter_linear_mipmap; + +// Emulated input resolution. +uniform vec2 res; + +// Mask type +// 0 = Very compressed TV style shadow mask +// 1 = Stretched VGA style shadow mask (same as prior shaders) +// 2 = VGA style shadow mask +uniform int mask_type :hint_range(0, 2) = 0; + +// Bloom Type +// 0 = Normalized exposure +// 1 = Aditive bloom +// 2 = No Bloom +uniform int bloom_type :hint_range(0, 2) = 0; + +// Hardness of scanline. +// -8.0 = soft +// -16.0 = medium +uniform float hardScan :hint_range(-12.0, -1.0) = -8.0; + +// Hardness of pixels in scanline. +// -2.0 = soft +// -4.0 = hard +uniform float hardPix :hint_range(-4.0, 0.0) = -2.0; + +// Hardness of short vertical bloom. +// -1.0 = wide to the point of clipping (bad) +// -1.5 = wide +// -4.0 = not very wide at all +uniform float hardBloomScan :hint_range(-4.0, 0.0) = -2.0; + +// Hardness of short horizontal bloom. +// -0.5 = wide to the point of clipping (bad) +// -1.0 = wide +// -2.0 = not very wide at all +uniform float hardBloomPix :hint_range(-2.0, 0.0) = -1.5; + +// Amount of small bloom effect. +// 1.0/1.0 = only bloom +// 1.0/16.0 = what I think is a good amount of small bloom +// 0.0 = no bloom +uniform float bloomAmount :hint_range(1.0, 16.0) = 16.0; + +// Display warp. +// 0.0 = none +// 1.0/8.0 = extreme +uniform vec2 warp = vec2(64.0, 24.0); + +// Amount of shadow mask. +uniform float maskDark :hint_range(0.0, 1.0) = 0.5; +uniform float maskLight :hint_range(1.0, 2.0) = 1.5; + +//------------------------------------------------------------------------ + +// sRGB to Linear. +// Assuing using sRGB typed textures this should not be needed. +float ToLinear1(float c){ return(c <= 0.04045) ? c / 12.92 : pow((c + 0.055) / 1.055, 2.4); } +vec3 ToLinear(vec3 c){ return vec3(ToLinear1(c.r), ToLinear1(c.g), ToLinear1(c.b)); } + +// Linear to sRGB. +// Assuing using sRGB typed textures this should not be needed. +float ToSrgb1(float c){ return(c < 0.0031308?c * 12.92 : 1.055 * pow(c, 0.41666) - 0.055); } +vec3 ToSrgb(vec3 c){ return vec3(ToSrgb1(c.r), ToSrgb1(c.g), ToSrgb1(c.b)); } + +// Nearest emulated sample given floating point position and texel offset. +// Also zero's off screen. +vec3 Fetch(vec2 pos, vec2 off, sampler2D iChannel0){ + pos = floor(pos * res + off) / res; + + if(max(abs(pos.x - 0.5), abs(pos.y - 0.5)) > 0.5){ + return vec3(0.0, 0.0, 0.0); + } + + return ToLinear(texture(iChannel0 , pos.xy , -16.0).rgb); +} + +// Distance in emulated pixels to nearest texel. +vec2 Dist(vec2 pos){ + pos = pos * res; + return - ((pos - floor(pos)) - vec2(0.5)); +} + +// 1D Gaussian. +float Gaus(float pos, float scale){ return exp2(scale * pos * pos); } + +// 3-tap Gaussian filter along horz line. +vec3 Horz3(vec2 pos, float off, sampler2D iChannel0){ + vec3 b = Fetch(pos, vec2(-1.0, off), iChannel0); + vec3 c = Fetch(pos, vec2( 0.0, off), iChannel0); + vec3 d = Fetch(pos, vec2( 1.0, off), iChannel0); + float dst = Dist(pos).x; + + // Convert distance to weight. + float scale = hardPix; + float wb = Gaus(dst - 1.0, scale); + float wc = Gaus(dst + 0.0, scale); + float wd = Gaus(dst + 1.0, scale); + + // Return filtered sample. + return (b * wb + c * wc + d * wd) / (wb + wc + wd); +} +// 5-tap Gaussian filter along horz line. +vec3 Horz5(vec2 pos, float off, sampler2D iChannel0){ + vec3 a = Fetch(pos, vec2(-2.0, off), iChannel0); + vec3 b = Fetch(pos, vec2(-1.0, off), iChannel0); + vec3 c = Fetch(pos, vec2( 0.0, off), iChannel0); + vec3 d = Fetch(pos, vec2( 1.0, off), iChannel0); + vec3 e = Fetch(pos, vec2( 2.0, off), iChannel0); + float dst = Dist(pos).x; + + // Convert distance to weight. + float scale = hardPix; + float wa = Gaus(dst - 2.0, scale); + float wb = Gaus(dst - 1.0, scale); + float wc = Gaus(dst + 0.0, scale); + float wd = Gaus(dst + 1.0, scale); + float we = Gaus(dst + 2.0, scale); + + // Return filtered sample. + return (a * wa + b * wb + c * wc + d * wd + e * we) / (wa + wb + wc + wd + we); +} +// 7-tap Gaussian filter along horz line. +vec3 Horz7(vec2 pos, float off, sampler2D iChannel0){ + vec3 a = Fetch(pos, vec2(-3.0, off), iChannel0); + vec3 b = Fetch(pos, vec2(-2.0, off), iChannel0); + vec3 c = Fetch(pos, vec2( 1.0, off), iChannel0); + vec3 d = Fetch(pos, vec2( 0.0, off), iChannel0); + vec3 e = Fetch(pos, vec2( 1.0, off), iChannel0); + vec3 f = Fetch(pos, vec2( 2.0, off), iChannel0); + vec3 g = Fetch(pos, vec2( 3.0, off), iChannel0); + float dst = Dist(pos).x; + + // Convert distance to weight. + float scale = hardBloomPix; + float wa = Gaus(dst - 3.0, scale); + float wb = Gaus(dst - 2.0, scale); + float wc = Gaus(dst - 1.0, scale); + float wd = Gaus(dst + 0.0, scale); + float we = Gaus(dst + 1.0, scale); + float wf = Gaus(dst + 2.0, scale); + float wg = Gaus(dst + 3.0, scale); + + // Return filtered sample. + return (a * wa + b * wb + c * wc + d * wd + e * we + f * wf + g * wg) / (wa + wb + wc + wd + we + wf + wg); +} + +// Return scanline weight. +float Scan(vec2 pos, float off){ + float dst = Dist(pos).y; + + return Gaus(dst + off, hardScan); +} + +// Return scanline weight for bloom. +float BloomScan(vec2 pos, float off){ + float dst = Dist(pos).y; + + return Gaus(dst + off, hardBloomScan); +} + +// Allow nearest three lines to effect pixel. +vec3 Tri(vec2 pos, sampler2D iChannel0){ + vec3 a = Horz3(pos,-1.0, iChannel0); + vec3 b = Horz5(pos, 0.0, iChannel0); + vec3 c = Horz3(pos, 1.0, iChannel0); + + float wa = Scan(pos,-1.0); + float wb = Scan(pos, 0.0); + float wc = Scan(pos, 1.0); + + return a * wa + b * wb + c * wc; +} + +// Small bloom. +vec3 Bloom(vec2 pos, sampler2D iChannel0){ + vec3 a = Horz5(pos,-2.0, iChannel0); + vec3 b = Horz7(pos,-1.0, iChannel0); + vec3 c = Horz7(pos, 0.0, iChannel0); + vec3 d = Horz7(pos, 1.0, iChannel0); + vec3 e = Horz5(pos, 2.0, iChannel0); + + float wa = BloomScan(pos,-2.0); + float wb = BloomScan(pos,-1.0); + float wc = BloomScan(pos, 0.0); + float wd = BloomScan(pos, 1.0); + float we = BloomScan(pos, 2.0); + + return a * wa + b * wb + c * wc + d * wd + e * we; +} + +// Distortion of scanlines, and end of screen alpha. +vec2 Warp(vec2 pos){ + pos = pos * 2.0 - 1.0; + pos *= vec2(1.0 + (pos.y * pos.y) * 1.0 / warp.x, 1.0 + (pos.x * pos.x) * 1.0/ warp.y); + + return pos * 0.5+0.5; +} + +vec3 Mask(vec2 pos){ + if (mask_type == 0){ + float line = maskLight; + float odd = 0.0; + + if(fract(pos.x / 6.0) < 0.5) odd = 1.0; + if(fract((pos.y + odd) / 2.0) < 0.5) line = maskDark; + pos.x = fract(pos.x / 3.0); + + vec3 mask = vec3(maskDark, maskDark, maskDark); + if(pos.x < 0.333)mask.r = maskLight; + else if(pos.x < 0.666)mask.g = maskLight; + else mask.b = maskLight; + + mask *= line; + return mask; + }else if (mask_type == 1){ + pos.x += pos.y * 3.0; + + vec3 mask = vec3(maskDark, maskDark, maskDark); + pos.x = fract(pos.x / 6.0); + if(pos.x < 0.333)mask.r = maskLight; + else if(pos.x < 0.666)mask.g = maskLight; + else mask.b = maskLight; + + return mask; + }else if (mask_type == 2){ + pos.xy = floor(pos.xy * vec2(1.0, 0.5)); + pos.x += pos.y * 3.0; + + vec3 mask = vec3(maskDark, maskDark, maskDark); + pos.x = fract(pos.x / 6.0); + if(pos.x < 0.333)mask.r = maskLight; + else if(pos.x < 0.666)mask.g = maskLight; + else mask.b = maskLight; + + return mask; + } + } + +// Draw dividing bars. +float Bar(float pos, float bar){ pos -= bar; return pos * pos < 4.0 ? 0.0 : 1.0; } + +// Entry. +void fragment(){ + vec2 pos = Warp(FRAGCOORD.xy / (1.0 / SCREEN_PIXEL_SIZE).xy); + + COLOR.rgb = Tri(pos, SCREEN_TEXTURE) * Mask(FRAGCOORD.xy); + if (bloom_type == 0){ + COLOR.rgb = mix(COLOR.rgb,Bloom(pos, SCREEN_TEXTURE), 1.0 / bloomAmount); + }else if (bloom_type == 1){ + COLOR.rgb += Bloom(pos, SCREEN_TEXTURE) * 1.0 / bloomAmount; + } + + COLOR.a = 1.0; + COLOR.rgb = ToSrgb(COLOR.rgb); +} \ No newline at end of file diff --git a/Shaders/GodotRetro/Screen Shaders/AccurateCRT.gdshader.uid b/Shaders/GodotRetro/Screen Shaders/AccurateCRT.gdshader.uid new file mode 100644 index 00000000..630a39f8 --- /dev/null +++ b/Shaders/GodotRetro/Screen Shaders/AccurateCRT.gdshader.uid @@ -0,0 +1 @@ +uid://b5aqrdiat1tw7 diff --git a/Shaders/GodotRetro/Screen Shaders/Aditional Shaders/B&W.gdshader b/Shaders/GodotRetro/Screen Shaders/Aditional Shaders/B&W.gdshader new file mode 100644 index 00000000..8e4ae915 --- /dev/null +++ b/Shaders/GodotRetro/Screen Shaders/Aditional Shaders/B&W.gdshader @@ -0,0 +1,31 @@ +//SHADER ORIGINALY CREADED BY "demofox" FROM SHADERTOY +//MODIFIED AND PORTED TO GODOT BY AHOPNESS (@ahopness) +//LICENSE : CC0 +//COMATIBLE WITH : GLES2, GLES3, WEBGL +//SHADERTOY LINK : https://www.shadertoy.com/view/XdXSzX + +shader_type canvas_item; + +uniform sampler2D SCREEN_TEXTURE : hint_screen_texture, filter_linear_mipmap; + +uniform float contrast :hint_range(0.0, 3.0) = 1.0; +uniform float brightness :hint_range(-1.0, 1.0) = 0.0; + + +void fragment(){ + vec2 uv = FRAGCOORD.xy / (1.0 / SCREEN_PIXEL_SIZE).xy; + + vec3 pixelColor = texture(SCREEN_TEXTURE, uv).xyz; + + // Grayscale + float pixelGrey = dot(pixelColor, vec3(0.2126, 0.7152, 0.0722)); + pixelColor = vec3(pixelGrey); + + // Contrast + pixelColor.rgb = ((pixelColor.rgb - 0.5) * max(contrast, 0.0)) + 0.5; + + // Brightness + pixelColor.rgb += brightness; + + COLOR = vec4(pixelColor, 1.0); +} \ No newline at end of file diff --git a/Shaders/GodotRetro/Screen Shaders/Aditional Shaders/B&W.gdshader.uid b/Shaders/GodotRetro/Screen Shaders/Aditional Shaders/B&W.gdshader.uid new file mode 100644 index 00000000..0b0503fd --- /dev/null +++ b/Shaders/GodotRetro/Screen Shaders/Aditional Shaders/B&W.gdshader.uid @@ -0,0 +1 @@ +uid://jgbk45h1spb1 diff --git a/Shaders/GodotRetro/Screen Shaders/Aditional Shaders/BetterCC.gdshader b/Shaders/GodotRetro/Screen Shaders/Aditional Shaders/BetterCC.gdshader new file mode 100644 index 00000000..463e30bc --- /dev/null +++ b/Shaders/GodotRetro/Screen Shaders/Aditional Shaders/BetterCC.gdshader @@ -0,0 +1,42 @@ +//SHADER ORIGINALY CREADED BY "Wunkolo" FROM SHADERTOY +//MODIFIED AND PORTED TO GODOT BY AHOPNESS (@ahopness) +//LICENSE : CC0 +//COMATIBLE WITH : GLES2, GLES3, WEBGL +//SHADERTOY LINK : https://www.shadertoy.com/view/tllfRf + +shader_type canvas_item; + +uniform sampler2D SCREEN_TEXTURE : hint_screen_texture, filter_linear_mipmap; + +uniform vec4 Shadows :source_color = vec4(0.0, 0.0, 0.0, 1.0); +uniform vec4 Midtones :source_color = vec4(0.0, 0.0, 0.0, 1.0); +uniform vec4 Hilights :source_color = vec4(0.0, 0.0, 0.0, 1.0); + +vec3 InvLerp( vec3 A, vec3 B, vec3 t){ + return (t - A) / (B - A); +} + +vec3 ColorGrade( in vec3 InColor ){ + // Calculate the three offseted colors up-front + vec3 OffShadows = InColor + Shadows.xyz; + vec3 OffMidtones = InColor + Midtones.xyz; + vec3 OffHilights = InColor + Hilights.xyz; + + // Linearly interpolate between the 3 new colors, piece-wise + return mix( + // We pick which of the two control points to interpolate from based on which side of + // 0.5 the input color channel lands on + mix(OffShadows, OffMidtones, InvLerp(vec3(0.0), vec3(0.5), InColor)), // < 0.5 + mix(OffMidtones, OffHilights, InvLerp(vec3(0.5), vec3(1.0), InColor)), // >= 0.5 + greaterThanEqual(InColor, vec3(0.5)) + ); +} + +void fragment(){ + vec2 uv = FRAGCOORD.xy / vec2(1.0 / SCREEN_PIXEL_SIZE.xy); + COLOR.a = 1.0; + COLOR.rgb = texture(SCREEN_TEXTURE, uv).rgb; + COLOR.rgb = ColorGrade(COLOR.rgb); + + //COLOR.rgb = pow(COLOR.rgb, vec3(2.2)); +} \ No newline at end of file diff --git a/Shaders/GodotRetro/Screen Shaders/Aditional Shaders/BetterCC.gdshader.uid b/Shaders/GodotRetro/Screen Shaders/Aditional Shaders/BetterCC.gdshader.uid new file mode 100644 index 00000000..f68c8a31 --- /dev/null +++ b/Shaders/GodotRetro/Screen Shaders/Aditional Shaders/BetterCC.gdshader.uid @@ -0,0 +1 @@ +uid://cfnegwv7lqi3k diff --git a/Shaders/GodotRetro/Screen Shaders/Aditional Shaders/Blur.gdshader b/Shaders/GodotRetro/Screen Shaders/Aditional Shaders/Blur.gdshader new file mode 100644 index 00000000..b1dcb9c1 --- /dev/null +++ b/Shaders/GodotRetro/Screen Shaders/Aditional Shaders/Blur.gdshader @@ -0,0 +1,63 @@ +//SHADER ORIGINALY CREADED BY "jcant0n" FROM SHADERTOY +//MODIFIED AND PORTED TO GODOT BY AHOPNESS (@ahopness) +//LICENSE : CC0 +//COMATIBLE WITH : GLES2, GLES3, WEBGL +//SHADERTOY LINK : https://www.shadertoy.com/view/XssSDs# + +shader_type canvas_item; + +uniform sampler2D SCREEN_TEXTURE : hint_screen_texture, filter_linear_mipmap; + +uniform float amount :hint_range(0.0, 1.5) = 1.0; + +vec2 Circle(float Start, float Points, float Point) { + float Rad = (3.141592 * 3.0 * (1.0 / Points)) * (Point + Start); + return vec2(sin(Rad), cos(Rad)); +} + +void fragment(){ + vec2 uv = FRAGCOORD.xy / (1.0 / SCREEN_PIXEL_SIZE).xy; + vec2 PixelOffset = amount / (1.0 / SCREEN_PIXEL_SIZE).xy; + + float Start = 2.0 / 14.0; + vec2 Scale = 0.66 * 4.0 * 2.0 * PixelOffset.xy; + + vec3 N0 = texture(SCREEN_TEXTURE, uv + Circle(Start, 14.0, 0.0) * Scale).rgb; + vec3 N1 = texture(SCREEN_TEXTURE, uv + Circle(Start, 14.0, 1.0) * Scale).rgb; + vec3 N2 = texture(SCREEN_TEXTURE, uv + Circle(Start, 14.0, 2.0) * Scale).rgb; + vec3 N3 = texture(SCREEN_TEXTURE, uv + Circle(Start, 14.0, 3.0) * Scale).rgb; + vec3 N4 = texture(SCREEN_TEXTURE, uv + Circle(Start, 14.0, 4.0) * Scale).rgb; + vec3 N5 = texture(SCREEN_TEXTURE, uv + Circle(Start, 14.0, 5.0) * Scale).rgb; + vec3 N6 = texture(SCREEN_TEXTURE, uv + Circle(Start, 14.0, 6.0) * Scale).rgb; + vec3 N7 = texture(SCREEN_TEXTURE, uv + Circle(Start, 14.0, 7.0) * Scale).rgb; + vec3 N8 = texture(SCREEN_TEXTURE, uv + Circle(Start, 14.0, 8.0) * Scale).rgb; + vec3 N9 = texture(SCREEN_TEXTURE, uv + Circle(Start, 14.0, 9.0) * Scale).rgb; + vec3 N10 = texture(SCREEN_TEXTURE, uv + Circle(Start, 14.0, 10.0) * Scale).rgb; + vec3 N11 = texture(SCREEN_TEXTURE, uv + Circle(Start, 14.0, 11.0) * Scale).rgb; + vec3 N12 = texture(SCREEN_TEXTURE, uv + Circle(Start, 14.0, 12.0) * Scale).rgb; + vec3 N13 = texture(SCREEN_TEXTURE, uv + Circle(Start, 14.0, 13.0) * Scale).rgb; + vec3 N14 = texture(SCREEN_TEXTURE, uv).rgb; + + float W = 1.0 / 15.0; + + vec3 color = vec3(0,0,0); + + color.rgb = + (N0 * W) + + (N1 * W) + + (N2 * W) + + (N3 * W) + + (N4 * W) + + (N5 * W) + + (N6 * W) + + (N7 * W) + + (N8 * W) + + (N9 * W) + + (N10 * W) + + (N11 * W) + + (N12 * W) + + (N13 * W) + + (N14 * W); + + COLOR = vec4(color.rgb,1.0); +} diff --git a/Shaders/GodotRetro/Screen Shaders/Aditional Shaders/Blur.gdshader.uid b/Shaders/GodotRetro/Screen Shaders/Aditional Shaders/Blur.gdshader.uid new file mode 100644 index 00000000..d06c4d90 --- /dev/null +++ b/Shaders/GodotRetro/Screen Shaders/Aditional Shaders/Blur.gdshader.uid @@ -0,0 +1 @@ +uid://btpp3b7dgsbjr diff --git a/Shaders/GodotRetro/Screen Shaders/Aditional Shaders/ColorPrecission.gdshader b/Shaders/GodotRetro/Screen Shaders/Aditional Shaders/ColorPrecission.gdshader new file mode 100644 index 00000000..4c527f45 --- /dev/null +++ b/Shaders/GodotRetro/Screen Shaders/Aditional Shaders/ColorPrecission.gdshader @@ -0,0 +1,32 @@ +//SHADER ORIGINALY CREADED BY "abelcamarena" FROM SHADERTOY +//MODIFIED AND PORTED TO GODOT BY AHOPNESS (@ahopness) +//LICENSE : CC0 +//COMATIBLE WITH : GLES2, GLES3, WEBGL +//SHADERTOY LINK : https://www.shadertoy.com/view/tsKGDm + +// Looking for ditheirng? I reccomend using this shader instead : +// https://github.com/WittyCognomen/godot-psx-shaders/blob/master/shaders/psx_dither_post.shader +// https://github.com/WittyCognomen/godot-psx-shaders/tree/master/shaders/dithers + +shader_type canvas_item; + +uniform sampler2D SCREEN_TEXTURE : hint_screen_texture, filter_linear_mipmap; + +uniform float SCREEN_WIDTH = 320.; // Lower num - bigger pixels (this will be the screen width) +uniform float COLOR_FACTOR :hint_range(0., 10.) = 4.; // Higher num - higher colors quality + +void fragment(){ + // Reduce pixels + vec2 size = SCREEN_WIDTH * SCREEN_PIXEL_SIZE.xy/SCREEN_PIXEL_SIZE.x; + vec2 coor = floor( UV * size) ; + vec2 uv = FRAGCOORD.xy / (1.0 / SCREEN_PIXEL_SIZE).xy; + + // Get source color + vec3 col = texture(SCREEN_TEXTURE, uv).xyz; + + // Reduce colors + col = floor(col * COLOR_FACTOR) / COLOR_FACTOR; + + // Output to screen + COLOR = vec4(col,1.); +} \ No newline at end of file diff --git a/Shaders/GodotRetro/Screen Shaders/Aditional Shaders/ColorPrecission.gdshader.uid b/Shaders/GodotRetro/Screen Shaders/Aditional Shaders/ColorPrecission.gdshader.uid new file mode 100644 index 00000000..740a347b --- /dev/null +++ b/Shaders/GodotRetro/Screen Shaders/Aditional Shaders/ColorPrecission.gdshader.uid @@ -0,0 +1 @@ +uid://c2j7nuoh1tj51 diff --git a/Shaders/GodotRetro/Screen Shaders/Aditional Shaders/Dithering.gdshader b/Shaders/GodotRetro/Screen Shaders/Aditional Shaders/Dithering.gdshader new file mode 100644 index 00000000..974284a4 --- /dev/null +++ b/Shaders/GodotRetro/Screen Shaders/Aditional Shaders/Dithering.gdshader @@ -0,0 +1,46 @@ +//SHADER ORIGINALY CREADED BY "abelcamarena" FROM SHADERTOY +//MODIFIED AND PORTED TO GODOT BY AHOPNESS (@ahopness) +//LICENSE : CC0 +//COMATIBLE WITH : GLES2, GLES3, WEBGL +//SHADERTOY LINK : https://www.shadertoy.com/view/tsKGDm + +shader_type canvas_item; + +uniform sampler2D SCREEN_TEXTURE : hint_screen_texture, filter_linear_mipmap; + +uniform float SCREEN_WIDTH = 320.; // Lower num - bigger pixels (this will be the screen width) +uniform float COLOR_FACTOR :hint_range(0., 10.) = 4.; // Higher num - higher colors quality +uniform float DITHERING_STRENTH :hint_range(0., .07) = 0.005; // Be carefull with this one, dithering can get messy really easily + +int PSXDither(ivec2 fragcoord) { + const int dither_table[16] = { + -4, +0, -3, +1, + +2, -2, +3, -1, + -3, +1, -4, +0, + +3, -1, +2, -2 + }; + + int x = fragcoord.x % 4; + int y = fragcoord.y % 4; + + return dither_table[y * 4 + x]; +} + +void fragment(){ + // Reduce pixels + vec2 size = SCREEN_WIDTH * SCREEN_PIXEL_SIZE.xy/SCREEN_PIXEL_SIZE.x; + vec2 coor = floor( UV * size) ; + vec2 uv = FRAGCOORD.xy / (1.0 / SCREEN_PIXEL_SIZE).xy; + + // Get source color + vec3 col = texture(SCREEN_TEXTURE, uv).xyz; + + // Dithering + col += float(PSXDither(ivec2(FRAGCOORD.xy))) * DITHERING_STRENTH; + + // Reduce colors + col = floor(col * COLOR_FACTOR) / COLOR_FACTOR; + + // Output to screen + COLOR = vec4(col,1.); +} \ No newline at end of file diff --git a/Shaders/GodotRetro/Screen Shaders/Aditional Shaders/Dithering.gdshader.uid b/Shaders/GodotRetro/Screen Shaders/Aditional Shaders/Dithering.gdshader.uid new file mode 100644 index 00000000..4b49c29e --- /dev/null +++ b/Shaders/GodotRetro/Screen Shaders/Aditional Shaders/Dithering.gdshader.uid @@ -0,0 +1 @@ +uid://b0rycwqoft3cy diff --git a/Shaders/GodotRetro/Screen Shaders/Aditional Shaders/Sharpness.gdshader b/Shaders/GodotRetro/Screen Shaders/Aditional Shaders/Sharpness.gdshader new file mode 100644 index 00000000..cf9dc787 --- /dev/null +++ b/Shaders/GodotRetro/Screen Shaders/Aditional Shaders/Sharpness.gdshader @@ -0,0 +1,29 @@ +//SHADER ORIGINALY CREADED BY "Nihilistic_Furry" FROM SHADERTOY +//MODIFIED AND PORTED TO GODOT BY AHOPNESS (@ahopness) +//LICENSE : CC0 +//COMATIBLE WITH : GLES2, GLES3, WEBGL +//SHADERTOY LINK : https://www.shadertoy.com/view/wsK3Wt + +shader_type canvas_item; + +uniform sampler2D SCREEN_TEXTURE : hint_screen_texture, filter_linear_mipmap; + +uniform float sharpen_amount :hint_range(0,4) = 1.0; + +vec4 sharpenMask (sampler2D st, vec2 fc, vec2 sps){ + // Sharpen detection matrix [0,1,0],[1,-4,1],[0,1,0] + // Colors + vec4 up = texture (st, (fc + vec2 (0, 1))/sps); + vec4 left = texture (st, (fc + vec2 (-1, 0))/sps); + vec4 center = texture (st, fc/sps); + vec4 right = texture (st, (fc + vec2 (1, 0))/sps); + vec4 down = texture (st, (fc + vec2 (0, -1))/sps); + + // Return edge detection + return (1.0 + 4.0*sharpen_amount)*center -sharpen_amount*(up + left + right + down); +} + +void fragment(){ + // Detect edges and output to screen + COLOR = sharpenMask (SCREEN_TEXTURE, FRAGCOORD.xy, 1.0 / SCREEN_PIXEL_SIZE); +} \ No newline at end of file diff --git a/Shaders/GodotRetro/Screen Shaders/Aditional Shaders/Sharpness.gdshader.uid b/Shaders/GodotRetro/Screen Shaders/Aditional Shaders/Sharpness.gdshader.uid new file mode 100644 index 00000000..725315c9 --- /dev/null +++ b/Shaders/GodotRetro/Screen Shaders/Aditional Shaders/Sharpness.gdshader.uid @@ -0,0 +1 @@ +uid://q7w80gwlwwl6 diff --git a/Shaders/GodotRetro/Screen Shaders/Glitch.gdshader b/Shaders/GodotRetro/Screen Shaders/Glitch.gdshader new file mode 100644 index 00000000..d439ac08 --- /dev/null +++ b/Shaders/GodotRetro/Screen Shaders/Glitch.gdshader @@ -0,0 +1,55 @@ +//SHADER ORIGINALY CREADED BY "keijiro" FROM GITHUB +//MODIFIED AND PORTED TO GODOT BY AHOPNESS (@ahopness) +//LICENSE : https://github.com/keijiro/KinoGlitch#license +//COMATIBLE WITH : GLES2, GLES3, WEBGL +//GITHUB LINK : https://github.com/keijiro/KinoGlitch + +shader_type canvas_item; + +uniform sampler2D SCREEN_TEXTURE : hint_screen_texture, filter_linear_mipmap; + +uniform float _ScanLineJitter : hint_range(.2, 1) = .25; // (displacement, threshold) +uniform float _VerticalJump : hint_range(0, 1) = .01; // (amount, time) +uniform float _HorizontalShake : hint_range(0, 1) = 0; +uniform float _ColorDrift : hint_range(0, 1) = .02; // (amount, time) + + +float nrand(float x, float y){ + return fract(sin(dot(vec2(x, y), vec2(12.9898, 78.233))) * 43758.5453); +} + +void fragment(){ + float sl_thresh = dot(vec2(1.0 - _ScanLineJitter * 1.2), vec2(1.0 - _ScanLineJitter * 1.2)); + float sl_disp = 0.002 + pow(_ScanLineJitter, 3) * 0.05; + vec2 sl = vec2(sl_disp, sl_thresh); + + float _verticalJumpTime = TIME * _VerticalJump * 11.3; + vec2 vj = vec2(_VerticalJump, _verticalJumpTime); + + float hs = _HorizontalShake * 0.2; + + vec2 cd = vec2(_ColorDrift * 0.04f, TIME * 606.11f); + + float u = FRAGCOORD.x / (1.0 / SCREEN_PIXEL_SIZE).x; + float v = FRAGCOORD.y / (1.0 / SCREEN_PIXEL_SIZE).y; + + // Scan line jitter + float jitter = nrand(v, TIME) * 2.0 - 1.0; + jitter *= step(sl.y, abs(jitter)) * sl.x; + + // Vertical jump + float jump = mix(v, fract(v + vj.y), vj.x); + + // Horizontal shake + float shake = (nrand(TIME, 2) - 0.5) * hs; + + // Color drift + float drift = sin(jump + cd.y) * cd.x; + + vec4 final1 = texture(SCREEN_TEXTURE, fract(vec2(u + jitter + shake, jump))); + vec4 final2 = texture(SCREEN_TEXTURE, fract(vec2(u + jitter + shake + drift, jump))); + + vec4 render = vec4(final1.r, final2.g, final1.b, 1); + + COLOR = render; +} \ No newline at end of file diff --git a/Shaders/GodotRetro/Screen Shaders/Glitch.gdshader.uid b/Shaders/GodotRetro/Screen Shaders/Glitch.gdshader.uid new file mode 100644 index 00000000..b0f16f51 --- /dev/null +++ b/Shaders/GodotRetro/Screen Shaders/Glitch.gdshader.uid @@ -0,0 +1 @@ +uid://c3126pjb2ueto diff --git a/Shaders/GodotRetro/Screen Shaders/Grain.gdshader b/Shaders/GodotRetro/Screen Shaders/Grain.gdshader new file mode 100644 index 00000000..aef18669 --- /dev/null +++ b/Shaders/GodotRetro/Screen Shaders/Grain.gdshader @@ -0,0 +1,127 @@ +//SHADER ORIGINALY CREADED BY "spl!te" FROM GITHUB FOR GODOT 2.1 +//MODIFIED AND PORTED TO GODOT BY AHOPNESS (@ahopness) +//LICENSE : CC0 +//COMATIBLE WITH : GLES2, GLES3 +//GITHUB LINK : https://github.com/splite/Godot_Film_Grain_Shader +//ORIGINAL POST LINK : http://devlog-martinsh.blogspot.com/2013/05/image-imperfections-and-film-grain-post.html + +shader_type canvas_item; + +uniform sampler2D SCREEN_TEXTURE : hint_screen_texture, filter_linear_mipmap; + +uniform bool colored = false; //colored noise? +uniform float color_amount :hint_range(0, 1.3) = 0.6; +uniform float grain_amount :hint_range(0, 0.07) = 0.025; //grain amount +uniform float grain_size :hint_range(1, 3) = 1.6; //grain particle size (1.5 - 2.5) +uniform float lum_amount :hint_range(0, 2) = 1.3; + +varying float time; + +void vertex(){ + time = TIME; +} + +//a random texture generator, but you can also use a pre-computed perturbation texture +vec4 rnm(vec2 tc) { + float noise = sin(dot(tc + vec2(time,time),vec2(12.9898,78.233))) * 43758.5453; + float noiseR = fract(noise)*2.0-1.0; + float noiseG = fract(noise*1.2154)*2.0-1.0; + float noiseB = fract(noise*1.3453)*2.0-1.0; + float noiseA = fract(noise*1.3647)*2.0-1.0; + return vec4(noiseR,noiseG,noiseB,noiseA); +} + +float fade(float t) { + return t*t*t*(t*(t*6.0-15.0)+10.0); +} + +float pnoise3D(vec3 p){ + vec3 pi = 0.00390625*floor(p); + pi = vec3(pi.x+0.001953125, pi.y+0.001953125, pi.z+0.001953125); + vec3 pf = fract(p); // Fractional part for interpolation + + // Noise contributions from (x=0, y=0), z=0 and z=1 + float perm00 = rnm(pi.xy).a ; + vec3 grad000 = rnm(vec2(perm00, pi.z)).rgb * 4.0; + grad000 = vec3(grad000.x - 1.0, grad000.y - 1.0, grad000.z - 1.0); + float n000 = dot(grad000, pf); + vec3 grad001 = rnm(vec2(perm00, pi.z + 0.00390625)).rgb * 4.0; + grad001 = vec3(grad001.x - 1.0, grad001.y - 1.0, grad001.z - 1.0); + float n001 = dot(grad001, pf - vec3(0.0, 0.0, 1.0)); + + // Noise contributions from (x=0, y=1), z=0 and z=1 + float perm01 = rnm(pi.xy + vec2(0.0, 0.00390625)).a ; + vec3 grad010 = rnm(vec2(perm01, pi.z)).rgb * 4.0; + grad010 = vec3(grad010.x - 1.0, grad010.y - 1.0, grad010.z - 1.0); + float n010 = dot(grad010, pf - vec3(0.0, 1.0, 0.0)); + vec3 grad011 = rnm(vec2(perm01, pi.z + 0.00390625)).rgb * 4.0; + grad011 = vec3(grad011.x - 1.0, grad011.y - 1.0, grad011.z - 1.0); + float n011 = dot(grad011, pf - vec3(0.0, 1.0, 1.0)); + + // Noise contributions from (x=1, y=0), z=0 and z=1 + float perm10 = rnm(pi.xy + vec2(0.00390625, 0.0)).a ; + vec3 grad100 = rnm(vec2(perm10, pi.z)).rgb * 4.0; + grad100 = vec3(grad100.x - 1.0, grad100.y - 1.0, grad100.z - 1.0); + float n100 = dot(grad100, pf - vec3(1.0, 0.0, 0.0)); + vec3 grad101 = rnm(vec2(perm10, pi.z + 0.00390625)).rgb * 4.0; + grad101 = vec3(grad101.x - 1.0, grad101.y - 1.0, grad101.z - 1.0); + float n101 = dot(grad101, pf - vec3(1.0, 0.0, 1.0)); + + // Noise contributions from (x=1, y=1), z=0 and z=1 + float perm11 = rnm(pi.xy + vec2(0.00390625, 0.00390625)).a ; + vec3 grad110 = rnm(vec2(perm11, pi.z)).rgb * 4.0; + grad110 = vec3(grad110.x - 1.0, grad110.y - 1.0, grad110.z - 1.0); + float n110 = dot(grad110, pf - vec3(1.0, 1.0, 0.0)); + vec3 grad111 = rnm(vec2(perm11, pi.z + 0.00390625)).rgb * 4.0; + grad111 = vec3(grad111.x - 1.0, grad111.y - 1.0, grad111.z - 1.0); + float n111 = dot(grad111, pf - vec3(1.0, 1.0, 1.0)); + + // Blend contributions along x + vec4 n_x = mix(vec4(n000, n001, n010, n011), vec4(n100, n101, n110, n111), fade(pf.x)); + + // Blend contributions along y + vec2 n_xy = mix(n_x.xy, n_x.zw, fade(pf.y)); + + // Blend contributions along z + float n_xyz = mix(n_xy.x, n_xy.y, fade(pf.z)); + + // We're done, return the final noise value. + return n_xyz; +} + +//2d coordinate orientation thing +vec2 coordRot(vec2 tc, float angle, vec2 screen_size){ + float aspect = screen_size.x/screen_size.y; + float rotX = ((tc.x*2.0-1.0)*aspect*cos(angle)) - ((tc.y*2.0-1.0)*sin(angle)); + float rotY = ((tc.y*2.0-1.0)*cos(angle)) + ((tc.x*2.0-1.0)*aspect*sin(angle)); + rotX = ((rotX/aspect)*0.5+0.5); + rotY = rotY*0.5+0.5; + return vec2(rotX,rotY); +} + +void fragment (){ + vec2 screen_size = (1.0 / SCREEN_PIXEL_SIZE).xy; + vec3 rotOffset = vec3(1.425,3.892,5.835); //rotation offset values + vec2 rotCoordsR = coordRot(UV, time + rotOffset.x, screen_size); + vec3 noise = vec3(pnoise3D(vec3(rotCoordsR*vec2(screen_size.x/grain_size,screen_size.y/grain_size),0.0))); + + if (colored){ + vec2 rotCoordsG = coordRot(UV, time + rotOffset.y, screen_size); + vec2 rotCoordsB = coordRot(UV, time + rotOffset.z, screen_size); + noise.g = mix(noise.r,pnoise3D(vec3(rotCoordsG*vec2(screen_size.x/grain_size,screen_size.y/grain_size),1.0)),color_amount); + noise.b = mix(noise.r,pnoise3D(vec3(rotCoordsB*vec2(screen_size.x/grain_size,screen_size.y/grain_size),2.0)),color_amount); + } + + vec3 col = texture(TEXTURE, UV).rgb; + vec3 lumcoeff = vec3(0.299,0.587,0.114); + float luminance = mix(0.0,dot(col, lumcoeff),lum_amount); + float lum = smoothstep(0.2,0.0,luminance); + lum += luminance; + + noise = mix(noise,vec3(0.0),pow(lum,4.0)); + col = col+noise*grain_amount; + + vec4 SRC_COLOR = texture(SCREEN_TEXTURE, SCREEN_UV); + + COLOR = vec4(col,1.0) * SRC_COLOR; +} \ No newline at end of file diff --git a/Shaders/GodotRetro/Screen Shaders/Grain.gdshader.uid b/Shaders/GodotRetro/Screen Shaders/Grain.gdshader.uid new file mode 100644 index 00000000..dec0f87d --- /dev/null +++ b/Shaders/GodotRetro/Screen Shaders/Grain.gdshader.uid @@ -0,0 +1 @@ +uid://bos266ol7go8s diff --git a/Shaders/GodotRetro/Screen Shaders/JpegCompression.gdshader b/Shaders/GodotRetro/Screen Shaders/JpegCompression.gdshader new file mode 100644 index 00000000..d7563cf2 --- /dev/null +++ b/Shaders/GodotRetro/Screen Shaders/JpegCompression.gdshader @@ -0,0 +1,42 @@ +//SHADER ORIGINALY CREADED BY "paniq" FROM SHADERTOY +//MODIFIED AND PORTED TO GODOT BY AHOPNESS (@ahopness) +//LICENSE : CC0 +//COMATIBLE WITH : GLES2, GLES3, WEBGL +//SHADERTOY LINK : https://www.shadertoy.com/view/MdcGzj + +shader_type canvas_item; + +uniform sampler2D SCREEN_TEXTURE : hint_screen_texture, filter_linear_mipmap; + +uniform float color_depth :hint_range(0.0, 255.0) = 100.0; +uniform float color_number :hint_range(0.0, 50.0) = 20.0; + +const mat3 rgb2ycbcr = mat3( + vec3(0.299, -0.168736, 0.5), + vec3(0.587, -0.331264, -0.418688), + vec3(0.114, 0.5, -0.081312) +); +const mat3 ycbcr2rgb = mat3( + vec3(1.0, 1.0, 1.0), + vec3(0.0, -0.344136, 1.772), + vec3(1.402, -0.714136, 0.0) +); + +// simulating 8:4:4 compression ratio (16bit) +vec3 compress_ycbcr_844 (vec3 rgb) { + vec3 ycbcr = rgb2ycbcr * rgb; + ycbcr.r = floor(ycbcr.r * color_depth + 0.5) / color_depth; + ycbcr.gb += 0.5; + ycbcr.gb = floor(ycbcr.gb * color_number + 0.5) / color_number; + ycbcr.gb -= 0.5; + return ycbcr2rgb * ycbcr; +} + + +void fragment(){ + vec2 uv = FRAGCOORD.xy / (1.0 / SCREEN_PIXEL_SIZE).xy; + vec3 rgb = texture(SCREEN_TEXTURE, uv).rgb; + rgb = compress_ycbcr_844(rgb); + + COLOR = vec4(rgb,1.0); +} \ No newline at end of file diff --git a/Shaders/GodotRetro/Screen Shaders/JpegCompression.gdshader.uid b/Shaders/GodotRetro/Screen Shaders/JpegCompression.gdshader.uid new file mode 100644 index 00000000..4a91283b --- /dev/null +++ b/Shaders/GodotRetro/Screen Shaders/JpegCompression.gdshader.uid @@ -0,0 +1 @@ +uid://dh1d4na5apw2c diff --git a/Shaders/GodotRetro/Screen Shaders/LensDistortion.gdshader b/Shaders/GodotRetro/Screen Shaders/LensDistortion.gdshader new file mode 100644 index 00000000..99db8419 --- /dev/null +++ b/Shaders/GodotRetro/Screen Shaders/LensDistortion.gdshader @@ -0,0 +1,31 @@ +//SHADER ORIGINALY CREADED BY "jcant0n" FROM SHADERTOY +//MODIFIED AND PORTED TO GODOT BY AHOPNESS (@ahopness) +//LICENSE : CC0 +//COMATIBLE WITH : GLES2, GLES3, WEBGL +//SHADERTOY LINK : https://www.shadertoy.com/view/4sSSzz + +shader_type canvas_item; + +uniform sampler2D SCREEN_TEXTURE : hint_screen_texture, filter_linear_mipmap; + +uniform float strength :hint_range(-0.035, 0.035) = 0.0; + +void fragment(){ + vec2 Resolution = 1.0 / SCREEN_PIXEL_SIZE; + vec2 uv = FRAGCOORD.xy / Resolution.xy; + float aspectRatio = Resolution.x / Resolution.y; + + + vec2 intensity = vec2(strength * aspectRatio); + + vec2 coords = uv; + coords = (coords - 0.5) * 2.0; + + vec2 realCoordOffs; + realCoordOffs.x = (1.0 - coords.y * coords.y) * intensity.y * (coords.x); + realCoordOffs.y = (1.0 - coords.x * coords.x) * intensity.x * (coords.y); + + vec4 color = texture(SCREEN_TEXTURE, uv - realCoordOffs); + + COLOR = vec4(color); +} \ No newline at end of file diff --git a/Shaders/GodotRetro/Screen Shaders/LensDistortion.gdshader.uid b/Shaders/GodotRetro/Screen Shaders/LensDistortion.gdshader.uid new file mode 100644 index 00000000..6e387bd6 --- /dev/null +++ b/Shaders/GodotRetro/Screen Shaders/LensDistortion.gdshader.uid @@ -0,0 +1 @@ +uid://ccufdc3kdocaj diff --git a/Shaders/GodotRetro/Screen Shaders/NTSC.gdshader b/Shaders/GodotRetro/Screen Shaders/NTSC.gdshader new file mode 100644 index 00000000..685309f3 --- /dev/null +++ b/Shaders/GodotRetro/Screen Shaders/NTSC.gdshader @@ -0,0 +1,122 @@ +//SHADER ORIGINALY CREADED BY "ompuco" FROM SHADERTOY +//MODIFIED AND PORTED TO GODOT BY AHOPNESS (@ahopness) +//LICENSE : CC0 +//COMATIBLE WITH : GLES2, GLES3, WEBGL +//SHADERTOY LINK : https://www.shadertoy.com/view/XlsczN + +shader_type canvas_item; + +uniform sampler2D SCREEN_TEXTURE : hint_screen_texture, filter_linear_mipmap; + +uniform float blur_amount :hint_range(0.0, 8.0) = 3.0; +uniform float signal_quality :hint_range(0.0, 0.5) = 0; +uniform float bottom_strenth :hint_range(0.0, 6.0) = 3.0; +uniform sampler2D grain_tex; + +float grain (vec2 st, float iTime) { + return fract(sin(dot(st.xy, vec2(17.0,180.)))* 2500. + iTime); +} + +vec3 rgb2yiq(vec3 c){ + return vec3( + (0.2989 * c.x + 0.5959 * c.y + 0.2115 * c.z), + (0.5870 * c.x - 0.2744 * c.y - 0.5229 * c.z), + (0.1140 * c.x - 0.3216 * c.y + 0.3114 * c.z) + ); +} +vec3 yiq2rgb(vec3 c){ + return vec3( + (1.0 * c.x + 1.0 * c.y + 1.0 * c.z), + (0.956 * c.x - 0.2720 * c.y - 1.1060 * c.z), + (0.6210 * c.x - 0.6474 * c.y + 1.7046 * c.z) + ); +} + +vec2 Circle(float Start, float Points, float Point){ + float Rad = (3.141592 * 2.0 * (1.0 / Points)) * (Point + Start); + return vec2(-(.3+Rad), cos(Rad)); +} + +vec3 Blur(vec2 uv, float f, float d, float iTime, sampler2D iChannel0){ + float t = (sin(iTime * 5.0 + uv.y * 5.0)) / 10.0; + float b = 1.0; + + t = 0.0; + vec2 PixelOffset = vec2(d + .0005 * t, 0); + + float Start = 2.0 / 14.0; + vec2 Scale = 0.66 * blur_amount * 2.0 * PixelOffset.xy; + + vec3 N0 = texture(iChannel0, uv + Circle(Start, 14.0, 0.0) * Scale).rgb; + vec3 N1 = texture(iChannel0, uv + Circle(Start, 14.0, 1.0) * Scale).rgb; + vec3 N2 = texture(iChannel0, uv + Circle(Start, 14.0, 2.0) * Scale).rgb; + vec3 N3 = texture(iChannel0, uv + Circle(Start, 14.0, 3.0) * Scale).rgb; + vec3 N4 = texture(iChannel0, uv + Circle(Start, 14.0, 4.0) * Scale).rgb; + vec3 N5 = texture(iChannel0, uv + Circle(Start, 14.0, 5.0) * Scale).rgb; + vec3 N6 = texture(iChannel0, uv + Circle(Start, 14.0, 6.0) * Scale).rgb; + vec3 N7 = texture(iChannel0, uv + Circle(Start, 14.0, 7.0) * Scale).rgb; + vec3 N8 = texture(iChannel0, uv + Circle(Start, 14.0, 8.0) * Scale).rgb; + vec3 N9 = texture(iChannel0, uv + Circle(Start, 14.0, 9.0) * Scale).rgb; + vec3 N10 = texture(iChannel0, uv + Circle(Start, 14.0, 10.0) * Scale).rgb; + vec3 N11 = texture(iChannel0, uv + Circle(Start, 14.0, 11.0) * Scale).rgb; + vec3 N12 = texture(iChannel0, uv + Circle(Start, 14.0, 12.0) * Scale).rgb; + vec3 N13 = texture(iChannel0, uv + Circle(Start, 14.0, 13.0) * Scale).rgb; + vec3 N14 = texture(iChannel0, uv).rgb; + + vec4 clr = texture(iChannel0, uv); + float W = 1.0 / 15.0; + + clr.rgb= + (N0 * W) + + (N1 * W) + + (N2 * W) + + (N3 * W) + + (N4 * W) + + (N5 * W) + + (N6 * W) + + (N7 * W) + + (N8 * W) + + (N9 * W) + + (N10 * W) + + (N11 * W) + + (N12 * W) + + (N13 * W) + + (N14 * W); + + return vec3(clr.xyz)*b; +} + +void fragment(){ + float d = 0.1 * 1.0 / 50.0; + vec2 uv = FRAGCOORD.xy / (1.0 / SCREEN_PIXEL_SIZE).xy; + + float s = signal_quality * grain(vec2(uv.x, uv.y * 777777777777777.0), TIME); // Sorry... + // Main tearing + float e = min(0.30, pow(max(0.0, cos(uv.y * 4.0 + 0.3) - 0.75) * (s + 0.5) * 1.0, 3.0)) * 25.0; + s -= pow(texture(SCREEN_TEXTURE, vec2(0.01 + (uv.y * 32.0) / 32.0, 1.0)).r, 1.0); + uv.x += e * abs(s * 3.0); + // Bootom tearing + float r = texture(grain_tex, vec2(mod(TIME * 10.0, mod(TIME * 10.0, 256.0) * (1.0 / 256.0)), 0.0)).r * (2.0 * s); + uv.x += abs(r * pow(min(0.003, (uv.y - 0.15)) * bottom_strenth, 2.0)); + + // Apply blur + d = 0.051 + abs(sin(s / 4.0)); + float c = max(0.0001, 0.002 * d); + + COLOR.xyz = Blur(uv, 0.0, c + c * (uv.x), TIME, SCREEN_TEXTURE); + float y = rgb2yiq(COLOR.xyz).r; + + uv.x += 0.01 * d; + c *= 6.0; + COLOR.xyz = Blur(uv, 0.333 ,c, TIME, SCREEN_TEXTURE); + float i = rgb2yiq(COLOR.xyz).g; + + uv.x += 0.005 * d; + + c *= 2.50; + COLOR.xyz = Blur(uv, 0.666, c, TIME, SCREEN_TEXTURE); + float q = rgb2yiq(COLOR.xyz).b; + + COLOR.xyz = yiq2rgb(vec3(y, i, q)) - pow(s + e * 2.0, 3.0); + COLOR.xyz *= smoothstep(1.0, 0.999, uv.x - .1); +} \ No newline at end of file diff --git a/Shaders/GodotRetro/Screen Shaders/NTSC.gdshader.uid b/Shaders/GodotRetro/Screen Shaders/NTSC.gdshader.uid new file mode 100644 index 00000000..fe5ac906 --- /dev/null +++ b/Shaders/GodotRetro/Screen Shaders/NTSC.gdshader.uid @@ -0,0 +1 @@ +uid://bdqsd02hogctj diff --git a/Shaders/GodotRetro/Screen Shaders/NTSCBasic.gdshader b/Shaders/GodotRetro/Screen Shaders/NTSCBasic.gdshader new file mode 100644 index 00000000..2e145257 --- /dev/null +++ b/Shaders/GodotRetro/Screen Shaders/NTSCBasic.gdshader @@ -0,0 +1,79 @@ +//SHADER ORIGINALY CREADED BY "keijiro" FROM GITHUB +//MODIFIED AND PORTED TO GODOT BY AHOPNESS (@ahopness) +//LICENSE : MIT +//COMATIBLE WITH : GLES2, GLES3 +//GITHUB LINK : https://github.com/keijiro/KinoTube/ + +shader_type canvas_item; + +uniform sampler2D SCREEN_TEXTURE : hint_screen_texture, filter_linear_mipmap; + +uniform float _bleeding :hint_range(0, 1) = 0.5; +uniform float _fringing :hint_range(0, 1) = 0.5; +uniform float _scanline :hint_range(0, 1) = 0.5; +uniform bool linearColorSpace = true; + +vec3 LinearToGammaSpace (vec3 linRGB){ + linRGB = max(linRGB, vec3(0, 0, 0)); + return max(1.055 * pow(linRGB, vec3(0.416666667)) - 0.055, 0); +} +vec3 GammaToLinearSpace (vec3 sRGB){ + return sRGB * (sRGB * (sRGB * 0.305306011 + 0.682171111) + 0.012522878); +} + +vec3 RGB2YIQ(vec3 rgb){ + rgb = clamp(rgb, 0, 1); + if (!linearColorSpace){ + rgb = LinearToGammaSpace(rgb); + } + return mat3(vec3(0.299, 0.587, 0.114), + vec3(0.596, -0.274, -0.322), + vec3(0.211, -0.523, 0.313)) * rgb; +} +vec3 YIQ2RGB(vec3 yiq){ + vec3 rgb = mat3(vec3(1, 0.956, 0.621), + vec3(1, -0.272, -0.647), + vec3(1, -1.106, 1.703)) * yiq; + + rgb = clamp(rgb, 0, 1); + if (!linearColorSpace){ + rgb = GammaToLinearSpace(rgb); + } + + return rgb; +} + +vec3 SampleYIQ(vec2 uv, float du, sampler2D _MainTex){ + uv.x += du; + return RGB2YIQ(texture(_MainTex, uv).rgb); +} + +void fragment(){ + float bleedWidth = 0.04 * _bleeding; // width of bleeding + float bleedStep = 2.5 / (1.0 / SCREEN_PIXEL_SIZE).x; // max interval of taps + float bleedTaps = ceil(bleedWidth / bleedStep); + float bleedDelta = bleedWidth / bleedTaps; + float fringeWidth = 0.0025 * _fringing; // width of fringing + + vec2 uv = FRAGCOORD.xy / (1.0 / SCREEN_PIXEL_SIZE).xy; + vec3 yiq = SampleYIQ(uv, 0, SCREEN_TEXTURE); + + // Bleeding + for (float i = 0.0; i < bleedTaps; i++) + { + yiq.y += SampleYIQ(uv, - bleedTaps * i, SCREEN_TEXTURE).y; + yiq.z += SampleYIQ(uv, + bleedTaps * i, SCREEN_TEXTURE).z; + } + yiq.yz /= bleedTaps + 1.0; + + // Fringing + float y1 = SampleYIQ(uv, - fringeWidth, SCREEN_TEXTURE).x; + float y2 = SampleYIQ(uv, + fringeWidth, SCREEN_TEXTURE).x; + yiq.yz += y2 - y1; + + // Scanline + float scan = sin(uv.y * 500.0 * PI); + scan = mix(1.0, (scan + 1.0) / 2.0, _scanline); + + COLOR = vec4(YIQ2RGB(yiq * scan), 1); +} \ No newline at end of file diff --git a/Shaders/GodotRetro/Screen Shaders/NTSCBasic.gdshader.uid b/Shaders/GodotRetro/Screen Shaders/NTSCBasic.gdshader.uid new file mode 100644 index 00000000..24c37443 --- /dev/null +++ b/Shaders/GodotRetro/Screen Shaders/NTSCBasic.gdshader.uid @@ -0,0 +1 @@ +uid://c2dkdcb7wx84i diff --git a/Shaders/GodotRetro/Screen Shaders/SimpleGlitch.gdshader b/Shaders/GodotRetro/Screen Shaders/SimpleGlitch.gdshader new file mode 100644 index 00000000..fce5720d --- /dev/null +++ b/Shaders/GodotRetro/Screen Shaders/SimpleGlitch.gdshader @@ -0,0 +1,55 @@ +//SHADER ORIGINALY CREADED BY "Gaktan" FROM SHADERTOY +//MODIFIED AND PORTED TO GODOT BY AHOPNESS (@ahopness) +//LICENSE : CC0 +//COMATIBLE WITH : GLES2, GLES3 +//SHADERTOY LINK : https://www.shadertoy.com/view/Ms3XWH# + +shader_type canvas_item; + +uniform sampler2D SCREEN_TEXTURE : hint_screen_texture, filter_linear_mipmap; + +uniform float range = 0.03; +uniform float noiseQuality :hint_range(0,250) = 250.0; +uniform float noiseIntensity :hint_range(0, 0.05) = 0.005; +uniform float offsetIntensity = 0.01; +uniform float colorOffsetIntensity :hint_range(0,1.5) = 0.3; + +float rand(vec2 co){ + return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453); +} + +float verticalBar(float pos, float uvY, float offset){ + float edge0 = (pos - range); + float edge1 = (pos + range); + + float x = smoothstep(edge0, pos, uvY) * offset; + x -= smoothstep(pos, edge1, uvY) * offset; + return x; +} + +void fragment(){ + vec2 uv = FRAGCOORD.xy / (1.0 / SCREEN_PIXEL_SIZE).xy; + + for (float i = 0.0; i < 0.71; i += 0.1313){ + float d = mod(TIME - tan(TIME * 0.24 * i), 0); + float o = sin(1.0 - tan(TIME * 0.24 * i)); + o *= offsetIntensity; + uv.x += verticalBar(d, uv.y, o); + } + + float uvY = uv.y; + uvY *= noiseQuality; + uvY = float(int(uvY)) * (1.0 / noiseQuality); + float noise = rand(vec2(TIME * 0.00001, uvY)); + uv.x += noise * noiseIntensity; + + vec2 offsetR = vec2(0.006 * sin(TIME), 0.0) * colorOffsetIntensity; + vec2 offsetG = vec2(0.0073 * (cos(TIME * 0.97)), 0.0) * colorOffsetIntensity; + + float r = texture(SCREEN_TEXTURE, uv + offsetR).r; + float g = texture(SCREEN_TEXTURE, uv + offsetG).g; + float b = texture(SCREEN_TEXTURE, uv).b; + + vec4 tex = vec4(r, g, b, 1.0); + COLOR = tex; +} \ No newline at end of file diff --git a/Shaders/GodotRetro/Screen Shaders/SimpleGlitch.gdshader.uid b/Shaders/GodotRetro/Screen Shaders/SimpleGlitch.gdshader.uid new file mode 100644 index 00000000..425f889d --- /dev/null +++ b/Shaders/GodotRetro/Screen Shaders/SimpleGlitch.gdshader.uid @@ -0,0 +1 @@ +uid://c6fu1qcee2jws diff --git a/Shaders/GodotRetro/Screen Shaders/SimpleGrain.gdshader b/Shaders/GodotRetro/Screen Shaders/SimpleGrain.gdshader new file mode 100644 index 00000000..59d65a2d --- /dev/null +++ b/Shaders/GodotRetro/Screen Shaders/SimpleGrain.gdshader @@ -0,0 +1,32 @@ +//SHADER ORIGINALY CREADED BY "juniorxsound" FROM SHADERTOY +//MODIFIED AND PORTED TO GODOT BY AHOPNESS (@ahopness) +//LICENSE : CC0 +//COMATIBLE WITH : GLES2, GLES3, WEBGL +//SHADERTOY LINK : https://www.shadertoy.com/view/ldScWw + +shader_type canvas_item; + +uniform sampler2D SCREEN_TEXTURE : hint_screen_texture, filter_linear_mipmap; + +uniform float amount :hint_range(0.0, 0.4) = 0.1; + +float grain (vec2 st, float time){ + return fract(sin(dot(st.xy, vec2(17.0,180.)))* 2500. + time); +} + +void fragment(){ + //Coords + vec2 uv = FRAGCOORD.xy / (1.0 / SCREEN_PIXEL_SIZE).xy; + + //Produce some noise based on the coords + vec3 grainPlate = vec3(grain(uv, TIME)); + + //Get the image + vec4 img = texture(SCREEN_TEXTURE, uv); + + //Mix the two signals together + vec3 mixer = mix(img.rgb, grainPlate, amount); + + + COLOR = vec4(mixer,1.0); +} \ No newline at end of file diff --git a/Shaders/GodotRetro/Screen Shaders/SimpleGrain.gdshader.uid b/Shaders/GodotRetro/Screen Shaders/SimpleGrain.gdshader.uid new file mode 100644 index 00000000..edb82296 --- /dev/null +++ b/Shaders/GodotRetro/Screen Shaders/SimpleGrain.gdshader.uid @@ -0,0 +1 @@ +uid://cs82ebrrx0n6p diff --git a/Shaders/GodotRetro/Screen Shaders/TV.gdshader b/Shaders/GodotRetro/Screen Shaders/TV.gdshader new file mode 100644 index 00000000..cb80553d --- /dev/null +++ b/Shaders/GodotRetro/Screen Shaders/TV.gdshader @@ -0,0 +1,126 @@ +//SHADER ORIGINALY CREADED BY "ehj1" FROM SHADERTOY +//MODIFIED AND PORTED TO GODOT BY AHOPNESS (@ahopness) +//LICENSE : CC0 +//COMATIBLE WITH : GLES2, GLES3 +//SHADERTOY LINK : https://www.shadertoy.com/view/ldXGW4 + +shader_type canvas_item; + +uniform sampler2D SCREEN_TEXTURE : hint_screen_texture, filter_linear_mipmap; + +uniform float vertJerkOpt :hint_range(0,1) = 0.2; +uniform float vertMovementOpt :hint_range(0,1) = 0.0; +uniform float bottomStaticOpt :hint_range(0,5) = 0.0; +uniform float bottomStaticStrenth :hint_range(0.0, 1.5) = 0.7; +uniform float scalinesOpt :hint_range(0,6) = 0.8; +uniform float rgbOffsetOpt :hint_range(0,2) = 0.2; +uniform float horzFuzzOpt :hint_range(0,5) = 0.15; + +// Noise generation functions borrowed from: +// https://github.com/ashima/webgl-noise/blob/master/src/noise2D.glsl + +vec3 mod289vec3(vec3 x){ + return x - floor(x * (1.0 / 289.0)) * 289.0; +} + +vec2 mod289vec2(vec2 x){ + return x - floor(x * (1.0 / 289.0)) * 289.0; +} + +vec3 permute(vec3 x){ + return mod289vec3(((x*34.0)+1.0)*x); +} + +float snoise(vec2 v){ + const vec4 C = vec4(0.211324865405187, // (3.0-sqrt(3.0))/6.0 + 0.366025403784439, // 0.5*(sqrt(3.0)-1.0) + -0.577350269189626, // -1.0 + 2.0 * C.x + 0.024390243902439); // 1.0 / 41.0 + // First corner + vec2 i = floor(v + dot(v, C.yy) ); + vec2 x0 = v - i + dot(i, C.xx); + + // Other corners + vec2 i1; + //i1.x = step( x0.y, x0.x ); // x0.x > x0.y ? 1.0 : 0.0 + //i1.y = 1.0 - i1.x; + i1 = (x0.x > x0.y) ? vec2(1.0, 0.0) : vec2(0.0, 1.0); + // x0 = x0 - 0.0 + 0.0 * C.xx ; + // x1 = x0 - i1 + 1.0 * C.xx ; + // x2 = x0 - 1.0 + 2.0 * C.xx ; + vec4 x12 = x0.xyxy + C.xxzz; + x12.xy -= i1; + + // Permutations + i = mod289vec2(i); // Avoid truncation effects in permutation + vec3 p = permute( permute( i.y + vec3(0.0, i1.y, 1.0 )) + + i.x + vec3(0.0, i1.x, 1.0 )); + + vec3 m = max(0.5 - vec3(dot(x0,x0), dot(x12.xy,x12.xy), dot(x12.zw,x12.zw)), 0.0); + m = m*m ; + m = m*m ; + + // Gradients: 41 points uniformly over a line, mapped onto a diamond. + // The ring size 17*17 = 289 is close to a multiple of 41 (41*7 = 287) + + vec3 x = 2.0 * fract(p * C.www) - 1.0; + vec3 h = abs(x) - 0.5; + vec3 ox = floor(x + 0.5); + vec3 a0 = x - ox; + + // Normalise gradients implicitly by scaling m + // Approximation of: m *= inversesqrt( a0*a0 + h*h ); + m *= 1.79284291400159 - 0.85373472095314 * ( a0*a0 + h*h ); + + // Compute final noise value at P + vec3 g; + g.x = a0.x * x0.x + h.x * x0.y; + g.yz = a0.yz * x12.xz + h.yz * x12.yw; + return 130.0 * dot(m, g); +} + +float staticV(vec2 uv, float time){ + float staticHeight = snoise(vec2(9.0,float(time)*1.2+3.0))*bottomStaticStrenth+5.0; + float staticAmount = snoise(vec2(1.0,time*1.2-6.0))*0.1+0.3; + float staticStrength = snoise(vec2(-9.75,time*0.6-3.0))*2.0+2.0; + return (1.0-step(snoise(vec2(5.0*pow(time,2.0)+pow(uv.x*7.0,1.2),pow((mod(time,100.0)+100.0)*uv.y*0.3+3.0,staticHeight))),staticAmount))*staticStrength; +} + + +void fragment(){ + vec2 uv = FRAGCOORD.xy / (1.0 / SCREEN_PIXEL_SIZE).xy; + + float jerkOffset = (1.0-step(snoise(vec2(TIME*1.3,5.0)),0.8))*0.05; + + float fuzzOffset = snoise(vec2(TIME*15.0,uv.y*80.0))*0.003; + float largeFuzzOffset = snoise(vec2(TIME*1.0,uv.y*25.0))*0.004; + + float vertMovementOn = (1.0-step(snoise(vec2(TIME*0.2,8.0)),0.4))*vertMovementOpt; + float vertJerk = (1.0-step(snoise(vec2(TIME*1.5,5.0)),0.6))*vertJerkOpt; + float vertJerk2 = (1.0-step(snoise(vec2(TIME*5.5,5.0)),0.2))*vertJerkOpt; + float yOffset = abs(sin(TIME)*4.0)*vertMovementOn+vertJerk*vertJerk2*0.3; + float _y = mod(uv.y+yOffset,1.0); + + + float xOffset = (fuzzOffset + largeFuzzOffset) * horzFuzzOpt; + + float staticVal = 0.0; + + for (float y = -1.0; y <= 1.0; y += 1.0) { + float maxDist = 5.0/200.0; + float dist = y/200.0; + staticVal += staticV(vec2(uv.x,uv.y+dist), TIME)*(maxDist-abs(dist))*1.5; + } + + staticVal *= bottomStaticOpt; + + float red = texture(SCREEN_TEXTURE, vec2(uv.x + xOffset -0.01*rgbOffsetOpt,_y)).r+staticVal; + float green = texture(SCREEN_TEXTURE, vec2(uv.x + xOffset,_y)).g+staticVal; + float blue = texture(SCREEN_TEXTURE, vec2(uv.x + xOffset +0.01*rgbOffsetOpt,_y)).b+staticVal; + + vec3 color = vec3(red,green,blue); + float scanline = sin(uv.y*800.0)*0.04*scalinesOpt; + color -= scanline; + + COLOR = vec4(color,1.0); +} \ No newline at end of file diff --git a/Shaders/GodotRetro/Screen Shaders/TV.gdshader.uid b/Shaders/GodotRetro/Screen Shaders/TV.gdshader.uid new file mode 100644 index 00000000..a1c27a58 --- /dev/null +++ b/Shaders/GodotRetro/Screen Shaders/TV.gdshader.uid @@ -0,0 +1 @@ +uid://byta6yj01gx66 diff --git a/Shaders/GodotRetro/Screen Shaders/VHS.gdshader b/Shaders/GodotRetro/Screen Shaders/VHS.gdshader new file mode 100644 index 00000000..3eab88b1 --- /dev/null +++ b/Shaders/GodotRetro/Screen Shaders/VHS.gdshader @@ -0,0 +1,86 @@ +//SHADER ORIGINALY CREADED BY "FMS_Cat" FROM SHADERTOY +//MODIFIED AND PORTED TO GODOT BY AHOPNESS (@ahopness) +//LICENSE : CC0 +//COMATIBLE WITH : GLES2, GLES3 +//SHADERTOY LINK : https://www.shadertoy.com/view/XtBXDt + +shader_type canvas_item; + +uniform sampler2D SCREEN_TEXTURE : hint_screen_texture, filter_linear_mipmap; + +uniform float tape_wave_amount :hint_range (0, .04) = 0.003; +uniform float tape_crease_amount :hint_range (0, 15) = 2.5; +uniform float color_displacement :hint_range (0, 5) = 1; +uniform float lines_velocity :hint_range (0, 5) = 0.1; + +vec3 tex2D( sampler2D _tex, vec2 _p ){ + vec3 col = texture( _tex, _p ).xyz; + if ( 0.5 < abs( _p.x - 0.5 ) ) { + col = vec3( 0.1 ); + } + return col; +} + +float hash( vec2 _v ){ + return fract( sin( dot( _v, vec2( 89.44, 19.36 ) ) ) * 22189.22 ); +} + +float iHash( vec2 _v, vec2 _r ){ + float h00 = hash( vec2( floor( _v * _r + vec2( 0.0, 0.0 ) ) / _r ) ); + float h10 = hash( vec2( floor( _v * _r + vec2( 1.0, 0.0 ) ) / _r ) ); + float h01 = hash( vec2( floor( _v * _r + vec2( 0.0, 1.0 ) ) / _r ) ); + float h11 = hash( vec2( floor( _v * _r + vec2( 1.0, 1.0 ) ) / _r ) ); + vec2 ip = vec2( smoothstep( vec2( 0.0, 0.0 ), vec2( 1.0, 1.0 ), mod( _v*_r, 1. ) ) ); + return ( h00 * ( 1. - ip.x ) + h10 * ip.x ) * ( 1. - ip.y ) + ( h01 * ( 1. - ip.x ) + h11 * ip.x ) * ip.y; +} + +float noise( vec2 _v ){ + float sum = 0.; + for( float i=1.0; i<9.0; i++ ){ + sum += iHash( _v + vec2( i ), vec2( 2. * pow( 2., float( i ) ) ) ) / pow( 2., float( i ) ); + } + return sum; +} + +void fragment(){ + vec2 uv = FRAGCOORD.xy / (1.0 / SCREEN_PIXEL_SIZE).xy; + vec2 uvn = uv; + vec3 col = vec3( 0.0 ); + + // tape wave + uvn.x += ( noise( vec2( uvn.y, TIME ) ) - 0.5 )* 0.005; + uvn.x += ( noise( vec2( uvn.y * 100.0, TIME * 10.0 ) ) - 0.5 ) * tape_wave_amount; + + // tape crease + float tcPhase = clamp( ( sin( uvn.y * 8.0 - TIME * PI * 1.2 ) - 0.92 ) * noise( vec2( TIME ) ), 0.0, 0.01 ) * tape_crease_amount; + float tcNoise = max( noise( vec2( uvn.y * 100.0, TIME * 10.0 ) ) - 0.5, 0.0 ); + uvn.x = uvn.x - tcNoise * tcPhase; + + // switching noise + float snPhase = smoothstep( 0.03, 0.0, uvn.y ); + uvn.y += snPhase * 0.3; + uvn.x += snPhase * ( ( noise( vec2( uv.y * 100.0, TIME * 10.0 ) ) - 0.5 ) * 0.2 ); + + col = tex2D( SCREEN_TEXTURE, uvn ); + col *= 1.0 - tcPhase; + col = mix( + col, + col.yzx, + snPhase + ); + + // bloom + for( float x = -4.0; x < 2.5; x += 1.0 ){ + col.xyz += vec3( + tex2D( SCREEN_TEXTURE, uvn + vec2( x - 0.0, 0.0 ) * 0.007 ).x, + tex2D( SCREEN_TEXTURE, uvn + vec2( x - color_displacement, 0.0 ) * 0.007 ).y, + tex2D( SCREEN_TEXTURE, uvn + vec2( x - color_displacement * 2.0, 0.0 ) * 0.007 ).z + ) * 0.1; + } + col *= 0.6; + + // ac beat + col *= 1.0 + clamp( noise( vec2( 0.0, uv.y + TIME * lines_velocity ) ) * 0.6 - 0.25, 0.0, 0.1 ); + + COLOR = vec4( col, 1.0 ); +} \ No newline at end of file diff --git a/Shaders/GodotRetro/Screen Shaders/VHS.gdshader.uid b/Shaders/GodotRetro/Screen Shaders/VHS.gdshader.uid new file mode 100644 index 00000000..16c13e50 --- /dev/null +++ b/Shaders/GodotRetro/Screen Shaders/VHS.gdshader.uid @@ -0,0 +1 @@ +uid://cud5dr1oan8oe diff --git a/Shaders/GodotRetro/Screen Shaders/VHSPause.gdshader b/Shaders/GodotRetro/Screen Shaders/VHSPause.gdshader new file mode 100644 index 00000000..f9aa09e0 --- /dev/null +++ b/Shaders/GodotRetro/Screen Shaders/VHSPause.gdshader @@ -0,0 +1,45 @@ +//SHADER ORIGINALY CREADED BY "caaaaaaarter" FROM SHADERTOY +//MODIFIED AND PORTED TO GODOT BY AHOPNESS (@ahopness) +//LICENSE : CC0 +//COMATIBLE WITH : GLES2, GLES3 +//SHADERTOY LINK : https://www.shadertoy.com/view/4lB3Dc + +shader_type canvas_item; + +uniform sampler2D SCREEN_TEXTURE : hint_screen_texture, filter_linear_mipmap; + +uniform float shake_amount_x : hint_range(1, 500) = 250.0; +uniform float shake_amount_y : hint_range(1, 500) = 40.0; +uniform float white_hlines : hint_range(0, 50) = 50; +uniform float white_vlines : hint_range(0,80) = 80; + +float rand(vec2 co){ + return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453); +} + +void fragment(){ + vec4 texColor = vec4(0); + // get position to sample + vec2 samplePosition = FRAGCOORD.xy / (1.0 / SCREEN_PIXEL_SIZE).xy; + + float whiteNoise = 9999.0; + + // Jitter each line left and right + samplePosition.x = samplePosition.x+(rand(vec2(TIME,UV.y))-0.5)/shake_amount_x; + // Jitter the whole picture up and down + samplePosition.y = samplePosition.y+(rand(vec2(TIME))-0.5)/shake_amount_y; + // Slightly add color noise to each line + texColor = texColor + (vec4(-0.5)+vec4(rand(vec2(UV.y,TIME)),rand(vec2(UV.y,TIME+1.0)),rand(vec2(UV.y,TIME+2.0)),0))*0.1; + + // Either sample the texture, or just make the pixel white (to get the staticy-bit at the bottom) + whiteNoise = rand(vec2(floor(samplePosition.y*white_vlines),floor(samplePosition.x*white_hlines))+vec2(TIME,0)); + if (whiteNoise > 11.5-30.0*samplePosition.y || whiteNoise < 1.5-5.0*samplePosition.y) { + // Sample the texture. + //samplePosition.y = 1.0-samplePosition.y; //Fix for upside-down texture + texColor = texColor + texture(SCREEN_TEXTURE,samplePosition); + }else{ + // Use white. (I'm adding here so the color noise still applies) + texColor = vec4(1); + } + COLOR = texColor; +} \ No newline at end of file diff --git a/Shaders/GodotRetro/Screen Shaders/VHSPause.gdshader.uid b/Shaders/GodotRetro/Screen Shaders/VHSPause.gdshader.uid new file mode 100644 index 00000000..b67f2eea --- /dev/null +++ b/Shaders/GodotRetro/Screen Shaders/VHSPause.gdshader.uid @@ -0,0 +1 @@ +uid://btlt3p2o7oln0 diff --git a/Shaders/ursc/bayer_matrix/bayer16.png b/Shaders/ursc/bayer_matrix/bayer16.png new file mode 100644 index 00000000..cb1b1d15 --- /dev/null +++ b/Shaders/ursc/bayer_matrix/bayer16.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:078abc20c1e0d4fad664946e5e2c7eab3c61e658061ffa7cfaa1080b6a822d22 +size 805 diff --git a/Shaders/ursc/bayer_matrix/bayer16.png.import b/Shaders/ursc/bayer_matrix/bayer16.png.import new file mode 100644 index 00000000..0bb699db --- /dev/null +++ b/Shaders/ursc/bayer_matrix/bayer16.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://skw25od4cono" +path="res://.godot/imported/bayer16.png-34f360650481412bc35ae595301b7088.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Shaders/ursc/bayer_matrix/bayer16.png" +dest_files=["res://.godot/imported/bayer16.png-34f360650481412bc35ae595301b7088.ctex"] + +[params] + +compress/mode=3 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/uastc_level=0 +compress/rdo_quality_loss=0.0 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=true +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/channel_remap/red=0 +process/channel_remap/green=1 +process/channel_remap/blue=2 +process/channel_remap/alpha=3 +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=0 diff --git a/Shaders/ursc/bayer_matrix/bayer2.png b/Shaders/ursc/bayer_matrix/bayer2.png new file mode 100644 index 00000000..3007a274 --- /dev/null +++ b/Shaders/ursc/bayer_matrix/bayer2.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:437e8596f79cec9ad2affd97ecd17f7f8d9a7c74800c677bfa540ab7324b67e2 +size 79 diff --git a/Shaders/ursc/bayer_matrix/bayer2.png.import b/Shaders/ursc/bayer_matrix/bayer2.png.import new file mode 100644 index 00000000..ea3f1f3b --- /dev/null +++ b/Shaders/ursc/bayer_matrix/bayer2.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://cwoe6fvbp416w" +path="res://.godot/imported/bayer2.png-ab8463e7dd167859f3625308a8e41c2e.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Shaders/ursc/bayer_matrix/bayer2.png" +dest_files=["res://.godot/imported/bayer2.png-ab8463e7dd167859f3625308a8e41c2e.ctex"] + +[params] + +compress/mode=3 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/uastc_level=0 +compress/rdo_quality_loss=0.0 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=true +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/channel_remap/red=0 +process/channel_remap/green=1 +process/channel_remap/blue=2 +process/channel_remap/alpha=3 +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=0 diff --git a/Shaders/ursc/bayer_matrix/bayer4.png b/Shaders/ursc/bayer_matrix/bayer4.png new file mode 100644 index 00000000..5e0255c0 --- /dev/null +++ b/Shaders/ursc/bayer_matrix/bayer4.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:29505e17ea82ec00488a6ec510defb4a5423f7bc87c9f0fd45088a8cd624b57d +size 120 diff --git a/Shaders/ursc/bayer_matrix/bayer4.png.import b/Shaders/ursc/bayer_matrix/bayer4.png.import new file mode 100644 index 00000000..6230f634 --- /dev/null +++ b/Shaders/ursc/bayer_matrix/bayer4.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://b0bn2jlt30c6g" +path="res://.godot/imported/bayer4.png-c63a48367994b63e1d8b8aab910f8128.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Shaders/ursc/bayer_matrix/bayer4.png" +dest_files=["res://.godot/imported/bayer4.png-c63a48367994b63e1d8b8aab910f8128.ctex"] + +[params] + +compress/mode=3 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/uastc_level=0 +compress/rdo_quality_loss=0.0 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=true +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/channel_remap/red=0 +process/channel_remap/green=1 +process/channel_remap/blue=2 +process/channel_remap/alpha=3 +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=0 diff --git a/Shaders/ursc/bayer_matrix/bayer8.png b/Shaders/ursc/bayer_matrix/bayer8.png new file mode 100644 index 00000000..bede8de1 --- /dev/null +++ b/Shaders/ursc/bayer_matrix/bayer8.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6c00a300bcea229ad15106f8df895ac354950ada6527bdb45578155413476c43 +size 265 diff --git a/Shaders/ursc/bayer_matrix/bayer8.png.import b/Shaders/ursc/bayer_matrix/bayer8.png.import new file mode 100644 index 00000000..43322ca9 --- /dev/null +++ b/Shaders/ursc/bayer_matrix/bayer8.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://d11awhha7ixot" +path="res://.godot/imported/bayer8.png-8f65fccf4b2d9b00a79d95b700f242b4.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Shaders/ursc/bayer_matrix/bayer8.png" +dest_files=["res://.godot/imported/bayer8.png-8f65fccf4b2d9b00a79d95b700f242b4.ctex"] + +[params] + +compress/mode=3 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/uastc_level=0 +compress/rdo_quality_loss=0.0 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=true +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/channel_remap/red=0 +process/channel_remap/green=1 +process/channel_remap/blue=2 +process/channel_remap/alpha=3 +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=0 diff --git a/Shaders/ursc/canvas_item/dithering.gdshader b/Shaders/ursc/canvas_item/dithering.gdshader new file mode 100644 index 00000000..80e41ba9 --- /dev/null +++ b/Shaders/ursc/canvas_item/dithering.gdshader @@ -0,0 +1,30 @@ +#pragma disable_preprocessor + +shader_type canvas_item; + +// 0: bypass +uniform float color_depth: hint_range(0, 32, 8) = 24; + +uniform sampler2D dithering_pattern_texture: + hint_default_white, repeat_enable, filter_nearest; + +void fragment() +{ + vec3 base_color = texture(TEXTURE, UV).rgb; + + if (color_depth > 0.0) + { + vec2 dpt_size = vec2(textureSize(dithering_pattern_texture, 0)); + vec2 texture_size = vec2(textureSize(TEXTURE, 0)); + + vec3 dithering = texture( + dithering_pattern_texture, UV * (texture_size / dpt_size)).rgb - 0.5; + + COLOR.rgb = round( + base_color.rgb * color_depth + dithering) / color_depth; + } + else + { + COLOR.rgb = base_color; + } +} diff --git a/Shaders/ursc/canvas_item/dithering.gdshader.uid b/Shaders/ursc/canvas_item/dithering.gdshader.uid new file mode 100644 index 00000000..e685759c --- /dev/null +++ b/Shaders/ursc/canvas_item/dithering.gdshader.uid @@ -0,0 +1 @@ +uid://di7y6sooqe3t4 diff --git a/Shaders/ursc/canvas_item/fade.gdshader b/Shaders/ursc/canvas_item/fade.gdshader new file mode 100644 index 00000000..e2510059 --- /dev/null +++ b/Shaders/ursc/canvas_item/fade.gdshader @@ -0,0 +1,16 @@ +#pragma disable_preprocessor + +shader_type canvas_item; + +uniform sampler2D SCREEN_TEXTURE: hint_screen_texture, filter_nearest, repeat_disable; + +// 1: white +// -1: black +uniform int mode: hint_range(-1, 1, 2) = -1; + +void fragment() +{ + vec3 screen_color = texture(SCREEN_TEXTURE, SCREEN_UV).rgb; + COLOR.rgb = screen_color + COLOR.a * float(mode); + COLOR.a = 1.0; +} diff --git a/Shaders/ursc/canvas_item/fade.gdshader.uid b/Shaders/ursc/canvas_item/fade.gdshader.uid new file mode 100644 index 00000000..21554771 --- /dev/null +++ b/Shaders/ursc/canvas_item/fade.gdshader.uid @@ -0,0 +1 @@ +uid://ddas7a15ugrdn diff --git a/Shaders/ursc/setup.gd b/Shaders/ursc/setup.gd new file mode 100644 index 00000000..7429bd33 --- /dev/null +++ b/Shaders/ursc/setup.gd @@ -0,0 +1,57 @@ +# Ultimate Retro Shader Collection (v1.4.0): Setup Script +# +# This script will add the necessary shader globals for URSC shaders to your project.godot file. +# To run, just click File -> Run. +# In order to fully register the globals, the editor will be restarted upon running. +# +# NOTE: this script CAN'T be used to manage the globals for your game! You'll need to write your +# own code to handle the values of the globals at runtime. +@tool +extends EditorScript + + +var shader_globals := { + "affine_texture_mapping": { + "type": "bool", + "value": true + }, + "fog_color": { + "type": "color", + "value": Color(0, 0, 0, 1) + }, + "fog_start_distance": { + "type": "float", + "value": 0.0 + }, + "fog_end_distance": { + "type": "float", + "value": 0.0 + }, + "cull_distance": { + "type": "float", + "value": 64.0 + }, + "texture_filtering": { + "type": "bool", + "value": false + }, + "texture_lod_halve_distance": { + "type": "float", + "value": 0.0 + }, + "vertex_snap_intensity": { + "type": "int", + "value": 2 + } +} + + +func _run() -> void: + for key: String in shader_globals: + var full_key := "shader_globals/%s" % key + + if not ProjectSettings.has_setting(full_key): + ProjectSettings.set_setting(full_key, shader_globals[key]) + + ProjectSettings.save() + EditorInterface.restart_editor() diff --git a/Shaders/ursc/setup.gd.uid b/Shaders/ursc/setup.gd.uid new file mode 100644 index 00000000..bb857bc6 --- /dev/null +++ b/Shaders/ursc/setup.gd.uid @@ -0,0 +1 @@ +uid://d2ynev4mkmdct diff --git a/Shaders/ursc/spatial/basic/basic_opaque.gdshader b/Shaders/ursc/spatial/basic/basic_opaque.gdshader new file mode 100644 index 00000000..52f9b935 --- /dev/null +++ b/Shaders/ursc/spatial/basic/basic_opaque.gdshader @@ -0,0 +1,5 @@ +shader_type spatial; + +#define TEXTURE_DISABLED + +#include "../common.gdshaderinc" diff --git a/Shaders/ursc/spatial/basic/basic_opaque.gdshader.uid b/Shaders/ursc/spatial/basic/basic_opaque.gdshader.uid new file mode 100644 index 00000000..8f2dc184 --- /dev/null +++ b/Shaders/ursc/spatial/basic/basic_opaque.gdshader.uid @@ -0,0 +1 @@ +uid://blnsv83gfvq5v diff --git a/Shaders/ursc/spatial/basic/basic_transparent.gdshader b/Shaders/ursc/spatial/basic/basic_transparent.gdshader new file mode 100644 index 00000000..33b6568b --- /dev/null +++ b/Shaders/ursc/spatial/basic/basic_transparent.gdshader @@ -0,0 +1,6 @@ +shader_type spatial; + +#define ALPHA_BLEND +#define TEXTURE_DISABLED + +#include "../common.gdshaderinc" diff --git a/Shaders/ursc/spatial/basic/basic_transparent.gdshader.uid b/Shaders/ursc/spatial/basic/basic_transparent.gdshader.uid new file mode 100644 index 00000000..cc3e5ea2 --- /dev/null +++ b/Shaders/ursc/spatial/basic/basic_transparent.gdshader.uid @@ -0,0 +1 @@ +uid://lmobx4yb3rrs diff --git a/Shaders/ursc/spatial/common.gdshaderinc b/Shaders/ursc/spatial/common.gdshaderinc new file mode 100644 index 00000000..a3474450 --- /dev/null +++ b/Shaders/ursc/spatial/common.gdshaderinc @@ -0,0 +1,423 @@ +// If you want to use fog controlled by a Godot Environment resource (pixel-based), +// simply uncomment the following line: +// #define USE_ENVIRONMENT_FOG + +// Render mode +render_mode + +#if defined(BLEND_MODE) + BLEND_MODE, +#endif + +#if defined(CULL_MODE) + CULL_MODE, +#else + cull_back, +#endif + +#if defined(ALPHA_BLEND) + depth_draw_always, +#else + depth_draw_opaque, +#endif + +#if defined(UNSHADED) + unshaded, +#else + diffuse_lambert_wrap, + vertex_lighting, +#endif + +#if defined(AMBIENT_LIGHT_DISABLED) + ambient_light_disabled, +#endif + +#if defined(FOG_DISABLED) + fog_disabled, +#endif + +specular_disabled, +shadows_disabled; + + +// Constants +#if !defined(OVERRIDE_VERTEX_SNAP_RESOLUTION) + const ivec2 VERTEX_SNAP_RESOLUTION = ivec2(320, 240); +#endif + + +// Global uniforms +#if !defined(TEXTURE_DISABLED) && !defined(SHINY) + #if !defined(TEXTURE_METAL) + global uniform bool affine_texture_mapping; + #endif + + global uniform bool texture_filtering; + global uniform float texture_lod_halve_distance; +#endif + +#if defined(OVERRIDE_VERTEX_SNAP_RESOLUTION) + global uniform ivec2 vertex_snap_resolution; +#else + global uniform int vertex_snap_intensity; +#endif + +#if !defined(FOG_DISABLED) && !defined(USE_ENVIRONMENT_FOG) + global uniform vec4 fog_color : source_color; + global uniform float fog_start_distance; + global uniform float fog_end_distance; +#endif + +global uniform float cull_distance; + + +// Uniforms +#if defined(ALPHA_BLEND) || (defined(ALPHA_SCISSOR) && !defined(SHINY) && !defined(TEXTURE_METAL)) + uniform vec4 albedo_color : source_color = vec4(1.0); +#else + uniform vec3 albedo_color : source_color = vec3(1.0); +#endif + +#if defined(SHINY) + uniform float color_depth : hint_range(16, 64, 16) = 16; + uniform float glossiness : hint_range(0, 1, 0.05) = 0.4; + uniform float shadow_intensity : hint_range(0, 1, 0.05) = 0.65; +#elif !defined(TEXTURE_DISABLED) + uniform sampler2D albedo_texture : + source_color, + filter_nearest, + #if defined(TEXTURE_REPEAT) + repeat_enable; + #else + repeat_disable; + #endif + + #if (defined(ALPHA_SCISSOR) && !defined(SHINY) && !defined(TEXTURE_METAL)) + uniform float alpha_scissor : hint_range(0, 1, 0.01) = 0.1; + #else + uniform bool albedo_texture_as_primary_color = true; + uniform float mix_factor: hint_range(0.0, 1.0, 0.01) = 1.0; + #endif + + uniform float texture_lod_halve_distance_override : hint_range(0.0, 32.0, 2.0) = 0; + + #if !defined(TEXTURE_METAL) + uniform vec2 uv_offset = vec2(0.0); + uniform vec2 uv_scale = vec2(1.0); + uniform vec2 uv_scroll_speed = vec2(0.0); + #endif +#endif + +#if defined(BILLBOARD) + uniform int billboard_mode: hint_range(0, 2); + uniform bool use_transform_scale = true; +#endif + +uniform float cull_distance_override: hint_range(0.0, 1024.0, 2.0) = 0; + +uniform bool convert_vertex_colors = false; + + +// Varyings +#if !defined(TEXTURE_DISABLED) && !defined(TEXTURE_METAL) && !defined(SHINY) + varying float position_w; +#endif + +#if !defined(TEXTURE_DISABLED) && !defined(SHINY) + varying flat int should_halve_texture_lod; +#endif + +#if !defined(FOG_DISABLED) && !defined(USE_ENVIRONMENT_FOG) + varying float fog_mix_factor; +#endif + +// Functions +#if defined(SHINY) + vec3 glimmer(vec3 input) + { + float grayscale = max(vec3(input).r, max(vec3(input).g, vec3(input).b)); + float lower = floor(grayscale * color_depth) / color_depth; + float lower_difference = abs(grayscale - lower); + float upper = ceil(grayscale * color_depth) / color_depth; + float upper_difference = abs(upper - grayscale); + float level = lower_difference <= upper_difference ? lower : upper; + float adjustment = level / grayscale; + return vec3(input) * adjustment; + } +#elif !defined(TEXTURE_DISABLED) + vec4 albedoTextureFiltered(vec2 uv) + { + vec2 albedo_texture_size = vec2(textureSize(albedo_texture, 0)); + + vec2 tex_pix_a = vec2(1.0 / albedo_texture_size.x, 0.0); + vec2 tex_pix_b = vec2(0.0, 1.0 / albedo_texture_size.y); + vec2 tex_pix_c = vec2(tex_pix_a.x,tex_pix_b.y); + vec2 half_tex = vec2(tex_pix_a.x * 0.5, tex_pix_b.y * 0.5); + vec2 uv_centered = uv - half_tex; + + vec4 diffuse_color = texture(albedo_texture, uv_centered); + vec4 sample_a = texture(albedo_texture, uv_centered + tex_pix_a); + vec4 sample_b = texture(albedo_texture, uv_centered + tex_pix_b); + vec4 sample_c = texture(albedo_texture, uv_centered + tex_pix_c); + + float interp_x = modf(uv_centered.x * albedo_texture_size.x, albedo_texture_size.x); + float interp_y = modf(uv_centered.y * albedo_texture_size.y, albedo_texture_size.y); + + if (uv_centered.x < 0.0) + { + interp_x = 1.0 - interp_x * -1.0; + } + if (uv_centered.y < 0.0) + { + interp_y = 1.0 - interp_y * -1.0; + } + + diffuse_color = ( + diffuse_color + + interp_x * (sample_a - diffuse_color) + + interp_y * (sample_b - diffuse_color)) * + (1.0 - step(1.0, interp_x + interp_y)); + + diffuse_color += ( + (sample_c + (1.0 - interp_x) * (sample_b - sample_c) + + (1.0 - interp_y) * (sample_a - sample_c)) * + step(1.0, interp_x + interp_y)); + + return diffuse_color; + } +#endif + +// https://gamedev.stackexchange.com/a/194038 +vec3 fromLinear(vec3 linear_color) +{ + bvec3 cutoff = lessThan(linear_color.rgb, vec3(0.0031308)); + vec3 higher = vec3(1.055) * pow(linear_color.rgb, vec3(1.0 / 2.4)) - vec3(0.055); + vec3 lower = linear_color.rgb * vec3(12.92); + + return mix(higher, lower, cutoff); +} + +// https://gamedev.stackexchange.com/a/194038 +vec3 toLinear(vec3 srgb_color) +{ + bvec3 cutoff = lessThan(srgb_color.rgb, vec3(0.04045)); + vec3 higher = pow((srgb_color.rgb + vec3(0.055)) / vec3(1.055), vec3(2.4)); + vec3 lower = srgb_color.rgb / vec3(12.92); + + return mix(higher, lower, cutoff); +} + +void vertex() +{ + if (convert_vertex_colors) + COLOR.rgb = fromLinear(COLOR.rgb); + + #if !defined(TEXTURE_DISABLED) && !defined(TEXTURE_METAL) && !defined(SHINY) + UV = UV * uv_scale + uv_offset + (uv_scroll_speed * TIME); + #endif + + #if defined(BILLBOARD) + if (billboard_mode > 0) + { + if (billboard_mode == 1) + { + MODELVIEW_MATRIX = VIEW_MATRIX * mat4( + INV_VIEW_MATRIX[0], + INV_VIEW_MATRIX[1], + INV_VIEW_MATRIX[2], + MODEL_MATRIX[3]); + } + else + { + MODELVIEW_MATRIX = VIEW_MATRIX * mat4( + vec4(normalize(cross(vec3(0.0, 1.0, 0.0), INV_VIEW_MATRIX[2].xyz)), 0.0), + vec4(0.0, 1.0, 0.0, 0.0), + vec4(normalize(cross(INV_VIEW_MATRIX[0].xyz, vec3(0.0, 1.0, 0.0))), 0.0), + MODEL_MATRIX[3]); + } + + if (use_transform_scale) + { + MODELVIEW_MATRIX = MODELVIEW_MATRIX * mat4( + vec4(length(MODEL_MATRIX[0].xyz), 0.0, 0.0, 0.0), + vec4(0.0, length(MODEL_MATRIX[1].xyz), 0.0, 0.0), + vec4(0.0, 0.0, length(MODEL_MATRIX[2].xyz), 0.0), + vec4(0.0, 0.0, 0.0, 1.0)); + } + + MODELVIEW_NORMAL_MATRIX = mat3(MODELVIEW_MATRIX); + } + #endif + + float vertex_distance = length((MODELVIEW_MATRIX * vec4(VERTEX, 1.0))); + + #if !defined(FOG_DISABLED) && !defined(USE_ENVIRONMENT_FOG) + if (fog_start_distance >= 0.0 && fog_start_distance < fog_end_distance) + { + fog_mix_factor = clamp( + (vertex_distance - fog_start_distance) / (fog_end_distance - fog_start_distance), + 0.0, 1.0); + } + else + { + fog_mix_factor = 0.0; + } + #endif + + #if !defined(TEXTURE_DISABLED) && !defined(SHINY) + float actual_texture_lod_halve_distance = + texture_lod_halve_distance_override > 0.0 + ? texture_lod_halve_distance_override + : texture_lod_halve_distance; + + should_halve_texture_lod = ( + !texture_filtering && + actual_texture_lod_halve_distance > 0.0 && + vertex_distance > actual_texture_lod_halve_distance) ? 1 : 0; + #endif + + float actual_cull_distance = + cull_distance_override > 0.0 ? cull_distance_override : cull_distance; + + if (actual_cull_distance > 0.0 && vertex_distance > actual_cull_distance) + { + POSITION = vec4(sqrt(-1)); + } + else + { + POSITION = PROJECTION_MATRIX * MODELVIEW_MATRIX * vec4(VERTEX, 1.0); + + #if defined(OVERRIDE_VERTEX_SNAP_RESOLUTION) + vec4 snapped_position = POSITION; + snapped_position.xyz = POSITION.xyz / POSITION.w; + + vec2 actual_vertex_snap_resolution = vec2(vertex_snap_resolution); + + snapped_position.x = + floor(actual_vertex_snap_resolution.x * snapped_position.x) / + actual_vertex_snap_resolution.x; + + snapped_position.y = + floor(actual_vertex_snap_resolution.y * snapped_position.y) / + actual_vertex_snap_resolution.y; + + snapped_position.xyz *= POSITION.w; + + POSITION.xyz = snapped_position.xyz; + #else + if (vertex_snap_intensity > 0 && vertex_snap_intensity <= 2) + { + vec2 real_vertex_snap_resolution = + vec2(VERTEX_SNAP_RESOLUTION) * (1.0 / float(vertex_snap_intensity)); + + vec4 snapped_position = POSITION; + snapped_position.xyz = POSITION.xyz / POSITION.w; + + snapped_position.x = + floor(real_vertex_snap_resolution.x * snapped_position.x) / + real_vertex_snap_resolution.x; + + snapped_position.y = + floor(real_vertex_snap_resolution.y * snapped_position.y) / + real_vertex_snap_resolution.y; + + snapped_position.xyz *= POSITION.w; + + POSITION.xyz = snapped_position.xyz; + } + #endif + } + + #if !defined(TEXTURE_DISABLED) && !defined(TEXTURE_METAL) && !defined(SHINY) + if (affine_texture_mapping) + { + position_w = POSITION.w; + UV *= abs(POSITION.w); + } + #endif +} + +void fragment() +{ + #if defined(SHINY) + vec3 light_dir = vec3(0.500000, 0.250000, 1.000000); + float light_dot = dot(light_dir, NORMAL); + vec3 brightness = glimmer(vec3(pow(light_dot, 10.0))); + brightness = clamp(brightness * vec3(glossiness), vec3(0.00000), vec3(1.00000)); + vec3 shadow_dir = vec3(-light_dir.x, -light_dir.y, light_dir.z); + float dark_dot = dot(NORMAL, shadow_dir); + vec3 darkness = glimmer(vec3(dark_dot)); + + ALBEDO = + clamp(albedo_color.rgb + + brightness + + darkness * vec3(-shadow_intensity), 0.0, 1.0); + + #if defined(ALPHA_BLEND) + ALPHA = albedo_color.a; + #endif + #else + #if defined(TEXTURE_DISABLED) + ALBEDO = albedo_color.rgb * COLOR.rgb; + + #if defined(ALPHA_BLEND) + ALPHA = albedo_color.a * COLOR.a; + #endif + #else + vec2 uv; + + #if defined(TEXTURE_METAL) + uv = vec2(NORMAL.x / 2.0 + 0.5, (-NORMAL.y) / 2.0 + 0.5); + #else + uv = UV; + + if (affine_texture_mapping) + uv /= abs(position_w); + #endif + + vec4 sampled_color; + + if (should_halve_texture_lod == 1) + { + vec2 half_albedo_texture_size = vec2(textureSize(albedo_texture, 0)) * 0.5; + vec2 new_uv = floor(uv * half_albedo_texture_size) / half_albedo_texture_size; + + sampled_color = texture(albedo_texture, new_uv); + } + else + { + if (texture_filtering) + sampled_color = albedoTextureFiltered(uv); + else + sampled_color = texture(albedo_texture, uv); + } + + #if (defined(ALPHA_SCISSOR) && !defined(SHINY) && !defined(TEXTURE_METAL)) + ALBEDO = albedo_color.rgb * sampled_color.rgb; + ALPHA = albedo_color.a * sampled_color.a; + ALPHA_SCISSOR_THRESHOLD = alpha_scissor; + #else + vec3 primary_color = + albedo_texture_as_primary_color ? sampled_color.rgb : COLOR.rgb; + + vec3 secondary_color = + albedo_texture_as_primary_color ? COLOR.rgb : sampled_color.rgb; + + ALBEDO = + (1.0 - mix_factor) * primary_color + + mix_factor * secondary_color * primary_color; + + ALBEDO *= albedo_color.rgb; + + #if defined(ALPHA_BLEND) + ALPHA = albedo_color.a * sampled_color.a * COLOR.a; + #endif + #endif + #endif + #endif + + #if !defined(FOG_DISABLED) && !defined(USE_ENVIRONMENT_FOG) + FOG.a = fog_mix_factor; + FOG.rgb = toLinear(fog_color.rgb); + #endif +} diff --git a/Shaders/ursc/spatial/common.gdshaderinc.uid b/Shaders/ursc/spatial/common.gdshaderinc.uid new file mode 100644 index 00000000..84840cf0 --- /dev/null +++ b/Shaders/ursc/spatial/common.gdshaderinc.uid @@ -0,0 +1 @@ +uid://bwv4igqcg3xha diff --git a/Shaders/ursc/spatial/flat_sky.gdshader b/Shaders/ursc/spatial/flat_sky.gdshader new file mode 100644 index 00000000..f7725787 --- /dev/null +++ b/Shaders/ursc/spatial/flat_sky.gdshader @@ -0,0 +1,75 @@ +shader_type spatial; +render_mode unshaded; + +global uniform bool texture_filtering; + +uniform sampler2D albedo_texture : source_color, filter_nearest, repeat_enable; +uniform vec2 uv_offset = vec2(0.0); +uniform vec2 uv_scale = vec2(1.0); +uniform vec2 uv_scroll_speed = vec2(0.0); + +vec4 albedoTextureFiltered(vec2 uv) +{ + vec2 albedo_texture_size = vec2(textureSize(albedo_texture, 0)); + + vec2 tex_pix_a = vec2(1.0 / albedo_texture_size.x, 0.0); + vec2 tex_pix_b = vec2(0.0, 1.0 / albedo_texture_size.y); + vec2 tex_pix_c = vec2(tex_pix_a.x,tex_pix_b.y); + vec2 half_tex = vec2(tex_pix_a.x * 0.5, tex_pix_b.y * 0.5); + vec2 uv_centered = uv - half_tex; + + vec4 diffuse_color = texture(albedo_texture, uv_centered); + vec4 sample_a = texture(albedo_texture, uv_centered + tex_pix_a); + vec4 sample_b = texture(albedo_texture, uv_centered + tex_pix_b); + vec4 sample_c = texture(albedo_texture, uv_centered + tex_pix_c); + + float interp_x = modf(uv_centered.x * albedo_texture_size.x, albedo_texture_size.x); + float interp_y = modf(uv_centered.y * albedo_texture_size.y, albedo_texture_size.y); + + if (uv_centered.x < 0.0) + { + interp_x = 1.0 - interp_x * -1.0; + } + if (uv_centered.y < 0.0) + { + interp_y = 1.0 - interp_y * -1.0; + } + + diffuse_color = ( + diffuse_color + + interp_x * (sample_a - diffuse_color) + + interp_y * (sample_b - diffuse_color)) * + (1.0 - step(1.0, interp_x + interp_y)); + + diffuse_color += ( + (sample_c + (1.0 - interp_x) * (sample_b - sample_c) + + (1.0 - interp_y) * (sample_a - sample_c)) * + step(1.0, interp_x + interp_y)); + + return diffuse_color; +} + +void fragment() +{ + float y = atan(VIEW_MATRIX[0][2], VIEW_MATRIX[2][2]); + float x = asin(VIEW_MATRIX[1][2]); + + vec2 bg_coordinates = (vec2(y * 0.5, -x) * -(1.0 / PI)) + 0.5; + bg_coordinates.y *= 0.5; + + vec2 bg_scale; + + bg_scale.y = 0.5; + + vec2 albedo_texture_size = vec2(textureSize(albedo_texture, 0)); + float aspect_ratio = albedo_texture_size.x / albedo_texture_size.y; + bg_scale.x = VIEWPORT_SIZE.x / (VIEWPORT_SIZE.y * aspect_ratio) * bg_scale.y; + + vec2 uv = ( + SCREEN_UV * uv_scale + uv_offset + (uv_scroll_speed * TIME)) * bg_scale + bg_coordinates; + + if (texture_filtering) + ALBEDO = albedoTextureFiltered(uv).rgb; + else + ALBEDO = texture(albedo_texture, uv).rgb; +} diff --git a/Shaders/ursc/spatial/flat_sky.gdshader.uid b/Shaders/ursc/spatial/flat_sky.gdshader.uid new file mode 100644 index 00000000..ebf4aeca --- /dev/null +++ b/Shaders/ursc/spatial/flat_sky.gdshader.uid @@ -0,0 +1 @@ +uid://cg0jhqx4unew2 diff --git a/Shaders/ursc/spatial/metallic/metallic_opaque.gdshader b/Shaders/ursc/spatial/metallic/metallic_opaque.gdshader new file mode 100644 index 00000000..091c4ab0 --- /dev/null +++ b/Shaders/ursc/spatial/metallic/metallic_opaque.gdshader @@ -0,0 +1,5 @@ +shader_type spatial; + +#define TEXTURE_METAL + +#include "../common.gdshaderinc" diff --git a/Shaders/ursc/spatial/metallic/metallic_opaque.gdshader.uid b/Shaders/ursc/spatial/metallic/metallic_opaque.gdshader.uid new file mode 100644 index 00000000..7c92d1b5 --- /dev/null +++ b/Shaders/ursc/spatial/metallic/metallic_opaque.gdshader.uid @@ -0,0 +1 @@ +uid://lj4sb7s1xtsd diff --git a/Shaders/ursc/spatial/metallic/metallic_transparent.gdshader b/Shaders/ursc/spatial/metallic/metallic_transparent.gdshader new file mode 100644 index 00000000..296894d7 --- /dev/null +++ b/Shaders/ursc/spatial/metallic/metallic_transparent.gdshader @@ -0,0 +1,6 @@ +shader_type spatial; + +#define ALPHA_BLEND +#define TEXTURE_METAL + +#include "../common.gdshaderinc" diff --git a/Shaders/ursc/spatial/metallic/metallic_transparent.gdshader.uid b/Shaders/ursc/spatial/metallic/metallic_transparent.gdshader.uid new file mode 100644 index 00000000..f5b832d0 --- /dev/null +++ b/Shaders/ursc/spatial/metallic/metallic_transparent.gdshader.uid @@ -0,0 +1 @@ +uid://eqvesjeeu5qb diff --git a/Shaders/ursc/spatial/shiny/shiny_opaque.gdshader b/Shaders/ursc/spatial/shiny/shiny_opaque.gdshader new file mode 100644 index 00000000..ddf0b9f1 --- /dev/null +++ b/Shaders/ursc/spatial/shiny/shiny_opaque.gdshader @@ -0,0 +1,5 @@ +shader_type spatial; + +#define SHINY + +#include "../common.gdshaderinc" diff --git a/Shaders/ursc/spatial/shiny/shiny_opaque.gdshader.uid b/Shaders/ursc/spatial/shiny/shiny_opaque.gdshader.uid new file mode 100644 index 00000000..9182561a --- /dev/null +++ b/Shaders/ursc/spatial/shiny/shiny_opaque.gdshader.uid @@ -0,0 +1 @@ +uid://mw3hhv4kji5n diff --git a/Shaders/ursc/spatial/shiny/shiny_transparent.gdshader b/Shaders/ursc/spatial/shiny/shiny_transparent.gdshader new file mode 100644 index 00000000..b3a7b949 --- /dev/null +++ b/Shaders/ursc/spatial/shiny/shiny_transparent.gdshader @@ -0,0 +1,6 @@ +shader_type spatial; + +#define ALPHA_BLEND +#define SHINY + +#include "../common.gdshaderinc" diff --git a/Shaders/ursc/spatial/shiny/shiny_transparent.gdshader.uid b/Shaders/ursc/spatial/shiny/shiny_transparent.gdshader.uid new file mode 100644 index 00000000..cd4e2db6 --- /dev/null +++ b/Shaders/ursc/spatial/shiny/shiny_transparent.gdshader.uid @@ -0,0 +1 @@ +uid://ccqmm7d1gj1g diff --git a/Shaders/ursc/spatial/sprite/sprite_shaded.gdshader b/Shaders/ursc/spatial/sprite/sprite_shaded.gdshader new file mode 100644 index 00000000..e58a1e01 --- /dev/null +++ b/Shaders/ursc/spatial/sprite/sprite_shaded.gdshader @@ -0,0 +1,6 @@ +shader_type spatial; + +#define ALPHA_SCISSOR +#define BILLBOARD + +#include "../common.gdshaderinc" diff --git a/Shaders/ursc/spatial/sprite/sprite_shaded.gdshader.uid b/Shaders/ursc/spatial/sprite/sprite_shaded.gdshader.uid new file mode 100644 index 00000000..7e3b2179 --- /dev/null +++ b/Shaders/ursc/spatial/sprite/sprite_shaded.gdshader.uid @@ -0,0 +1 @@ +uid://dsippjvhgdop7 diff --git a/Shaders/ursc/spatial/sprite/sprite_shaded_double_sided.gdshader b/Shaders/ursc/spatial/sprite/sprite_shaded_double_sided.gdshader new file mode 100644 index 00000000..51d833e4 --- /dev/null +++ b/Shaders/ursc/spatial/sprite/sprite_shaded_double_sided.gdshader @@ -0,0 +1,7 @@ +shader_type spatial; + +#define CULL_MODE cull_disabled +#define ALPHA_SCISSOR +#define BILLBOARD + +#include "../common.gdshaderinc" diff --git a/Shaders/ursc/spatial/sprite/sprite_shaded_double_sided.gdshader.uid b/Shaders/ursc/spatial/sprite/sprite_shaded_double_sided.gdshader.uid new file mode 100644 index 00000000..b6466c74 --- /dev/null +++ b/Shaders/ursc/spatial/sprite/sprite_shaded_double_sided.gdshader.uid @@ -0,0 +1 @@ +uid://cr842teg4a11 diff --git a/Shaders/ursc/spatial/sprite/sprite_unshaded.gdshader b/Shaders/ursc/spatial/sprite/sprite_unshaded.gdshader new file mode 100644 index 00000000..40811bd7 --- /dev/null +++ b/Shaders/ursc/spatial/sprite/sprite_unshaded.gdshader @@ -0,0 +1,7 @@ +shader_type spatial; + +#define UNSHADED +#define ALPHA_SCISSOR +#define BILLBOARD + +#include "../common.gdshaderinc" diff --git a/Shaders/ursc/spatial/sprite/sprite_unshaded.gdshader.uid b/Shaders/ursc/spatial/sprite/sprite_unshaded.gdshader.uid new file mode 100644 index 00000000..1ae9452d --- /dev/null +++ b/Shaders/ursc/spatial/sprite/sprite_unshaded.gdshader.uid @@ -0,0 +1 @@ +uid://byn7w2xv2jyn8 diff --git a/Shaders/ursc/spatial/sprite/sprite_unshaded_double_sided.gdshader b/Shaders/ursc/spatial/sprite/sprite_unshaded_double_sided.gdshader new file mode 100644 index 00000000..4e05ea82 --- /dev/null +++ b/Shaders/ursc/spatial/sprite/sprite_unshaded_double_sided.gdshader @@ -0,0 +1,8 @@ +shader_type spatial; + +#define CULL_MODE cull_disabled +#define UNSHADED +#define ALPHA_SCISSOR +#define BILLBOARD + +#include "../common.gdshaderinc" diff --git a/Shaders/ursc/spatial/sprite/sprite_unshaded_double_sided.gdshader.uid b/Shaders/ursc/spatial/sprite/sprite_unshaded_double_sided.gdshader.uid new file mode 100644 index 00000000..c3a25dad --- /dev/null +++ b/Shaders/ursc/spatial/sprite/sprite_unshaded_double_sided.gdshader.uid @@ -0,0 +1 @@ +uid://drtaaolg5pwd7 diff --git a/Shaders/ursc/spatial/standard/standard_opaque.gdshader b/Shaders/ursc/spatial/standard/standard_opaque.gdshader new file mode 100644 index 00000000..46be047b --- /dev/null +++ b/Shaders/ursc/spatial/standard/standard_opaque.gdshader @@ -0,0 +1,3 @@ +shader_type spatial; + +#include "../common.gdshaderinc" diff --git a/Shaders/ursc/spatial/standard/standard_opaque.gdshader.uid b/Shaders/ursc/spatial/standard/standard_opaque.gdshader.uid new file mode 100644 index 00000000..6a72e981 --- /dev/null +++ b/Shaders/ursc/spatial/standard/standard_opaque.gdshader.uid @@ -0,0 +1 @@ +uid://djgcfdm8l1rif diff --git a/Shaders/ursc/spatial/standard/standard_opaque_repeating.gdshader b/Shaders/ursc/spatial/standard/standard_opaque_repeating.gdshader new file mode 100644 index 00000000..4453d602 --- /dev/null +++ b/Shaders/ursc/spatial/standard/standard_opaque_repeating.gdshader @@ -0,0 +1,5 @@ +shader_type spatial; + +#define TEXTURE_REPEAT + +#include "../common.gdshaderinc" diff --git a/Shaders/ursc/spatial/standard/standard_opaque_repeating.gdshader.uid b/Shaders/ursc/spatial/standard/standard_opaque_repeating.gdshader.uid new file mode 100644 index 00000000..c2b98ee9 --- /dev/null +++ b/Shaders/ursc/spatial/standard/standard_opaque_repeating.gdshader.uid @@ -0,0 +1 @@ +uid://8576et1il4r8 diff --git a/Shaders/ursc/spatial/standard/standard_transparent.gdshader b/Shaders/ursc/spatial/standard/standard_transparent.gdshader new file mode 100644 index 00000000..ab32d754 --- /dev/null +++ b/Shaders/ursc/spatial/standard/standard_transparent.gdshader @@ -0,0 +1,5 @@ +shader_type spatial; + +#define ALPHA_BLEND + +#include "../common.gdshaderinc" diff --git a/Shaders/ursc/spatial/standard/standard_transparent.gdshader.uid b/Shaders/ursc/spatial/standard/standard_transparent.gdshader.uid new file mode 100644 index 00000000..ddb37428 --- /dev/null +++ b/Shaders/ursc/spatial/standard/standard_transparent.gdshader.uid @@ -0,0 +1 @@ +uid://buhrkcg1liti7 diff --git a/Shaders/ursc/spatial/standard/standard_transparent_repeating.gdshader b/Shaders/ursc/spatial/standard/standard_transparent_repeating.gdshader new file mode 100644 index 00000000..ab32d754 --- /dev/null +++ b/Shaders/ursc/spatial/standard/standard_transparent_repeating.gdshader @@ -0,0 +1,5 @@ +shader_type spatial; + +#define ALPHA_BLEND + +#include "../common.gdshaderinc" diff --git a/Shaders/ursc/spatial/standard/standard_transparent_repeating.gdshader.uid b/Shaders/ursc/spatial/standard/standard_transparent_repeating.gdshader.uid new file mode 100644 index 00000000..fc09163d --- /dev/null +++ b/Shaders/ursc/spatial/standard/standard_transparent_repeating.gdshader.uid @@ -0,0 +1 @@ +uid://p6pilaf5disk