MagicNStuff/game/assets/shaders/hologram.gdshader
SchimmelSpreu83 1269e9a059 Some code cleanup
- Added an event when switching to another input device.
- Added InitialSetupMenu, which shows up when starting the game for the first time.
- Updated entrance hall csg.
- Added DialogBank for easier localization.
- Shaders can now be paused and time scaled.
- Added shading the edges of the beating lightbeam shader.
2026-04-20 19:18:51 +02:00

71 lines
2.3 KiB
Plaintext

shader_type spatial;
render_mode unshaded, cull_disabled, world_vertex_coords;
global uniform float time;
uniform vec4 color : source_color = vec4(0.275, 0.718, 1.0, 0.824);
uniform sampler2D albedo_texture;
uniform float stripe_falloff = 0.75;
uniform float strip1_speed = 0.05;
uniform float strip1_scale = 1.0;
uniform float strip1_fract_scale = 50.0;
uniform float strip2_speed = 0.1;
uniform float strip2_scale = 0.5;
uniform float strip2_fract_scale = 20.0;
group_uniforms tint_edge;
uniform vec4 tint_color : source_color = vec4(1.0, 0.5, 0.0, 0.5); // #FF8000
uniform vec4 edge_color : source_color = vec4(1.0, 0.0, 0.0, 1.0); // #FF0000
uniform float edge_power : hint_range(0.0, 1.0) = 0.5;
uniform float edge_size : hint_range(0.1, 5.0) = 1.0;
uniform float edge_intensity : hint_range(0.0, 2.0) = 0.8;
varying vec3 vertex_world_position;
void vertex() {
// Called for every vertex the material is visible on.
vertex_world_position = (PROJECTION_MATRIX * vec4(VERTEX, 1.0)).xyz;
}
void fragment() {
// Called for every pixel the material is visible on.
vec2 canvas = UV;//vec2(VIEW.x, VIEW.y);
canvas = vertex_world_position.xy;
//vec3 normal = normalize(NORMAL);
//canvas += normal.xz * 0.1;
vec2 uv = canvas * strip1_scale;
uv.y += time * strip1_speed;
vec2 uv2 = canvas * strip2_scale;
uv2.y += time * strip2_speed;
//vec2 uv3 = UV * 0.25;
//uv3.y += time * 0.035;
vec4 albedo = texture(albedo_texture, UV);
ALBEDO = mix(color.rgb, albedo.rgb, 0.5);
float strip1 = fract(uv.y * strip1_fract_scale);
float strip2 = fract(uv2.y * strip2_fract_scale);
//float strip3 = fract(uv3.y * 20.0);
float stripe = smoothstep(0.0, 1.0, mix(strip1, strip2, 0.5));
//stripe = 1.0 - smoothstep(0.0, stripe, (1.0 - UV.y) * stripe_falloff);
stripe = 1.0 - smoothstep(0.0, stripe, (1.0 - SCREEN_UV.y) * stripe_falloff);
float edge = 1.0 - dot(NORMAL, VIEW);
edge = pow(edge, mix(8.0, 2.0, edge_power));
edge = smoothstep(0.5 - edge_size * 0.1, 0.5 + edge_size * 0.1, edge);
vec4 edge_effect = edge * edge_intensity * edge_color * max(UV.y, 0.0);
//
ALPHA = min(color.a, max(max(edge_effect.a, stripe), 0.0)) * albedo.a;
//ALPHA = min(color.a, max(stripe, 0.0)) * albedo.a;
}
//void light() {
// // Called for every pixel for every light affecting the material.
// // Uncomment to replace the default light processing function with this one.
//}