shaders folder!

This commit is contained in:
pennyrigate 2023-03-08 01:07:24 -05:00
parent 69c28ced8b
commit f1e7f136f8
30 changed files with 28 additions and 29 deletions

View file

@ -1,28 +0,0 @@
shader_type canvas_item;
uniform vec4 border_color : hint_color = vec4(0.0, 0.0, 0.0, 1.0);
uniform bool border_corners = false;
bool is_border(sampler2D tex, vec2 uv, vec2 pixel_size) {
float check = texture(tex, uv + vec2(pixel_size.x, 0.0)).a;
check += texture(tex, uv + vec2(-pixel_size.x, 0.0)).a;
check += texture(tex, uv + vec2(0.0, pixel_size.y)).a;
check += texture(tex, uv + vec2(0.0, -pixel_size.y)).a;
if (border_corners) {
check += texture(tex, uv + pixel_size).a;
check += texture(tex, uv - pixel_size).a;
check += texture(tex, uv + vec2(pixel_size.x, -pixel_size.y)).a;
check += texture(tex, uv + vec2(-pixel_size.x, pixel_size.y)).a;
}
return check > 0.0;
}
void fragment() {
COLOR = texture(TEXTURE, UV);
if (COLOR.a == 0.0 && is_border(TEXTURE, UV, TEXTURE_PIXEL_SIZE)) {
COLOR = border_color;
}
}

View file

@ -1,44 +0,0 @@
shader_type canvas_item;
/*
MIT License
Copyright (c) 2019 Tomek
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
uniform vec4 color : hint_color;
uniform bool smooth_mode = false;
uniform bool reverse = false;
uniform float opacity : hint_range(0, 1);
void fragment() {
float alpha = texture(TEXTURE, UV).r;
if (reverse) {
alpha = clamp(1.0 - alpha, 0.0, 1.0);
}
if (smooth_mode) {
alpha = mix(0.0, 1.0, clamp(alpha - 1.0 + opacity * 2.0, 0.0, 1.0));
} else {
alpha = clamp(ceil(alpha + opacity * 1.00001 - 1.0), 0.0, 1.0);
}
COLOR = vec4(color.rgb, alpha);
}

View file

@ -1,43 +0,0 @@
shader_type canvas_item;
const float PI = 3.1415926535;
uniform bool enabled = true;
uniform vec2 resolution;
uniform vec2 curvature;
uniform vec2 scanline_opacity;
uniform float brightness;
vec2 curve_uv(vec2 uv) {
uv = uv * 2.0 - 1.0;
vec2 offset = abs(uv.yx) / vec2(curvature.x, curvature.y);
uv = uv + uv * offset * offset;
uv = uv * 0.5 + 0.5;
return uv;
}
vec3 scanline_intensity(float uv, float res, float opacity) {
float intensity = sin((uv * res - 0.25) * PI * 2.0);
intensity = ((0.5 * intensity) + 0.5) * 0.9 + 0.1;
return vec3(pow(intensity, opacity));
}
void fragment() {
if (enabled) {
vec2 curved_uv = UV;
vec3 base_color = texture(TEXTURE, curved_uv).rgb;
base_color += vec3(1.0/256.0);
base_color *= scanline_intensity(curved_uv.x, resolution.x, scanline_opacity.y);
base_color *= scanline_intensity(curved_uv.y, resolution.y, scanline_opacity.x);
base_color *= vec3(brightness);
if (curved_uv.x < 0.0 || curved_uv.y < 0.0 || curved_uv.x > 1.0 || curved_uv.y > 1.0) {
COLOR = vec4(0.0, 0.0, 0.0, 0.0);
} else {
COLOR = vec4(base_color, 1.0);
}
} else {
COLOR = texture(TEXTURE, UV);
}
}

View file

@ -1,14 +0,0 @@
[gd_resource type="Shader" format=2]
[resource]
code = "// Recolor
shader_type canvas_item;
uniform sampler2D palette : hint_albedo;
void fragment() {
vec4 color = texture(TEXTURE, UV);
vec4 result_color = texture(palette, color.rg );
result_color.a = color.a;
COLOR = result_color;
}"

View file

@ -1,32 +0,0 @@
shader_type canvas_item;
uniform sampler2D palette : hint_albedo;
uniform vec4 border_color : hint_color = vec4(0.0, 0.0, 0.0, 1.0);
uniform bool border_corners = false;
bool is_border(sampler2D tex, vec2 uv, vec2 pixel_size) {
float check = texture(tex, uv + vec2(pixel_size.x, 0.0)).a;
check += texture(tex, uv + vec2(-pixel_size.x, 0.0)).a;
check += texture(tex, uv + vec2(0.0, pixel_size.y)).a;
check += texture(tex, uv + vec2(0.0, -pixel_size.y)).a;
if (border_corners) {
check += texture(tex, uv + pixel_size).a;
check += texture(tex, uv - pixel_size).a;
check += texture(tex, uv + vec2(pixel_size.x, -pixel_size.y)).a;
check += texture(tex, uv + vec2(-pixel_size.x, pixel_size.y)).a;
}
return check > 0.0;
}
void fragment() {
vec4 color = texture(TEXTURE, UV);
if (color.a == 0.0 && is_border(TEXTURE, UV, TEXTURE_PIXEL_SIZE)) {
COLOR = border_color;
} else {
COLOR = texture(palette, color.rg );
COLOR.a = color.a;
}
}

View file

@ -1,12 +0,0 @@
shader_type canvas_item;
uniform float offset = 1.5;
uniform float speed = 0.5;
uniform float waves = 2.0;
uniform float color_amount = 0.2;
void fragment() {
vec2 uv = SCREEN_UV;
uv.x += floor(sin(TIME * speed - SCREEN_UV.y * waves) * offset) * SCREEN_PIXEL_SIZE.x;
COLOR = mix(texture(SCREEN_TEXTURE, uv), COLOR, color_amount);
}