One_Eleven_Android/tv2_shader.gdshader
2024-11-10 03:34:28 +03:00

51 lines
No EOL
1.3 KiB
Text

shader_type canvas_item;
uniform float scanline_count : hint_range(0, 1800) = 50.0;
vec2 uv_curve(vec2 uv)
{
float rotation = -3.1415/8f;
uv = (uv - 0.5) * 2.0;
//You can modify the numbers and try different values
uv.x *= 1.0 + pow(abs(uv.y) / 3.0, 2.0);
uv.y *= 1.0 + pow(abs(uv.x) / 3.0, 2.0);
//The scale part (you can delete it when you want)
uv /= 1.2;
uv = (uv/2.0) + 0.5;
vec2 pivot=vec2(0.5);
float sine = sin(rotation);
float cosine = cos(rotation);
uv -= pivot;
uv.x = uv.x * cosine - uv.y * sine;
uv.y = uv.x * sine + uv.y * cosine;
uv += pivot;
return uv;
}
void fragment()
{
float PI = 3.14159;
//You can modify the *3.0, *-3.0 for a bigger or smaller
float r = texture(TEXTURE, uv_curve(SCREEN_UV) + vec2(SCREEN_PIXEL_SIZE.x*0.0), 0.0).r;
float g = texture(TEXTURE, uv_curve(SCREEN_UV) + vec2(SCREEN_PIXEL_SIZE.x*0.5), 0.0).g;
float b = texture(TEXTURE, uv_curve(SCREEN_UV) + vec2(SCREEN_PIXEL_SIZE.x*-0.5), 0.0).b;
//If you dont want scanlines you can just delete this part
float s = sin(uv_curve(SCREEN_UV).y * scanline_count * PI * 2.0);
s = (s * 0.5 + 0.5) * 0.9 + 0.1;
vec4 scan_line = vec4(vec3(pow(s, 0.25)), 1.0);
vec4 text=vec4(r, g, b, 1.0) * scan_line;
vec4 newColor=texture(TEXTURE,UV);
if (newColor.a>0.0){
newColor = text;
}
COLOR=newColor;
}