Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Shaders com 4 tipos de transições de tela ( Godot 4)
- shader_type canvas_item;
- // Tamanho da tela em pixels — atualize isso no GDScript sempre!
- uniform vec2 screen_size = vec2(1280.0, 720.0);
- // Posição em PIXELS na tela onde o círculo vai fechar (ex: Vector2(880.0, 368.0))
- uniform vec2 pixel_target = vec2(960.0, 540.0); // padrão = centro de 1920x1080
- uniform vec2 center = vec2(0.5);
- uniform float progress : hint_range(0.0, 1.0) = 0.0;
- uniform float pixel_size : hint_range(1.0, 50.0) = 15.0;
- uniform float circle_size : hint_range(0.0, 3.0) = 1.5;
- uniform float curtains : hint_range(0.0, 1.0) = 1.0;
- uniform int type : hint_range(0, 4) = 0;
- void fragment() {
- // Converte posição em pixels para UV (0-1)
- vec2 target_uv = pixel_target / screen_size;
- // Seleciona o centro dependendo do tipo
- vec2 final_target = (type == 1) ? target_uv : center;
- // Corrige aspect ratio para círculo perfeito
- vec2 uv = UV - final_target;
- uv.x *= screen_size.x / screen_size.y; // escala X pelo aspect ratio
- float dist = length(uv);
- // Tipo 0 - Diamante Pixelado
- if (type == 0) {
- float xFraction = fract(FRAGCOORD.x / pixel_size);
- float yFraction = fract(FRAGCOORD.y / pixel_size);
- float xDistance = abs(xFraction - 0.5);
- float yDistance = abs(yFraction - 0.5);
- if (xDistance + yDistance + UV.x + UV.y > progress * 4.0) {
- discard;
- }
- }
- // Tipo 1 - Círculo fechando no ponto (em pixels → UV)
- else if (type == 1 || type == 2) {
- if (dist < circle_size * (1.0 - progress)) {
- COLOR.a = 0.0;
- }
- }
- // Tipo 3 - Cortina Vertical
- else if (type == 3) {
- if (abs(UV.x - 0.5) < curtains * (1.0 - progress) * 0.5) {
- COLOR.a = 0.0;
- }
- }
- // Tipo 4 - Cortina Horizontal
- else if (type == 4) {
- if (abs(UV.y - 0.5) < curtains * (1.0 - progress) * 0.5) {
- COLOR.a = 0.0;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment