Initial reorganization of shmup prroject; temp player sprites added.
This commit is contained in:
parent
02d14e913c
commit
accc463791
116 changed files with 298 additions and 177 deletions
175
shaders/crt.gdshader
Normal file
175
shaders/crt.gdshader
Normal file
|
|
@ -0,0 +1,175 @@
|
|||
shader_type canvas_item;
|
||||
|
||||
// Add required screen texture uniform
|
||||
uniform sampler2D SCREEN_TEXTURE : hint_screen_texture, filter_linear_mipmap;
|
||||
|
||||
// Display settings
|
||||
uniform bool overlay = false;
|
||||
uniform vec2 resolution = vec2(640.0, 480.0);
|
||||
uniform float brightness = 1.4;
|
||||
|
||||
// Scanline settings
|
||||
uniform float scanlines_opacity : hint_range(0.0, 1.0) = 0.4;
|
||||
uniform float scanlines_width : hint_range(0.0, 0.5) = 0.25;
|
||||
uniform float grille_opacity : hint_range(0.0, 1.0) = 0.3;
|
||||
|
||||
// Distortion settings
|
||||
uniform bool roll = true;
|
||||
uniform float roll_speed = 8.0;
|
||||
uniform float roll_size : hint_range(0.0, 100.0) = 15.0;
|
||||
uniform float roll_variation : hint_range(0.1, 5.0) = 1.8;
|
||||
uniform float distort_intensity : hint_range(0.0, 0.2) = 0.05;
|
||||
uniform float aberration : hint_range(-1.0, 1.0) = 0.03;
|
||||
|
||||
// Noise settings
|
||||
uniform float noise_opacity : hint_range(0.0, 1.0) = 0.4;
|
||||
uniform float noise_speed = 5.0;
|
||||
uniform float static_noise_intensity : hint_range(0.0, 1.0) = 0.06;
|
||||
|
||||
// Additional effects
|
||||
uniform bool pixelate = true;
|
||||
uniform bool discolor = true;
|
||||
uniform float warp_amount : hint_range(0.0, 5.0) = 1.0;
|
||||
uniform bool clip_warp = false;
|
||||
uniform float vignette_intensity = 0.4;
|
||||
uniform float vignette_opacity : hint_range(0.0, 1.0) = 0.5;
|
||||
|
||||
// The rest of the shader code remains exactly the same from here...
|
||||
// (All the functions and fragment shader code remain unchanged)
|
||||
|
||||
// Generate random value
|
||||
vec2 random(vec2 uv) {
|
||||
uv = vec2(dot(uv, vec2(127.1, 311.7)), dot(uv, vec2(269.5, 183.3)));
|
||||
return -1.0 + 2.0 * fract(sin(uv) * 43758.5453123);
|
||||
}
|
||||
|
||||
// Generate noise
|
||||
float noise(vec2 uv) {
|
||||
vec2 uv_index = floor(uv);
|
||||
vec2 uv_fract = fract(uv);
|
||||
vec2 blur = smoothstep(0.0, 1.0, uv_fract);
|
||||
|
||||
return mix(
|
||||
mix(
|
||||
dot(random(uv_index + vec2(0.0, 0.0)), uv_fract - vec2(0.0, 0.0)),
|
||||
dot(random(uv_index + vec2(1.0, 0.0)), uv_fract - vec2(1.0, 0.0)),
|
||||
blur.x
|
||||
),
|
||||
mix(
|
||||
dot(random(uv_index + vec2(0.0, 1.0)), uv_fract - vec2(0.0, 1.0)),
|
||||
dot(random(uv_index + vec2(1.0, 1.0)), uv_fract - vec2(1.0, 1.0)),
|
||||
blur.x
|
||||
),
|
||||
blur.y
|
||||
) * 0.5 + 0.5;
|
||||
}
|
||||
|
||||
// Screen warping
|
||||
vec2 warp(vec2 uv) {
|
||||
vec2 delta = uv - 0.5;
|
||||
float delta2 = dot(delta.xy, delta.xy);
|
||||
float delta4 = delta2 * delta2;
|
||||
return uv + delta * (delta4 * warp_amount);
|
||||
}
|
||||
|
||||
// Screen border
|
||||
float border(vec2 uv) {
|
||||
float radius = min(warp_amount, 0.08);
|
||||
radius = max(min(min(abs(radius * 2.0), abs(1.0)), abs(1.0)), 1e-5);
|
||||
vec2 abs_uv = abs(uv * 2.0 - 1.0) - vec2(1.0, 1.0) + radius;
|
||||
float dist = length(max(vec2(0.0), abs_uv)) / radius;
|
||||
return clamp(1.0 - smoothstep(0.96, 1.0, dist), 0.0, 1.0);
|
||||
}
|
||||
|
||||
// Vignette effect
|
||||
float vignette(vec2 uv) {
|
||||
uv *= 1.0 - uv.xy;
|
||||
float vig = uv.x * uv.y * 15.0;
|
||||
return pow(vig, vignette_intensity * vignette_opacity);
|
||||
}
|
||||
|
||||
void fragment() {
|
||||
// Get base UV and handle overlay
|
||||
vec2 uv = overlay ? warp(SCREEN_UV) : warp(UV);
|
||||
vec2 text_uv = uv;
|
||||
|
||||
// Handle pixelation
|
||||
if (pixelate) {
|
||||
text_uv = ceil(uv * resolution) / resolution;
|
||||
}
|
||||
|
||||
// Calculate roll effect
|
||||
float roll_line = 0.0;
|
||||
vec2 roll_uv = vec2(0.0);
|
||||
|
||||
if (roll || noise_opacity > 0.0) {
|
||||
float time = roll ? TIME : 0.0;
|
||||
roll_line = smoothstep(0.3, 0.9, sin(uv.y * roll_size - (time * roll_speed)));
|
||||
roll_line *= roll_line * smoothstep(0.3, 0.9, sin(uv.y * roll_size * roll_variation - (time * roll_speed * roll_variation)));
|
||||
roll_uv = vec2(roll_line * distort_intensity * (1.0 - UV.x), 0.0);
|
||||
}
|
||||
|
||||
// Sample texture with chromatic aberration
|
||||
vec4 text;
|
||||
if (roll) {
|
||||
text.r = texture(SCREEN_TEXTURE, text_uv + roll_uv * 0.8 + vec2(aberration, 0.0) * 0.1).r;
|
||||
text.g = texture(SCREEN_TEXTURE, text_uv + roll_uv * 1.2 - vec2(aberration, 0.0) * 0.1).g;
|
||||
text.b = texture(SCREEN_TEXTURE, text_uv + roll_uv).b;
|
||||
} else {
|
||||
text.r = texture(SCREEN_TEXTURE, text_uv + vec2(aberration, 0.0) * 0.1).r;
|
||||
text.g = texture(SCREEN_TEXTURE, text_uv - vec2(aberration, 0.0) * 0.1).g;
|
||||
text.b = texture(SCREEN_TEXTURE, text_uv).b;
|
||||
}
|
||||
text.a = 1.0;
|
||||
|
||||
// Apply CRT grille
|
||||
if (grille_opacity > 0.0) {
|
||||
float gr = smoothstep(0.85, 0.95, abs(sin(uv.x * (resolution.x * 3.14159265))));
|
||||
float gg = smoothstep(0.85, 0.95, abs(sin(1.05 + uv.x * (resolution.x * 3.14159265))));
|
||||
float gb = smoothstep(0.85, 0.95, abs(sin(2.1 + uv.x * (resolution.x * 3.14159265))));
|
||||
|
||||
text.r = mix(text.r, text.r * gr, grille_opacity);
|
||||
text.g = mix(text.g, text.g * gg, grille_opacity);
|
||||
text.b = mix(text.b, text.b * gb, grille_opacity);
|
||||
}
|
||||
|
||||
// Apply brightness
|
||||
text.rgb = clamp(text.rgb * brightness, 0.0, 1.0);
|
||||
|
||||
// Apply scanlines
|
||||
if (scanlines_opacity > 0.0) {
|
||||
float scan = smoothstep(scanlines_width, scanlines_width + 0.5, abs(sin(uv.y * (resolution.y * 3.14159265))));
|
||||
text.rgb = mix(text.rgb, text.rgb * vec3(scan), scanlines_opacity);
|
||||
}
|
||||
|
||||
// Apply noise
|
||||
if (noise_opacity > 0.0) {
|
||||
float n = smoothstep(0.4, 0.5, noise(uv * vec2(2.0, 200.0) + vec2(10.0, TIME * noise_speed)));
|
||||
float nl = n * roll_line * clamp(random((ceil(uv * resolution) / resolution) + vec2(TIME * 0.8, 0.0)).x + 0.8, 0.0, 1.0);
|
||||
text.rgb = clamp(mix(text.rgb, text.rgb + nl, noise_opacity), vec3(0.0), vec3(1.0));
|
||||
}
|
||||
|
||||
// Apply static
|
||||
if (static_noise_intensity > 0.0) {
|
||||
text.rgb += clamp(random((ceil(uv * resolution) / resolution) + fract(TIME)).x, 0.0, 1.0) * static_noise_intensity;
|
||||
}
|
||||
|
||||
// Apply border and vignette
|
||||
text.rgb *= border(uv);
|
||||
text.rgb *= vignette(uv);
|
||||
|
||||
// Handle clip warp
|
||||
if (clip_warp) {
|
||||
text.a = border(uv);
|
||||
}
|
||||
|
||||
// Apply VHS discoloration
|
||||
if (discolor) {
|
||||
vec3 greyscale = vec3(dot(text.rgb, vec3(0.333)));
|
||||
text.rgb = mix(text.rgb, greyscale, 0.5);
|
||||
float midpoint = pow(0.5, 2.2);
|
||||
text.rgb = (text.rgb - vec3(midpoint)) * 1.2 + midpoint;
|
||||
}
|
||||
|
||||
COLOR = text;
|
||||
}
|
||||
1
shaders/crt.gdshader.uid
Normal file
1
shaders/crt.gdshader.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://c4jtlpwspb778
|
||||
51
shaders/pixel_highlight.gdshader
Normal file
51
shaders/pixel_highlight.gdshader
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
shader_type canvas_item;
|
||||
|
||||
uniform float speed : hint_range(0.0, 5.0) = 1.0;
|
||||
uniform float line_width : hint_range(0.0, 0.2) = 0.15;
|
||||
uniform vec4 line_color : source_color = vec4(1.0, 1.0, 1.0, 1.0);
|
||||
uniform float pause_duration : hint_range(0.0, 6.0) = 0.15;
|
||||
uniform float offset = 2.0;
|
||||
uniform int pixelate_line : hint_range(0, 1) = 1;
|
||||
|
||||
void fragment() {
|
||||
vec4 base_texture = texture(TEXTURE, UV);
|
||||
|
||||
// Skip fully transparent pixels
|
||||
if (base_texture.a < 0.01) {
|
||||
discard;
|
||||
}
|
||||
|
||||
// Cycle timing with pause at end
|
||||
float cycle_duration = offset + pause_duration;
|
||||
float adjusted_time = mod(TIME * speed, cycle_duration);
|
||||
|
||||
// Line movement with pause (right to left)
|
||||
float line_position;
|
||||
if (adjusted_time <= offset) {
|
||||
line_position = offset - adjusted_time;
|
||||
} else {
|
||||
line_position = -0.3;
|
||||
}
|
||||
|
||||
// Use UV directly for diagonal calculation
|
||||
vec2 uv_for_line = UV;
|
||||
|
||||
// Pixelate the line position calculation (not the texture sampling)
|
||||
if (pixelate_line == 1) {
|
||||
vec2 texture_size = 1.0 / TEXTURE_PIXEL_SIZE;
|
||||
uv_for_line = floor(UV * texture_size) / texture_size;
|
||||
}
|
||||
|
||||
// Diagonal line rotation
|
||||
vec2 rotated_uv = vec2(uv_for_line.x + uv_for_line.y, uv_for_line.y - uv_for_line.x) * 0.5;
|
||||
float dist = abs(rotated_uv.x - line_position);
|
||||
|
||||
// Line width and smoothness
|
||||
float line_intensity = smoothstep(line_width, 0.0, dist);
|
||||
|
||||
// Mix base texture with line color (respecting line_color alpha)
|
||||
vec3 final_color = mix(base_texture.rgb, line_color.rgb, line_intensity * line_color.a);
|
||||
|
||||
// Preserve original alpha
|
||||
COLOR = vec4(final_color, base_texture.a);
|
||||
}
|
||||
1
shaders/pixel_highlight.gdshader.uid
Normal file
1
shaders/pixel_highlight.gdshader.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://x02irwg8ynvp
|
||||
17
shaders/player_hit.gdshader
Normal file
17
shaders/player_hit.gdshader
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
shader_type canvas_item;
|
||||
|
||||
uniform float toggle;
|
||||
|
||||
void vertex() {
|
||||
// Called for every vertex the material is visible on.
|
||||
}
|
||||
|
||||
void fragment() {
|
||||
COLOR = texture(TEXTURE, UV);
|
||||
COLOR.r = mix(COLOR.r, abs(sin(TIME * 20.25)), toggle);
|
||||
}
|
||||
|
||||
//void light() {
|
||||
// // Called for every pixel for every light affecting the CanvasItem.
|
||||
// // Uncomment to replace the default light processing function with this one.
|
||||
//}
|
||||
1
shaders/player_hit.gdshader.uid
Normal file
1
shaders/player_hit.gdshader.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://dfywtah53il1m
|
||||
110
shaders/starfield.gdshader
Normal file
110
shaders/starfield.gdshader
Normal file
|
|
@ -0,0 +1,110 @@
|
|||
// Starfield shader v5 by Brian Smith (steampunkdemon.itch.io)
|
||||
// MIT licence
|
||||
|
||||
shader_type canvas_item;
|
||||
|
||||
// Comment out the following line if you are not applying the shader to a ColorRect:
|
||||
uniform vec2 dimensions = vec2(1024.0, 600.0); // Resolution of ColorRect in pixels
|
||||
|
||||
uniform float small_stars = 50.0; // Number of small stars. Rows for horizontally scrolling stars or columns for vertically scrolling stars.
|
||||
uniform float small_stars_far_size : hint_range(0.1, 1.0, 0.1) = 0.5;
|
||||
uniform float small_stars_near_size : hint_range(0.1, 1.0, 0.1) = 1.0;
|
||||
uniform float large_stars = 8.0; // Number of large stars. Rows for horizontally scrolling stars or columns for vertically scrolling stars.
|
||||
uniform float large_stars_far_size : hint_range(0.1, 1.0, 0.1) = 0.5;
|
||||
uniform float large_stars_near_size : hint_range(0.1, 1.0, 0.1) = 1.0;
|
||||
|
||||
// Replace the below references to 'source_color' with 'hint_color' if you are using a version of Godot before 4.
|
||||
uniform vec4 far_stars_color : source_color = vec4(0.50, 0.0, 1.0, 1.0);
|
||||
uniform vec4 near_stars_color : source_color = vec4(1.0, 1.0, 1.0, 1.0);
|
||||
|
||||
// Remove the below references to ': source_color, filter_nearest_mipmap' if you are using a version of Godot before 4.
|
||||
uniform sampler2D small_stars_texture : source_color, filter_nearest_mipmap;
|
||||
uniform sampler2D large_stars_texture : source_color, filter_nearest_mipmap;
|
||||
|
||||
uniform float base_scroll_speed : hint_range(0.0, 1.0, 0.01) = 0.05;
|
||||
uniform float additional_scroll_speed : hint_range(0.01, 1.0, 0.01) = 0.05;
|
||||
|
||||
float greater_than(float x, float y) {
|
||||
return max(sign(x - y), 0.0);
|
||||
}
|
||||
|
||||
void fragment() {
|
||||
// The below line will scroll the stars from right to left or from bottom to top.
|
||||
// To make the stars scroll in the opposite direction change the line to:
|
||||
// float time = 10000.0 - TIME;
|
||||
// Alternatively you can comment out the below line and add a new uniform above as:
|
||||
// uniform float time = 10000.0;
|
||||
// You can then update the time uniform from your _physics_process function by adding or subtracting delta. You can also pause the scrolling by not changing the time uniform.
|
||||
float time = 10000.0 + TIME;
|
||||
|
||||
// Comment out the following two lines if you are not applying the shader to a TextureRect:
|
||||
// COLOR = texture(TEXTURE,UV); // This line is only required if you are using a version of Godot before 4.
|
||||
// vec2 dimensions = 1.0 / TEXTURE_PIXEL_SIZE;
|
||||
|
||||
// Horizontal scrolling:
|
||||
float small_star_rn = fract(sin(floor(UV.y * small_stars)) * dimensions.y);
|
||||
float large_star_rn = fract(sin(floor(UV.y * large_stars)) * dimensions.y);
|
||||
vec2 small_star_uv = vec2(fract(UV.x + (base_scroll_speed + small_star_rn * additional_scroll_speed) * time) * small_stars * dimensions.x / dimensions.y, fract(UV.y * small_stars)) * 2.0 - 1.0;
|
||||
vec2 large_star_uv = vec2(fract(UV.x + (base_scroll_speed + large_star_rn * additional_scroll_speed) * time) * large_stars * dimensions.x / dimensions.y, fract(UV.y * large_stars)) * 2.0 - 1.0;
|
||||
|
||||
// Vertical scrolling:
|
||||
// float small_stars_rn = fract(sin(floor(UV.x * small_stars)) * dimensions.x);
|
||||
// float large_stars_rn = fract(sin(floor(UV.x * large_stars)) * dimensions.x);
|
||||
// vec2 small_stars_uv = vec2(fract(UV.x * small_stars), fract(UV.y + (base_scroll_speed + small_stars_rn * additional_scroll_speed) * time) * small_stars * dimensions.y / dimensions.x) * 2.0 - 1.0;
|
||||
// vec2 large_stars_uv = vec2(fract(UV.x * large_stars), fract(UV.y + (base_scroll_speed + large_stars_rn * additional_scroll_speed) * time) * large_stars * dimensions.y / dimensions.x) * 2.0 - 1.0;
|
||||
|
||||
vec4 star_color = mix(far_stars_color, near_stars_color, small_star_rn);
|
||||
float star_size = small_stars_far_size + (small_stars_near_size - small_stars_far_size) * small_star_rn;
|
||||
|
||||
// Render small stars as circles with soft edges:
|
||||
COLOR.rgb = mix(COLOR.rgb, star_color.rgb, max((star_size - length(small_star_uv)) / star_size, 0.0) * star_color.a);
|
||||
|
||||
// Render small stars as circles with hard edges:
|
||||
// COLOR.rgb = mix(COLOR.rgb, star_color.rgb, greater_than(star_size, length(small_star_uv)) * star_color.a);
|
||||
|
||||
// Render small stars as crosses with soft edges:
|
||||
// COLOR.rgb = mix(COLOR.rgb, star_color.rgb, max((star_size - length(small_star_uv)) / star_size, 0.0) * (max(greater_than(star_size / 10.0, abs(small_star_uv.x)), greater_than(star_size / 10.0, abs(small_star_uv.y)))) * star_color.a);
|
||||
|
||||
// Render small stars as crosses with hard edges:
|
||||
// COLOR.rgb = mix(COLOR.rgb, star_color.rgb, max(greater_than(star_size / 5.0, abs(small_star_uv.x)) * greater_than(star_size, abs(small_star_uv.y)), greater_than(star_size / 5.0, abs(small_star_uv.y)) * greater_than(star_size, abs(small_star_uv.x))) * star_color.a);
|
||||
|
||||
// Render small stars as squares:
|
||||
// COLOR.rgb = mix(COLOR.rgb, star_color.rgb, greater_than(star_size, abs(small_star_uv.x)) * greater_than(star_size, abs(small_star_uv.y)) * star_color.a);
|
||||
|
||||
// Render small stars as diamonds:
|
||||
// COLOR.rgb = mix(COLOR.rgb, star_color.rgb, greater_than(star_size, abs(small_star_uv.y) + abs(small_star_uv.x)) * star_color.a);
|
||||
|
||||
// Render small stars using the 'small_stars_texture':
|
||||
// The 'small_stars_texture' must have a border of blank transparent pixels.
|
||||
// vec4 small_stars_texture_pixel = texture(small_stars_texture, (small_star_uv / (small_stars_far_size + (small_stars_near_size - small_stars_far_size) * small_star_rn) + 1.0) / 2.0) * mix(far_stars_color, near_stars_color, small_star_rn);
|
||||
// COLOR.rgb = mix(COLOR.rgb, small_stars_texture_pixel.rgb, small_stars_texture_pixel.a);
|
||||
|
||||
star_color = mix(far_stars_color, near_stars_color, large_star_rn);
|
||||
star_size = large_stars_far_size + (large_stars_near_size - large_stars_far_size) * large_star_rn;
|
||||
|
||||
// Render large stars as circles with soft edges:
|
||||
// COLOR.rgb = mix(COLOR.rgb, star_color.rgb, max((star_size - length(large_star_uv)) / star_size, 0.0) * star_color.a);
|
||||
|
||||
// Render large stars with circles and crosses with smooth edges:
|
||||
COLOR.rgb = mix(COLOR.rgb, star_color.rgb, (max((star_size / 1.7 - length(large_star_uv)) / star_size, 0.0) + max((star_size - length(large_star_uv)) / star_size / 2.0, 0.0) * (max(greater_than(star_size / 10.0, abs(large_star_uv.x)), greater_than(star_size / 10.0, abs(large_star_uv.y))))) * star_color.a);
|
||||
|
||||
// Render large stars as circles with hard edges:
|
||||
// COLOR.rgb = mix(COLOR.rgb, star_color.rgb, greater_than(star_size, length(large_star_uv)) * star_color.a);
|
||||
|
||||
// Render large stars as crosses with soft edges:
|
||||
// COLOR.rgb = mix(COLOR.rgb, star_color.rgb, max((star_size - length(large_star_uv)) / star_size, 0.0) * (max(greater_than(star_size / 10.0, abs(large_star_uv.x)), greater_than(star_size / 10.0, abs(large_star_uv.y)))) * star_color.a);
|
||||
|
||||
// Render large stars as crosses with hard edges:
|
||||
// COLOR.rgb = mix(COLOR.rgb, star_color.rgb, max(greater_than(star_size / 5.0, abs(large_star_uv.x)) * greater_than(star_size, abs(large_star_uv.y)), greater_than(star_size / 5.0, abs(large_star_uv.y)) * greater_than(star_size, abs(large_star_uv.x))) * star_color.a);
|
||||
|
||||
// Render large stars as squares:
|
||||
// COLOR.rgb = mix(COLOR.rgb, star_color.rgb, greater_than(star_size, abs(large_star_uv.x)) * greater_than(star_size, abs(large_star_uv.y)) * star_color.a);
|
||||
|
||||
// Render large stars as diamonds:
|
||||
// COLOR.rgb = mix(COLOR.rgb, star_color.rgb, greater_than(star_size, abs(large_star_uv.y) + abs(large_star_uv.x)) * star_color.a);
|
||||
|
||||
// Render large stars using the 'large_stars_texture':
|
||||
// The 'large_stars_texture' must have a border of blank transparent pixels.
|
||||
// vec4 large_stars_texture_pixel = texture(large_stars_texture, (large_star_uv / (large_stars_far_size + (large_stars_near_size - large_stars_far_size) * large_star_rn) + 1.0) / 2.0) * mix(far_stars_color, near_stars_color, large_star_rn);
|
||||
// COLOR.rgb = mix(COLOR.rgb, large_stars_texture_pixel.rgb, large_stars_texture_pixel.a);
|
||||
}
|
||||
1
shaders/starfield.gdshader.uid
Normal file
1
shaders/starfield.gdshader.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://bs8uhiq3os0o6
|
||||
Loading…
Add table
Add a link
Reference in a new issue