Advertisement
Guest User

Untitled

a guest
Nov 27th, 2020
19
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. fixed4 frag(v2f i) : SV_Target
  2. {
  3.  
  4. const int m = 5;
  5. float z[m], zed;
  6. float xs = 1/ 1024.0;
  7. float ys = 1 / 720.0;
  8. float r = _blurRadius;
  9. float2 pos = i.vertex;
  10. float2 p = 0.5 * (i.vertex + 1.0);
  11. z[0] = tex2D(_MainTex, i.uv).r;; // oldest 2 frames
  12. z[1] = tex2D(_HistoryA, i.uv).r;
  13. if (abs(z[0] - z[1]) > _dataDelta) // threshold depth change
  14. {
  15. int index;
  16. float x, y, xx, yy, rr, dx, dy, w, w0;
  17.  
  18. // 2D spatial gauss blur of z0
  19. rr = r * r;
  20. w0 = 0.3780 / pow(r, 1.975);
  21. z[0] = 0.0;
  22. for (dx = _MainTex_TexelSize.x, x = -r, p.x = 0.5 + (pos.x * 0.5) + (x * dx); x <= r; x++, p.x += dx) {
  23. xx = x * x;
  24. for (dy = _MainTex_TexelSize.y, y = -r, p.y = 0.5 + (pos.y * 0.5) + (y * dy); y <= r; y++, p.y += dy) {
  25. yy = y * y;
  26. if (xx + yy <= rr)
  27. {
  28. w = w0 * exp((-xx - yy) / (2.0 * rr));
  29. z[0] += tex2D(_MainTex, p).r * w;
  30. }
  31. }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement