poisson_jacobi.frag 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /*
  2. * Copyright (C) 2020, Inria
  3. * GRAPHDECO research group, https://team.inria.fr/graphdeco
  4. * All rights reserved.
  5. *
  6. * This software is free for non-commercial, research and evaluation use
  7. * under the terms of the LICENSE.md file.
  8. *
  9. * For inquiries contact sibr@inria.fr and/or George.Drettakis@inria.fr
  10. */
  11. #version 420
  12. uniform vec4 weights;
  13. uniform float scale;
  14. layout(binding = 0) uniform sampler2D curr_tex;
  15. layout(location= 0) out vec4 out_color;
  16. void main(void) {
  17. ivec2 coord = ivec2(gl_FragCoord.xy*scale);
  18. float w_center = weights.x;
  19. float w_edge = weights.y;
  20. float w_corner = weights.z;
  21. float w_c_x_inv= weights.w;
  22. // Solve the Laplace equation, same as Poisson equation with
  23. // divergence equal to 0
  24. out_color =
  25. -w_c_x_inv * (
  26. (texelFetch(curr_tex, coord, 0) * w_center +
  27. (texelFetch(curr_tex, coord+ivec2( 0, 1), 0) +
  28. texelFetch(curr_tex, coord+ivec2( 0,-1), 0) +
  29. texelFetch(curr_tex, coord+ivec2( 1, 0), 0) +
  30. texelFetch(curr_tex, coord+ivec2(-1, 0), 0)) * w_edge +
  31. (texelFetch(curr_tex, coord+ivec2(-1,-1), 0) +
  32. texelFetch(curr_tex, coord+ivec2(-1, 1), 0) +
  33. texelFetch(curr_tex, coord+ivec2( 1,-1), 0) +
  34. texelFetch(curr_tex, coord+ivec2( 1, 1), 0)) * w_corner
  35. )
  36. );
  37. }