|
320 | 320 | *
|
321 | 321 | * Motion estimation (ME) should improve quality without impacting speed.
|
322 | 322 | *
|
| 323 | + * Increasing temporal distortion (TD) can reduce motion blur. |
| 324 | + * |
323 | 325 | * T: number of frames used
|
324 | 326 | * ME: motion estimation, 0 for none, 1 for max weight, 2 for weighted avg
|
325 | 327 | * MEF: estimate factor, compensates for ME being one frame behind
|
326 | 328 | * TRF: compare against the denoised frames
|
| 329 | + * TD: temporal distortion, higher numbers give less weight to previous frames |
327 | 330 | */
|
328 | 331 | #ifdef LUMA_raw
|
329 | 332 | #define T 0
|
330 | 333 | #define ME 1
|
331 | 334 | #define MEF 2
|
332 | 335 | #define TRF 0
|
| 336 | +#define TD 1.0 |
333 | 337 | #else
|
334 | 338 | #define T 0
|
335 | 339 | #define ME 0
|
336 | 340 | #define MEF 2
|
337 | 341 | #define TRF 0
|
| 342 | +#define TD 1.0 |
338 | 343 | #endif
|
339 | 344 |
|
340 | 345 | /* Spatial kernel
|
341 | 346 | *
|
342 | 347 | * Increasing the spatial denoising factor (SS) reduces the weight of further
|
343 | 348 | * pixels.
|
344 | 349 | *
|
345 |
| - * Spatial distortion instructs the spatial kernel to view that axis as |
346 |
| - * closer/further, for instance SD=(1,1,0.5) would make the temporal axis |
347 |
| - * appear closer and increase blur between frames. |
348 |
| - * |
349 | 350 | * The intra-patch variants are supposed to help with larger patch sizes.
|
350 | 351 | *
|
351 | 352 | * SST: enables spatial kernel if R>=PST, 0 fully disables
|
352 | 353 | * SS: spatial sigma
|
353 |
| - * SD: spatial distortion (X, Y, time) |
354 | 354 | * PSS: intra-patch spatial sigma
|
355 | 355 | * PST: enables intra-patch spatial kernel if P>=PST, 0 fully disables
|
356 |
| - * PSD: intra-patch spatial distortion (X, Y) |
357 | 356 | */
|
358 | 357 | #ifdef LUMA_raw
|
359 | 358 | #define SST 1
|
360 | 359 | #define SS 0.5072938692870894
|
361 |
| -#define SD vec3(1,1,1) |
362 | 360 | #define PST 0
|
363 | 361 | #define PSS 0.0
|
364 |
| -#define PSD vec2(1,1) |
365 | 362 | #else
|
366 | 363 | #define SST 1
|
367 | 364 | #define SS 0.31580805565941705
|
368 |
| -#define SD vec3(1,1,1) |
369 | 365 | #define PST 0
|
370 | 366 | #define PSS 0.0
|
371 |
| -#define PSD vec2(1,1) |
372 | 367 | #endif
|
373 | 368 |
|
374 | 369 | /* Kernels
|
@@ -811,24 +806,24 @@ vec2 ref(vec2 p, int d)
|
811 | 806 | float spatial_r(vec3 v)
|
812 | 807 | {
|
813 | 808 | v.xy += 0.5 - fract(HOOKED_pos*HOOKED_size);
|
814 |
| - return SK(length(v*SD)*SS); |
| 809 | + v.z *= TD; |
| 810 | + return SK(length(v)*SS); |
815 | 811 | }
|
816 | 812 | #else
|
817 | 813 | #define spatial_r(v) (1)
|
818 | 814 | #endif
|
819 | 815 |
|
| 816 | +// 2D blur for sharpening |
820 | 817 | #if AS
|
821 | 818 | float spatial_as(vec3 v)
|
822 | 819 | {
|
823 | 820 | v.xy += 0.5 - fract(HOOKED_pos*HOOKED_size);
|
824 |
| - return ASK(length(v*SD)*ASS); |
| 821 | + return ASK(length(v)*ASS) * int(v.z == 0); |
825 | 822 | }
|
826 |
| -#else |
827 |
| -#define spatial_as(v) (1) |
828 | 823 | #endif
|
829 | 824 |
|
830 | 825 | #if PST && P >= PST
|
831 |
| -#define spatial_p(v) PSK(length(v*PSD)*PSS) |
| 826 | +#define spatial_p(v) PSK(length(v)*PSS) |
832 | 827 | #else
|
833 | 828 | #define spatial_p(v) (1)
|
834 | 829 | #endif
|
@@ -1075,7 +1070,6 @@ vec4 hook()
|
1075 | 1070 |
|
1076 | 1071 | #if AS
|
1077 | 1072 | float spatial_as_weight = spatial_as(tr);
|
1078 |
| - spatial_as_weight *= int(r.z == 0); // ignore temporal |
1079 | 1073 | sum_as += px * spatial_as_weight;
|
1080 | 1074 | total_weight_as += spatial_as_weight;
|
1081 | 1075 | #endif
|
@@ -1443,55 +1437,50 @@ return _INJ_RF_LUMA_texOff(0);
|
1443 | 1437 | *
|
1444 | 1438 | * Motion estimation (ME) should improve quality without impacting speed.
|
1445 | 1439 | *
|
| 1440 | + * Increasing temporal distortion (TD) can reduce motion blur. |
| 1441 | + * |
1446 | 1442 | * T: number of frames used
|
1447 | 1443 | * ME: motion estimation, 0 for none, 1 for max weight, 2 for weighted avg
|
1448 | 1444 | * MEF: estimate factor, compensates for ME being one frame behind
|
1449 | 1445 | * TRF: compare against the denoised frames
|
| 1446 | + * TD: temporal distortion, higher numbers give less weight to previous frames |
1450 | 1447 | */
|
1451 | 1448 | #ifdef LUMA_raw
|
1452 | 1449 | #define T 0
|
1453 | 1450 | #define ME 1
|
1454 | 1451 | #define MEF 2
|
1455 | 1452 | #define TRF 0
|
| 1453 | +#define TD 1.0 |
1456 | 1454 | #else
|
1457 | 1455 | #define T 0
|
1458 | 1456 | #define ME 0
|
1459 | 1457 | #define MEF 2
|
1460 | 1458 | #define TRF 0
|
| 1459 | +#define TD 1.0 |
1461 | 1460 | #endif
|
1462 | 1461 |
|
1463 | 1462 | /* Spatial kernel
|
1464 | 1463 | *
|
1465 | 1464 | * Increasing the spatial denoising factor (SS) reduces the weight of further
|
1466 | 1465 | * pixels.
|
1467 | 1466 | *
|
1468 |
| - * Spatial distortion instructs the spatial kernel to view that axis as |
1469 |
| - * closer/further, for instance SD=(1,1,0.5) would make the temporal axis |
1470 |
| - * appear closer and increase blur between frames. |
1471 |
| - * |
1472 | 1467 | * The intra-patch variants are supposed to help with larger patch sizes.
|
1473 | 1468 | *
|
1474 | 1469 | * SST: enables spatial kernel if R>=PST, 0 fully disables
|
1475 | 1470 | * SS: spatial sigma
|
1476 |
| - * SD: spatial distortion (X, Y, time) |
1477 | 1471 | * PSS: intra-patch spatial sigma
|
1478 | 1472 | * PST: enables intra-patch spatial kernel if P>=PST, 0 fully disables
|
1479 |
| - * PSD: intra-patch spatial distortion (X, Y) |
1480 | 1473 | */
|
1481 | 1474 | #ifdef LUMA_raw
|
1482 | 1475 | #define SST 1
|
1483 | 1476 | #define SS 0.5045657681048714
|
1484 |
| -#define SD vec3(1,1,1) |
1485 | 1477 | #define PST 0
|
1486 | 1478 | #define PSS 0.0
|
1487 |
| -#define PSD vec2(1,1) |
1488 | 1479 | #else
|
1489 | 1480 | #define SST 1
|
1490 | 1481 | #define SS 0.2660216669677905
|
1491 |
| -#define SD vec3(1,1,1) |
1492 | 1482 | #define PST 0
|
1493 | 1483 | #define PSS 0.0
|
1494 |
| -#define PSD vec2(1,1) |
1495 | 1484 | #endif
|
1496 | 1485 |
|
1497 | 1486 | /* Kernels
|
@@ -1934,24 +1923,24 @@ vec2 ref(vec2 p, int d)
|
1934 | 1923 | float spatial_r(vec3 v)
|
1935 | 1924 | {
|
1936 | 1925 | v.xy += 0.5 - fract(HOOKED_pos*HOOKED_size);
|
1937 |
| - return SK(length(v*SD)*SS); |
| 1926 | + v.z *= TD; |
| 1927 | + return SK(length(v)*SS); |
1938 | 1928 | }
|
1939 | 1929 | #else
|
1940 | 1930 | #define spatial_r(v) (1)
|
1941 | 1931 | #endif
|
1942 | 1932 |
|
| 1933 | +// 2D blur for sharpening |
1943 | 1934 | #if AS
|
1944 | 1935 | float spatial_as(vec3 v)
|
1945 | 1936 | {
|
1946 | 1937 | v.xy += 0.5 - fract(HOOKED_pos*HOOKED_size);
|
1947 |
| - return ASK(length(v*SD)*ASS); |
| 1938 | + return ASK(length(v)*ASS) * int(v.z == 0); |
1948 | 1939 | }
|
1949 |
| -#else |
1950 |
| -#define spatial_as(v) (1) |
1951 | 1940 | #endif
|
1952 | 1941 |
|
1953 | 1942 | #if PST && P >= PST
|
1954 |
| -#define spatial_p(v) PSK(length(v*PSD)*PSS) |
| 1943 | +#define spatial_p(v) PSK(length(v)*PSS) |
1955 | 1944 | #else
|
1956 | 1945 | #define spatial_p(v) (1)
|
1957 | 1946 | #endif
|
@@ -2198,7 +2187,6 @@ vec4 hook()
|
2198 | 2187 |
|
2199 | 2188 | #if AS
|
2200 | 2189 | float spatial_as_weight = spatial_as(tr);
|
2201 |
| - spatial_as_weight *= int(r.z == 0); // ignore temporal |
2202 | 2190 | sum_as += px * spatial_as_weight;
|
2203 | 2191 | total_weight_as += spatial_as_weight;
|
2204 | 2192 | #endif
|
@@ -2565,55 +2553,50 @@ vec4 hook()
|
2565 | 2553 | *
|
2566 | 2554 | * Motion estimation (ME) should improve quality without impacting speed.
|
2567 | 2555 | *
|
| 2556 | + * Increasing temporal distortion (TD) can reduce motion blur. |
| 2557 | + * |
2568 | 2558 | * T: number of frames used
|
2569 | 2559 | * ME: motion estimation, 0 for none, 1 for max weight, 2 for weighted avg
|
2570 | 2560 | * MEF: estimate factor, compensates for ME being one frame behind
|
2571 | 2561 | * TRF: compare against the denoised frames
|
| 2562 | + * TD: temporal distortion, higher numbers give less weight to previous frames |
2572 | 2563 | */
|
2573 | 2564 | #ifdef LUMA_raw
|
2574 | 2565 | #define T 0
|
2575 | 2566 | #define ME 1
|
2576 | 2567 | #define MEF 2
|
2577 | 2568 | #define TRF 0
|
| 2569 | +#define TD 1.0 |
2578 | 2570 | #else
|
2579 | 2571 | #define T 0
|
2580 | 2572 | #define ME 0
|
2581 | 2573 | #define MEF 2
|
2582 | 2574 | #define TRF 0
|
| 2575 | +#define TD 1.0 |
2583 | 2576 | #endif
|
2584 | 2577 |
|
2585 | 2578 | /* Spatial kernel
|
2586 | 2579 | *
|
2587 | 2580 | * Increasing the spatial denoising factor (SS) reduces the weight of further
|
2588 | 2581 | * pixels.
|
2589 | 2582 | *
|
2590 |
| - * Spatial distortion instructs the spatial kernel to view that axis as |
2591 |
| - * closer/further, for instance SD=(1,1,0.5) would make the temporal axis |
2592 |
| - * appear closer and increase blur between frames. |
2593 |
| - * |
2594 | 2583 | * The intra-patch variants are supposed to help with larger patch sizes.
|
2595 | 2584 | *
|
2596 | 2585 | * SST: enables spatial kernel if R>=PST, 0 fully disables
|
2597 | 2586 | * SS: spatial sigma
|
2598 |
| - * SD: spatial distortion (X, Y, time) |
2599 | 2587 | * PSS: intra-patch spatial sigma
|
2600 | 2588 | * PST: enables intra-patch spatial kernel if P>=PST, 0 fully disables
|
2601 |
| - * PSD: intra-patch spatial distortion (X, Y) |
2602 | 2589 | */
|
2603 | 2590 | #ifdef LUMA_raw
|
2604 | 2591 | #define SST 1
|
2605 | 2592 | #define SS 0.5045657681048714
|
2606 |
| -#define SD vec3(1,1,1) |
2607 | 2593 | #define PST 0
|
2608 | 2594 | #define PSS 0.0
|
2609 |
| -#define PSD vec2(1,1) |
2610 | 2595 | #else
|
2611 | 2596 | #define SST 1
|
2612 | 2597 | #define SS 0.2660216669677905
|
2613 |
| -#define SD vec3(1,1,1) |
2614 | 2598 | #define PST 0
|
2615 | 2599 | #define PSS 0.0
|
2616 |
| -#define PSD vec2(1,1) |
2617 | 2600 | #endif
|
2618 | 2601 |
|
2619 | 2602 | /* Kernels
|
@@ -3056,24 +3039,24 @@ vec2 ref(vec2 p, int d)
|
3056 | 3039 | float spatial_r(vec3 v)
|
3057 | 3040 | {
|
3058 | 3041 | v.xy += 0.5 - fract(HOOKED_pos*HOOKED_size);
|
3059 |
| - return SK(length(v*SD)*SS); |
| 3042 | + v.z *= TD; |
| 3043 | + return SK(length(v)*SS); |
3060 | 3044 | }
|
3061 | 3045 | #else
|
3062 | 3046 | #define spatial_r(v) (1)
|
3063 | 3047 | #endif
|
3064 | 3048 |
|
| 3049 | +// 2D blur for sharpening |
3065 | 3050 | #if AS
|
3066 | 3051 | float spatial_as(vec3 v)
|
3067 | 3052 | {
|
3068 | 3053 | v.xy += 0.5 - fract(HOOKED_pos*HOOKED_size);
|
3069 |
| - return ASK(length(v*SD)*ASS); |
| 3054 | + return ASK(length(v)*ASS) * int(v.z == 0); |
3070 | 3055 | }
|
3071 |
| -#else |
3072 |
| -#define spatial_as(v) (1) |
3073 | 3056 | #endif
|
3074 | 3057 |
|
3075 | 3058 | #if PST && P >= PST
|
3076 |
| -#define spatial_p(v) PSK(length(v*PSD)*PSS) |
| 3059 | +#define spatial_p(v) PSK(length(v)*PSS) |
3077 | 3060 | #else
|
3078 | 3061 | #define spatial_p(v) (1)
|
3079 | 3062 | #endif
|
@@ -3320,7 +3303,6 @@ vec4 hook()
|
3320 | 3303 |
|
3321 | 3304 | #if AS
|
3322 | 3305 | float spatial_as_weight = spatial_as(tr);
|
3323 |
| - spatial_as_weight *= int(r.z == 0); // ignore temporal |
3324 | 3306 | sum_as += px * spatial_as_weight;
|
3325 | 3307 | total_weight_as += spatial_as_weight;
|
3326 | 3308 | #endif
|
|
0 commit comments