Game files
This commit is contained in:
54
Shaders/perspective.gdshader
Normal file
54
Shaders/perspective.gdshader
Normal file
@@ -0,0 +1,54 @@
|
||||
shader_type canvas_item;
|
||||
|
||||
/**
|
||||
* In relative units now (0-1)
|
||||
*/
|
||||
uniform float zoom = 1.0;
|
||||
|
||||
/**
|
||||
* Higher values = less distortion in the center
|
||||
*/
|
||||
uniform float sharpness = 2.0;
|
||||
|
||||
/**
|
||||
* (1, 0) for horizontal only, (0, 1) for vertical only
|
||||
*/
|
||||
uniform vec2 direction = vec2(1.0, 0.0);
|
||||
|
||||
/**
|
||||
* 0: Repeats
|
||||
* 1: Clamps
|
||||
* 2: Clips
|
||||
*/
|
||||
uniform int wrapping_mode = 0;
|
||||
|
||||
uniform sampler2D SCREEN_TEXTURE : hint_screen_texture, filter_linear_mipmap;
|
||||
|
||||
void fragment() {
|
||||
float fB;
|
||||
float fC;
|
||||
|
||||
vec2 posTex;
|
||||
vec4 color = vec4(0.0, 0.0, 0.0, 1.0);
|
||||
vec2 uv = SCREEN_UV;
|
||||
vec2 ndir = normalize(direction);
|
||||
float fac1 = abs(dot(uv - 0.5, normalize(ndir.yx))) * 2.0;
|
||||
float fac2 = -dot(uv - 0.5, normalize(ndir)) * 2.0;
|
||||
vec2 new_uv = uv + pow(fac1, sharpness) * fac2 * zoom * ndir;
|
||||
switch (wrapping_mode)
|
||||
{
|
||||
case 2:
|
||||
if (0.0 > new_uv.x || new_uv.x > 1.0 || 0.0 > new_uv.y || new_uv.y > 1.0)
|
||||
{
|
||||
COLOR = vec4(0);
|
||||
break;
|
||||
}
|
||||
case 0:
|
||||
new_uv = fract(new_uv);
|
||||
// fall-through
|
||||
case 1:
|
||||
new_uv = clamp(new_uv, vec2(0), vec2(1));
|
||||
COLOR = textureLod(SCREEN_TEXTURE, new_uv, 0.0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
1
Shaders/perspective.gdshader.uid
Normal file
1
Shaders/perspective.gdshader.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://sxb00aj6wt0h
|
||||
21
Shaders/static_blocky.gdshader
Normal file
21
Shaders/static_blocky.gdshader
Normal file
@@ -0,0 +1,21 @@
|
||||
shader_type canvas_item;
|
||||
|
||||
// Parameters
|
||||
uniform float alpha_threshold : hint_range(0.0, 1.0) = 0.1; // below this = fully transparent
|
||||
uniform float alpha_modifier : hint_range(0.0, 1.0) = 1.0; // global alpha multiplier
|
||||
|
||||
void fragment() {
|
||||
// Sample the current frame automatically
|
||||
vec4 tex_color = texture(TEXTURE, UV);
|
||||
|
||||
// Convert color to luminance (grayscale)
|
||||
float lum = dot(tex_color.rgb, vec3(0.299, 0.587, 0.114));
|
||||
|
||||
// Apply threshold: if below threshold, alpha = 0
|
||||
float alpha = lum < alpha_threshold ? 0.0 : lum;
|
||||
|
||||
// Apply global modifier
|
||||
alpha *= alpha_modifier;
|
||||
|
||||
COLOR = vec4(tex_color.rgb, alpha);
|
||||
}
|
||||
1
Shaders/static_blocky.gdshader.uid
Normal file
1
Shaders/static_blocky.gdshader.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://cb1jf4frbw7jo
|
||||
Reference in New Issue
Block a user