Guest User

Godot Panorama Shader

a guest
Aug 22nd, 2024
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. shader_type spatial;
  2. render_mode unshaded, depth_draw_always;
  3.  
  4. uniform sampler2D background: source_color, filter_linear;
  5.  
  6. vec4 getEnvironment(vec3 rayDirection) {
  7.     const float PIm2 = 2.0 * PI;    
  8.     rayDirection = normalize(rayDirection);
  9.     return texture(background, vec2((atan(rayDirection.z, rayDirection.x) / PIm2) - 0.25, acos(-rayDirection.y) / PI));    
  10. }
  11.  
  12. void fragment() {
  13.     vec4 world_view = INV_VIEW_MATRIX * vec4(VIEW, 0);
  14.     vec4 bg_color = getEnvironment(world_view.xyz);
  15.     ALBEDO = bg_color.rgb;
  16.     ALPHA = bg_color.a;
  17. }
  18.  
  19.  
Advertisement
Add Comment
Please, Sign In to add comment