Skip to content

Commit b8572ad

Browse files
committed
Merge branch 'dev'
2 parents e70b532 + bded0ff commit b8572ad

File tree

167 files changed

+18548
-11413
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

167 files changed

+18548
-11413
lines changed

‎.github/workflows/build.yml‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ jobs:
1818

1919
steps:
2020
- uses: actions/checkout@v2.4.0
21+
22+
- name: Setup dotnet
23+
uses: actions/setup-dotnet@v2
24+
with:
25+
dotnet-version: '6.0.202'
2126

2227
- name: Load Conan cache
2328
uses: actions/cache@v2

‎.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
*.userosscache
1111
*.sln.docstates
1212
.conan/
13+
my_*/
1314

1415
# User-specific files (MonoDevelop/Xamarin Studio)
1516
*.userprefs

‎DEPLOY/Deploy.bat‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,3 @@ cd ../publish/
3030
del *.pdb
3131
del *lib
3232
del *.exp
33-
del xaudio2_9redist.dll

‎Effects/ACNet.hlsl‎

Lines changed: 494 additions & 372 deletions
Large diffs are not rendered by default.

‎Effects/AdaptiveSharpen.hlsl‎

Lines changed: 173 additions & 255 deletions
Large diffs are not rendered by default.

‎Effects/Anime4K_3D_AA_Upscale_US.hlsl‎

Lines changed: 185 additions & 85 deletions
Large diffs are not rendered by default.

‎Effects/Anime4K_3D_Upscale_US.hlsl‎

Lines changed: 185 additions & 85 deletions
Large diffs are not rendered by default.
Lines changed: 78 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,14 @@
1+
// Anime4K_Denoise_Bilateral_Mean
12
// 移植自 https://github.com/bloc97/Anime4K/blob/master/glsl/Denoise/Anime4K_Denoise_Bilateral_Mean.glsl
23

34

45
//!MAGPIE EFFECT
5-
//!VERSION 1
6+
//!VERSION 2
67
//!OUTPUT_WIDTH INPUT_WIDTH
78
//!OUTPUT_HEIGHT INPUT_HEIGHT
89

9-
//!CONSTANT
10-
//!VALUE INPUT_PT_X
11-
float inputPtX;
1210

13-
//!CONSTANT
14-
//!VALUE INPUT_PT_Y
15-
float inputPtY;
16-
17-
//!CONSTANT
11+
//!PARAMETER
1812
//!MIN 1e-5
1913
//!DEFAULT 0.1
2014
float intensitySigma;
@@ -28,46 +22,100 @@ SamplerState sam;
2822

2923

3024
//!PASS 1
31-
//!BIND INPUT
25+
//!IN INPUT
26+
//!BLOCK_SIZE 16
27+
//!NUM_THREADS 64
3228

3329
#define INTENSITY_SIGMA intensitySigma //Intensity window size, higher is stronger denoise, must be a positive real number
3430
#define SPATIAL_SIGMA 1.0 //Spatial window size, higher is stronger denoise, must be a positive real number.
3531

3632
#define INTENSITY_POWER_CURVE 1.0 //Intensity window power curve. Setting it to 0 will make the intensity window treat all intensities equally, while increasing it will make the window narrower in darker intensities and wider in brighter intensities.
3733

3834
#define KERNELSIZE (max(uint(ceil(SPATIAL_SIGMA * 2.0)), 1) * 2 + 1) //Kernel size, must be an positive odd integer.
39-
#define KERNELHALFSIZE (int(KERNELSIZE/2)) //Half of the kernel size without remainder. Must be equal to trunc(KERNELSIZE/2).
35+
#define KERNELHALFSIZE (uint(KERNELSIZE/2)) //Half of the kernel size without remainder. Must be equal to trunc(KERNELSIZE/2).
4036
#define KERNELLEN (KERNELSIZE * KERNELSIZE) //Total area of kernel. Must be equal to KERNELSIZE * KERNELSIZE.
4137

42-
#define GETOFFSET(i) int2(int(i % KERNELSIZE) - KERNELHALFSIZE, int(i / KERNELSIZE) - KERNELHALFSIZE)
4338

44-
float3 gaussian_vec(float3 x, float3 s, float3 m) {
45-
float3 scaled = (x - m) / s;
39+
float3 gaussian_vec(float3 x, float3 rcpS, float3 m) {
40+
float3 scaled = (x - m) * rcpS;
4641
return exp(-0.5 * scaled * scaled);
4742
}
4843

49-
float gaussian(float x, float s, float m) {
50-
float scaled = (x - m) / s;
44+
float gaussian(float x, float rcpS, float m) {
45+
float scaled = (x - m) * rcpS;
5146
return exp(-0.5 * scaled * scaled);
5247
}
5348

5449

55-
float4 Pass1(float2 pos) {
56-
float3 sum = 0;
57-
float3 n = 0;
58-
59-
float3 vc = INPUT.Sample(sam, pos).rgb;
50+
void Pass1(uint2 blockStart, uint3 threadId) {
51+
uint2 gxy = (Rmp8x8(threadId.x) << 1) + blockStart;
52+
if (!CheckViewport(gxy)) {
53+
return;
54+
}
6055

61-
float3 is = pow(vc + 0.0001, INTENSITY_POWER_CURVE) * INTENSITY_SIGMA;
62-
float ss = SPATIAL_SIGMA;
56+
float2 inputPt = GetInputPt();
57+
uint i, j;
58+
59+
float3 src[KERNELSIZE + 1][KERNELSIZE + 1];
60+
[unroll]
61+
for (i = 0; i <= KERNELSIZE - 1; i += 2) {
62+
[unroll]
63+
for (j = 0; j <= KERNELSIZE - 1; j += 2) {
64+
float2 tpos = (gxy + int2(i, j) - KERNELHALFSIZE + 1) * inputPt;
65+
const float4 sr = INPUT.GatherRed(sam, tpos);
66+
const float4 sg = INPUT.GatherGreen(sam, tpos);
67+
const float4 sb = INPUT.GatherBlue(sam, tpos);
68+
69+
// w z
70+
// x y
71+
src[i][j] = float3(sr.w, sg.w, sb.w);
72+
src[i][j + 1] = float3(sr.x, sg.x, sb.x);
73+
src[i + 1][j] = float3(sr.z, sg.z, sb.z);
74+
src[i + 1][j + 1] = float3(sr.y, sg.y, sb.y);
75+
}
76+
}
6377

64-
for (uint i = 0; i < KERNELLEN; i++) {
65-
float2 ipos = pos + GETOFFSET(i) * float2(inputPtX, inputPtY);
66-
float3 v = INPUT.Sample(sam, ipos).rgb;
67-
float3 d = gaussian_vec(v, is, vc) * gaussian(length(ipos), ss, 0.0);
68-
sum += d * v;
69-
n += d;
78+
float len[KERNELSIZE][KERNELSIZE];
79+
[unroll]
80+
for (i = 0; i < KERNELSIZE; ++i) {
81+
[unroll]
82+
for (j = 0; j < KERNELSIZE; ++j) {
83+
len[i][j] = length(float2((int)i - KERNELHALFSIZE, (int)j - KERNELHALFSIZE));
84+
}
7085
}
7186

72-
return float4(sum / n, 1);
87+
[unroll]
88+
for (i = 0; i <= 1; ++i) {
89+
[unroll]
90+
for (j = 0; j <= 1; ++j) {
91+
uint2 destPos = gxy + uint2(i, j);
92+
93+
if (i != 0 || j != 0) {
94+
if (!CheckViewport(gxy)) {
95+
continue;
96+
}
97+
}
98+
99+
float3 sum = 0;
100+
float3 n = 0;
101+
102+
float3 vc = src[KERNELHALFSIZE + i][KERNELHALFSIZE + j].rgb;
103+
104+
float3 rcpIs = rcp(pow(vc + 0.0001, INTENSITY_POWER_CURVE) * INTENSITY_SIGMA);
105+
float rcpSs = rcp(SPATIAL_SIGMA);
106+
107+
[unroll]
108+
for (uint k = 0; k < KERNELSIZE; ++k) {
109+
[unroll]
110+
for (uint m = 0; m < KERNELSIZE; ++m) {
111+
float3 v = src[k + i][m + j];
112+
float3 d = gaussian_vec(v, rcpIs, vc) * gaussian(len[k][m], rcpSs, 0);
113+
sum += d * v;
114+
n += d;
115+
}
116+
}
117+
118+
WriteToOutput(destPos, sum / n);
119+
}
120+
}
73121
}

‎Effects/Anime4K_Denoise_Bilateral_Median.hlsl‎

Lines changed: 37 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -2,54 +2,29 @@
22

33

44
//!MAGPIE EFFECT
5-
//!VERSION 1
5+
//!VERSION 2
66
//!OUTPUT_WIDTH INPUT_WIDTH
77
//!OUTPUT_HEIGHT INPUT_HEIGHT
88

9-
//!CONSTANT
10-
//!VALUE INPUT_PT_X
11-
float inputPtX;
129

13-
//!CONSTANT
14-
//!VALUE INPUT_PT_Y
15-
float inputPtY;
16-
17-
//!CONSTANT
10+
//!PARAMETER
1811
//!MIN 1e-5
1912
//!DEFAULT 0.1
2013
float intensitySigma;
2114

2215
//!TEXTURE
2316
Texture2D INPUT;
2417

25-
//!TEXTURE
26-
//!WIDTH INPUT_WIDTH
27-
//!HEIGHT INPUT_HEIGHT
28-
//!FORMAT R16_FLOAT
29-
Texture2D lumaTex;
30-
3118
//!SAMPLER
3219
//!FILTER POINT
3320
SamplerState sam;
3421

3522

36-
//!PASS 1
37-
//!BIND INPUT
38-
//!SAVE lumaTex
39-
40-
float get_luma(float3 rgba) {
41-
return dot(float3(0.299, 0.587, 0.114), rgba);
42-
}
43-
44-
float4 Pass1(float2 pos) {
45-
return float4(get_luma(INPUT.Sample(sam, pos).rgb), 0.0, 0.0, 0.0);
46-
}
47-
4823

49-
//!PASS 2
50-
//!BIND INPUT, lumaTex
51-
52-
#pragma warning(disable: 3557)
24+
//!PASS 1
25+
//!IN INPUT
26+
//!BLOCK_SIZE 8
27+
//!NUM_THREADS 64
5328

5429
#define INTENSITY_SIGMA intensitySigma //Intensity window size, higher is stronger denoise, must be a positive real number
5530
#define SPATIAL_SIGMA 1.0 //Spatial window size, higher is stronger denoise, must be a positive real number.
@@ -63,15 +38,23 @@ float4 Pass1(float2 pos) {
6338

6439
#define GETOFFSET(i) int2(int(i % KERNELSIZE) - KERNELHALFSIZE, int(i / KERNELSIZE) - KERNELHALFSIZE)
6540

41+
float get_luma(float3 rgb) {
42+
return dot(float3(0.299, 0.587, 0.114), rgb);
43+
}
44+
6645
float gaussian(float x, float s, float m) {
6746
float scaled = (x - m) / s;
6847
return exp(-0.5 * scaled * scaled);
6948
}
7049

7150
float3 getMedian(float3 v[KERNELLEN], float w[KERNELLEN], float n) {
51+
float3 result = float3(0, 0, 0);
52+
53+
[unroll]
7254
for (uint i = 0; i < KERNELLEN; i++) {
7355
float w_above = 0.0;
7456
float w_below = 0.0;
57+
[unroll]
7558
for (uint j = 0; j < KERNELLEN; j++) {
7659
if (v[j].x > v[i].x) {
7760
w_above += w[j];
@@ -81,30 +64,40 @@ float3 getMedian(float3 v[KERNELLEN], float w[KERNELLEN], float n) {
8164
}
8265

8366
if ((n - w_above) / n >= 0.5 && w_below / n <= 0.5) {
84-
return v[i];
67+
result = v[i];
68+
break;
8569
}
8670
}
8771

88-
return float3(0, 0, 0);
72+
return result;
8973
}
9074

91-
float4 Pass2(float2 pos) {
75+
void Pass1(uint2 blockStart, uint3 threadId) {
76+
uint2 gxy = Rmp8x8(threadId.x) + blockStart;
77+
if (!CheckViewport(gxy)) {
78+
return;
79+
}
80+
81+
float2 inputPt = GetInputPt();
82+
float2 pos = (gxy + 0.5f) * inputPt;
83+
9284
float3 histogram_v[KERNELLEN];
9385
float histogram_l[KERNELLEN];
9486
float histogram_w[KERNELLEN];
9587
float n = 0.0;
9688

97-
float vc = lumaTex.Sample(sam, pos).x;
89+
float vc = get_luma(INPUT.SampleLevel(sam, pos, 0).rgb);
9890

9991
float is = pow(vc + 0.0001, INTENSITY_POWER_CURVE) * INTENSITY_SIGMA;
10092
float ss = SPATIAL_SIGMA;
10193

10294
uint i;
10395

96+
[unroll]
10497
for (i = 0; i < KERNELLEN; i++) {
105-
float2 ipos = pos + GETOFFSET(i) * float2(inputPtX, inputPtY);
106-
histogram_v[i] = INPUT.Sample(sam, ipos).rgb;
107-
histogram_l[i] = lumaTex.Sample(sam, ipos).x;
98+
int2 ipos = GETOFFSET(i);
99+
histogram_v[i] = INPUT.SampleLevel(sam, pos + ipos * inputPt, 0).rgb;
100+
histogram_l[i] = get_luma(histogram_v[i]);
108101
histogram_w[i] = gaussian(histogram_l[i], is, vc) * gaussian(length(ipos), ss, 0.0);
109102
n += histogram_w[i];
110103
}
@@ -113,12 +106,15 @@ float4 Pass2(float2 pos) {
113106
float histogram_wn[KERNELLEN];
114107
n = 0.0;
115108

109+
[unroll]
116110
for (i = 0; i < KERNELLEN; i++) {
117111
histogram_wn[i] = 0.0;
118112
}
119113

114+
[unroll]
120115
for (i = 0; i < KERNELLEN; i++) {
121116
histogram_wn[i] += gaussian(0.0, HISTOGRAM_REGULARIZATION, 0.0) * histogram_w[i];
117+
[unroll]
122118
for (uint j = (i + 1); j < KERNELLEN; j++) {
123119
float d = gaussian(histogram_l[j], HISTOGRAM_REGULARIZATION, histogram_l[i]);
124120
histogram_wn[j] += d * histogram_w[i];
@@ -127,8 +123,9 @@ float4 Pass2(float2 pos) {
127123
n += histogram_wn[i];
128124
}
129125

130-
return float4(getMedian(histogram_v, histogram_wn, n), 1);
126+
WriteToOutput(gxy, getMedian(histogram_v, histogram_wn, n));
127+
return;
131128
}
132129

133-
return float4(getMedian(histogram_v, histogram_w, n), 1);
130+
WriteToOutput(gxy, getMedian(histogram_v, histogram_w, n));
134131
}

0 commit comments

Comments
 (0)