Advertisement
Zunesha

Shaders com 4 tipos de transições de tela ( Godot 4)

Dec 23rd, 2023
270
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Shaders com 4 tipos de transições de tela ( Godot 4)
  2.  
  3. shader_type canvas_item;
  4.  
  5.     uniform float screen_width = 1920;
  6.     uniform float screen_height = 1080;
  7.     uniform vec2 center = vec2(0.5f);
  8.     uniform vec2 player = vec2(0.5f);
  9.  
  10.     uniform float progress : hint_range(0,1);
  11.     uniform float pixel_size = 15.0;
  12.     uniform float circle_size : hint_range(0,2) = 1.5f;
  13.     uniform float curtains : hint_range(0,1) = 1.0;
  14.  
  15.     uniform int type : hint_range(0,4) = 0;
  16.  
  17.     void fragment() {
  18.         //Tipo Diamante Pixel
  19.         if (type == 0) {
  20.             float xFraction = fract(FRAGCOORD.x / pixel_size);
  21.             float yFraction = fract(FRAGCOORD.y / pixel_size);
  22.            
  23.             float xDistance = abs(xFraction - 0.5);
  24.             float yDistance = abs(yFraction - 0.5);
  25.  
  26.             if (xDistance + yDistance + UV.x + UV.y > progress * 4.0) {
  27.                 discard;
  28.             }
  29.         }
  30.         //Tipo Circulo no player
  31.         else if (type == 1) {
  32.             float ratio = screen_width / screen_height;
  33.             if (distance(player, vec2(mix(player.x, UV.x, ratio), UV.y)) < circle_size * (1.0 - progress)) {
  34.                 COLOR.a = 0.0;
  35.             }
  36.         }
  37.         //Tipo Circulo no Centro
  38.         else if (type == 2) {
  39.             float ratio = screen_width / screen_height;
  40.             if (distance(center, vec2(mix(center.x, UV.x, ratio), UV.y)) < circle_size * (1.0 - progress)) {
  41.                 COLOR.a = 0.0;
  42.             }
  43.         }
  44.         //Tipo Corte Vertical
  45.         else if (type == 3) {
  46.             if (distance(vec2(0.5, 0.5), vec2(UV.x, UV.x)) < curtains * (1.0 - progress)) {
  47.                 COLOR.a = 0.0;
  48.             }
  49.         }
  50.         //Tipo Corte Horizontal
  51.         else if (type == 4) {
  52.             if (distance(vec2(0.5, 0.5), vec2(UV.y, UV.y)) < curtains * (1.0 - progress)) {
  53.                 COLOR.a = 0.0;
  54.             }
  55.         }
  56.     }
  57.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement