advanced-aa.fs 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #version 150
  2. #define dt vec3(1.0, 1.0, 1.0)
  3. uniform sampler2D source[];
  4. in vec3 c00;
  5. in vec3 c10;
  6. in vec3 c20;
  7. in vec3 c01;
  8. in vec3 c11;
  9. in vec3 c21;
  10. in vec3 c02;
  11. in vec3 c12;
  12. in vec3 c22;
  13. in float d1;
  14. in float d2;
  15. in float hl;
  16. in float vl;
  17. in float k1;
  18. in float k2;
  19. in Vertex {
  20. vec2 texCoord;
  21. vec4 t1;
  22. vec4 t2;
  23. vec4 t3;
  24. vec4 t4;
  25. };
  26. out vec4 fragColor;
  27. void main(void) {
  28. vec3 c00 = texture(source[0], t1.zw).xyz;
  29. vec3 c10 = texture(source[0], t3.xy).xyz;
  30. vec3 c20 = texture(source[0], t3.zw).xyz;
  31. vec3 c01 = texture(source[0], t1.xy).xyz;
  32. vec3 c11 = texture(source[0], texCoord).xyz;
  33. vec3 c21 = texture(source[0], t2.xy).xyz;
  34. vec3 c02 = texture(source[0], t2.zw).xyz;
  35. vec3 c12 = texture(source[0], t4.xy).xyz;
  36. vec3 c22 = texture(source[0], t4.zw).xyz;
  37. float d1=dot(abs(c00 - c22), dt) + 0.0001;
  38. float d2=dot(abs(c20 - c02), dt) + 0.0001;
  39. float hl=dot(abs(c01 - c21), dt) + 0.0001;
  40. float vl=dot(abs(c10 - c12), dt) + 0.0001;
  41. float k1 = 0.5 * (hl + vl);
  42. float k2 = 0.5 * (d1 + d2);
  43. vec3 t1 = (hl * (c10 + c12) + vl * (c01 + c21) + k1 * c11) / (2.5 * (hl + vl));
  44. vec3 t2 = (d1 * (c20 + c02) + d2 * (c00 + c22) + k2 * c11) / (2.5 * (d1 + d2));
  45. k1 = dot(abs(t1 - c11), dt) + 0.0001;
  46. k2 = dot(abs(t2 - c11), dt) + 0.0001;
  47. fragColor = vec4((k1 * t2 + k2 * t1) / (k1 + k2), 1.0);
  48. }