poisson_restrict.frag 989 B

12345678910111213141516171819202122232425262728293031323334353637383940
  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 float scale;
  13. layout(binding = 0) uniform sampler2D cons;
  14. layout(location= 0) out vec4 out_constraint;
  15. void main(void) {
  16. mat3 f = mat3(
  17. 0.25, 0.50, 0.25,
  18. 0.50, 1.00, 0.50,
  19. 0.25, 0.50, 0.25);
  20. vec4 constr = vec4(0);
  21. float sum = 0;
  22. ivec2 coord = ivec2(gl_FragCoord.xy*scale);
  23. for (int i=0; i<3; i++) {
  24. for (int j=0; j<3; j++) {
  25. vec4 c = texelFetch(cons,coord+ivec2(i-1,j-1),0);
  26. float a = float(any(greaterThan(c.rgb, vec3(0.01))));
  27. constr += f[i][j] * a * c;
  28. sum += f[i][j] * a;
  29. }
  30. }
  31. out_constraint = constr / sum;
  32. }