Advertisement
Zunesha

Shader se Desaparecer Godot 4

Sep 17th, 2024 (edited)
315
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
GDScript 1.39 KB | Gaming | 0 0
  1. Shader de Desaparecer Godot 4
  2.  
  3. shader_type canvas_item;
  4.  
  5. uniform float progress : hint_range(0.0, 1.0);
  6. uniform float noise_desnity = 60;
  7. uniform float beam_size : hint_range(0.01, 0.15);
  8. uniform vec4 color : source_color = vec4(0.0, 1.02, 1.2, 1.0);
  9.  
  10. // We are generating our own noise here. You could experiment with the
  11. // built in SimplexNoise or your own noise texture for other effects.
  12. vec2 random(vec2 uv){
  13.     uv = vec2( dot(uv, vec2(127.1,311.7) ),
  14.                dot(uv, vec2(269.5,183.3) ) );
  15.     return -1.0 + 2.0 * fract(sin(uv) * 43758.5453123);
  16. }
  17.  
  18. float noise(vec2 uv) {
  19.     vec2 uv_index = floor(uv);
  20.     vec2 uv_fract = fract(uv);
  21.  
  22.     vec2 blur = smoothstep(0.0, 1.0, uv_fract);
  23.  
  24.     return mix( mix( dot( random(uv_index + vec2(0.0,0.0) ), uv_fract - vec2(0.0,0.0) ),
  25.                      dot( random(uv_index + vec2(1.0,0.0) ), uv_fract - vec2(1.0,0.0) ), blur.x),
  26.                 mix( dot( random(uv_index + vec2(0.0,1.0) ), uv_fract - vec2(0.0,1.0) ),
  27.                      dot( random(uv_index + vec2(1.0,1.0) ), uv_fract - vec2(1.0,1.0) ), blur.x), blur.y) * 0.5 + 0.5;
  28. }
  29.  
  30. void fragment()
  31. {
  32.     vec4 tex = texture(TEXTURE, UV);
  33.    
  34.     float noise = noise(UV * noise_desnity) * UV.y;
  35.    
  36.     float d1 = step(progress, noise);
  37.     float d2 = step(progress - beam_size, noise);
  38.    
  39.     vec3 beam = vec3(d2 - d1) * color.rgb;
  40.    
  41.     tex.rgb += beam;
  42.     tex.a *= d2;
  43.    
  44.     COLOR = tex;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement