Zunesha

Shader Vignette Godot 4 (ColorRect)

Sep 11th, 2024 (edited)
997
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
GDScript 0.60 KB | Gaming | 0 0
  1. Shader Vignette  Godot 4 (ColorRect)
  2.  
  3. shader_type canvas_item;
  4.  
  5. uniform float alpha : hint_range(0.0, 1.0) = 1.0;
  6. uniform float inner_radius : hint_range(0.0, 1.0) = 0.0;
  7. uniform float outer_radius : hint_range(0.0, 1.0) = 1.0;
  8. uniform vec4 vignette_color : source_color = vec4(0.0, 0.0, 0.0, 1.0);
  9.  
  10. void fragment() {
  11.     float x = abs(UV.x - 0.5) * 2.0;
  12.     float y = abs(UV.y - 0.5) * 2.0;
  13.  
  14.     float q = 1.0 - (1.0 - sqrt(x * x + y * y) / outer_radius) / (1.0 - inner_radius);
  15.  
  16.     // Multiplica a cor pelo alpha calculado
  17.     COLOR = vec4(vignette_color.rgb, vignette_color.a * q * alpha);
  18. }
  19.  
Advertisement
Add Comment
Please, Sign In to add comment