TowerGame/shaders/hologram.gdshader

41 lines
998 B
Plaintext

shader_type spatial;
render_mode blend_mix, depth_prepass_alpha, cull_disabled; // blend_add
uniform vec4 albedo_color : source_color;
group_uniforms warp;
uniform bool enable_warp = false;
uniform vec3 warp_vector = vec3(1.0, 1.0, 1.0);
uniform float warp_strength : hint_range(0.0, 1.0) = 0.5;
uniform float warp_rate : hint_range(0.0, 200.0) = 0.5;
instance uniform float built_amount = 2.0;
varying float model_y;
// Called for every vertex the material is visible on.
void vertex() {
model_y = VERTEX.y;
if (enable_warp && VERTEX.y > built_amount) {
float offset = sin(pow(VERTEX.y, 2) * warp_rate * TIME) * pow(warp_strength, 2);
VERTEX += offset * warp_vector;
}
}
// Called for every pixel the material is visible on.
void fragment() {
float base_opacity = 0.2;
if (model_y > built_amount) {
ALPHA = base_opacity;
} else {
ALPHA = 1.0;
}
ALBEDO.rgb = albedo_color.rgb;
}
// Called for every pixel for every light affecting the material.
//void light() {
//}