Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fixed4 frag(v2f i) : SV_Target
- {
- const int m = 5;
- float z[m], zed;
- float xs = 1/ 1024.0;
- float ys = 1 / 720.0;
- float r = _blurRadius;
- float2 pos = i.vertex;
- float2 p = 0.5 * (i.vertex + 1.0);
- z[0] = tex2D(_MainTex, i.uv).r;; // oldest 2 frames
- z[1] = tex2D(_HistoryA, i.uv).r;
- if (abs(z[0] - z[1]) > _dataDelta) // threshold depth change
- {
- int index;
- float x, y, xx, yy, rr, dx, dy, w, w0;
- // 2D spatial gauss blur of z0
- rr = r * r;
- w0 = 0.3780 / pow(r, 1.975);
- z[0] = 0.0;
- for (dx = _MainTex_TexelSize.x, x = -r, p.x = 0.5 + (pos.x * 0.5) + (x * dx); x <= r; x++, p.x += dx) {
- xx = x * x;
- for (dy = _MainTex_TexelSize.y, y = -r, p.y = 0.5 + (pos.y * 0.5) + (y * dy); y <= r; y++, p.y += dy) {
- yy = y * y;
- if (xx + yy <= rr)
- {
- w = w0 * exp((-xx - yy) / (2.0 * rr));
- z[0] += tex2D(_MainTex, p).r * w;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement