frame-of-mind/src/base-environments/transition/shaders/escalator_disp.gdshader

51 lines
2.0 KiB
Plaintext
Raw Normal View History

2025-05-21 17:41:00 +00:00
shader_type spatial;
render_mode depth_prepass_alpha;
uniform sampler2D albedo_texture;
uniform sampler2D normal_map;
uniform float transition_point = 0.1;
uniform float transition_length = 0.1;
uniform float target_length = 6.0;
uniform float target_height = 3.0;
float map_normalized(float value, float from_min, float to_max) {
return clamp((value - from_min) / (to_max-from_min), 0.0, 1.0);
}
void vertex() {
if (UV2.y < 1.0) {
float cycle = 1.0-fract(TIME/15.0+UV2.y*1.01);
float p1 = transition_point;
float p2 = transition_point + transition_length;
float p3 = 1.0-transition_point - transition_length;
float p4 = 1.0-transition_point;
float d1 = p3-p2;
float d2 = 1.0 - transition_point * 2.0 - transition_length;
float dt = transition_length * 0.5;
float steepness = (target_height/target_length)/(d2);
//vec3 sloped_movement = vec3(0.0, -cos(steepness*PI), sin(steepness*PI)) * (target_height / steepness);
vec3 sloped_movement = vec3(0.0, target_height/d2, target_length);
VERTEX -= vec3(0, 0, .8);
//VERTEX -= vec3(0.0, 0.0, 7.0) * (1.0-UV2.y);
//VERTEX += sloped_movement * ((1.0-cos(map_normalized(cycle, 0.2, 0.3)*PI/2.0))/PI*.2+ clamp(cycle-0.3, 0.0, 0.4)+ sin(map_normalized(cycle, 0.7, 0.8)*PI/2.0)/PI*.2);
VERTEX += sloped_movement * ((1.0-cos(map_normalized(cycle, p1, p2)*PI/2.0))*dt + clamp(cycle-p2, 0.0, d1) + sin(map_normalized(cycle, p3, p4)*PI/2.0)*dt);
VERTEX += vec3(0.0, 0.0, target_length / d2) * (clamp(cycle, 0.0, p2) + cos(map_normalized(cycle, p1, p2)*PI/2.0)*dt + (1.0-cos(map_normalized(cycle, p3, p4)*PI/2.0))*dt + clamp(cycle-p4, 0.0, p1));
}
}
void fragment() {
METALLIC = 0.9;
ALBEDO = texture(albedo_texture, UV).xyz * 1.5;
ROUGHNESS = texture(albedo_texture, UV).x*.7;
NORMAL_MAP = texture(normal_map, UV).xyz;
ALPHA = texture(albedo_texture, UV).w;
}
//void light() {
// // Called for every pixel for every light affecting the material.
// // Uncomment to replace the default light processing function with this one.
//}