hq.frag 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. uniform sampler2D edgeTex;
  2. uniform sampler2D colorTex;
  3. uniform sampler2D offsetTex;
  4. uniform sampler2D weightTex;
  5. uniform sampler2D videoTex;
  6. in vec2 mid;
  7. in vec2 leftTop;
  8. in vec2 edgePos;
  9. in vec2 weightPos;
  10. in vec2 texStep2; // could be uniform
  11. in vec2 videoCoord;
  12. out vec4 fragColor;
  13. void main()
  14. {
  15. float edgeBits = texture(edgeTex, edgePos).z;
  16. //fragColor = vec4(edgeBits, fract(edgeBits * 16.0), fract(edgeBits * 256.0), 1.0);
  17. // transform (N x N x 4096) to (64N x 64N) texture coords
  18. float t = 64.0 * edgeBits;
  19. vec2 xy = vec2(fract(t), floor(t)/64.0);
  20. xy += fract(weightPos) / 64.0;
  21. vec4 offsets = texture(offsetTex, xy);
  22. vec3 weights = texture(weightTex, xy).xyz;
  23. vec4 c5 = texture(colorTex, mid);
  24. vec4 cx = texture(colorTex, leftTop + texStep2 * offsets.xy);
  25. vec4 cy = texture(colorTex, leftTop + texStep2 * offsets.zw);
  26. vec4 col = cx * weights.x + cy * weights.y + c5 * weights.z;
  27. #if SUPERIMPOSE
  28. vec4 vid = texture(videoTex, videoCoord);
  29. fragColor = mix(vid, col, col.a);
  30. #else
  31. fragColor = col;
  32. #endif
  33. }