forked from JakobPCoder/ReshadeMotionEstimation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMotionEstimation.fx
693 lines (610 loc) · 22.5 KB
/
MotionEstimation.fx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
/*
# ReshadeMotionEstimation
- Dense Realtime Motion Estimation | Based on Block Matching and Pyramids
- Developed from 2019 to 2022
- First published 2022 - Copyright, Jakob Wapenhensch
# This work is licensed under the Creative Commons Attribution-NonCommercial 4.0 International (CC BY-NC 4.0) License
- https://creativecommons.org/licenses/by-nc/4.0/
- https://creativecommons.org/licenses/by-nc/4.0/legalcode
# Human-readable summary of the License and not a substitute for https://creativecommons.org/licenses/by-nc/4.0/legalcode:
You are free to:
- Share — copy and redistribute the material in any medium or format
- Adapt — remix, transform, and build upon the material
- The licensor cannot revoke these freedoms as long as you follow the license terms.
Under the following terms:
- Attribution — You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
- NonCommercial — You may not use the material for commercial purposes.
- No additional restrictions — You may not apply legal terms or technological measures that legally restrict others from doing anything the license permits.
Notices:
- You do not have to comply with the license for elements of the material in the public domain or where your use is permitted by an applicable exception or limitation.
- No warranties are given. The license may not give you all of the permissions necessary for your intended use. For example, other rights such as publicity, privacy, or moral rights may limit how you use the material.
*/
#include "MotionEstimation.fxh"
// Samplers
sampler smpCur0 { Texture = texCur0; AddressU = Clamp; AddressV = Clamp; MipFilter = Linear; MinFilter = Linear; MagFilter = Point; };
sampler smpLast0 { Texture = texLast0; AddressU = Clamp; AddressV = Clamp; MipFilter = Linear; MinFilter = Linear; MagFilter = Point; };
sampler smpMotionFilterX { Texture = texMotionFilterX; AddressU = Clamp; AddressV = Clamp; MipFilter = Point; MinFilter = Point; MagFilter = Point; };
//Pyr:
//smpG samplers are .r = Grayscale, g = depth
//smgM samplers are .r = motion x, .g = motion y, .b = feature level, .a = loss;
sampler smpGCur0 { Texture = texGCur0; AddressU = Clamp; AddressV = Clamp; MipFilter = Linear; MinFilter = Linear; MagFilter = Point; };
sampler smpGLast0 { Texture = texGLast0; AddressU = Clamp; AddressV = Clamp; MipFilter = Linear; MinFilter = Linear; MagFilter = Point; };
sampler smpMCur0 { Texture = texMotionCur0; AddressU = Clamp; AddressV = Clamp; MipFilter = Point; MinFilter = Point; MagFilter = Point; };
///sampler smpMLast0 { Texture = texMotionLast0; AddressU = Clamp; AddressV = Clamp; MipFilter = Point; MinFilter = Point; MagFilter = Point; };
sampler smpGCur1 { Texture = texGCur1; AddressU = Clamp; AddressV = Clamp; MipFilter = Linear; MinFilter = Linear; MagFilter = Point; };
sampler smpGLast1 { Texture = texGLast1; AddressU = Clamp; AddressV = Clamp; MipFilter = Linear; MinFilter = Linear; MagFilter = Point; };
sampler smpMCur1 { Texture = texMotionCur1; AddressU = Clamp; AddressV = Clamp; MipFilter = Point; MinFilter = Point; MagFilter = Point; };
//sampler smpMLast1 { Texture = texMotionLast1; AddressU = Clamp; AddressV = Clamp; MipFilter = Point; MinFilter = Point; MagFilter = Point; };
sampler smpGCur2 { Texture = texGCur2; AddressU = Clamp; AddressV = Clamp; MipFilter = Linear; MinFilter = Linear; MagFilter = Point; };
sampler smpGLast2 { Texture = texGLast2; AddressU = Clamp; AddressV = Clamp; MipFilter = Linear; MinFilter = Linear; MagFilter = Point; };
sampler smpMCur2 { Texture = texMotionCur2; AddressU = Clamp; AddressV = Clamp; MipFilter = Point; MinFilter = Point; MagFilter = Point; };
//sampler smpMLast2 { Texture = texMotionLast2; AddressU = Clamp; AddressV = Clamp; MipFilter = Point; MinFilter = Point; MagFilter = Point; };
sampler smpGCur3 { Texture = texGCur3; AddressU = Clamp; AddressV = Clamp; MipFilter = Linear; MinFilter = Linear; MagFilter = Point; };
sampler smpGLast3 { Texture = texGLast3; AddressU = Clamp; AddressV = Clamp; MipFilter = Linear; MinFilter = Linear; MagFilter = Point; };
sampler smpMCur3 { Texture = texMotionCur3; AddressU = Clamp; AddressV = Clamp; MipFilter = Point; MinFilter = Point; MagFilter = Point; };
//sampler smpMLast3 { Texture = texMotionLast3; AddressU = Clamp; AddressV = Clamp; MipFilter = Point; MinFilter = Point; MagFilter = Point; };
sampler smpGCur4 { Texture = texGCur4; AddressU = Clamp; AddressV = Clamp; MipFilter = Linear; MinFilter = Linear; MagFilter = Point; };
sampler smpGLast4 { Texture = texGLast4; AddressU = Clamp; AddressV = Clamp; MipFilter = Linear; MinFilter = Linear; MagFilter = Point; };
sampler smpMCur4 { Texture = texMotionCur4; AddressU = Clamp; AddressV = Clamp; MipFilter = Point; MinFilter = Point; MagFilter = Point; };
//sampler smpMLast4 { Texture = texMotionLast4; AddressU = Clamp; AddressV = Clamp; MipFilter = Point; MinFilter = Point; MagFilter = Point; };
sampler smpGCur5 { Texture = texGCur5; AddressU = Clamp; AddressV = Clamp; MipFilter = Linear; MinFilter = Linear; MagFilter = Point; };
sampler smpGLast5 { Texture = texGLast5; AddressU = Clamp; AddressV = Clamp; MipFilter = Linear; MinFilter = Linear; MagFilter = Point; };
sampler smpMCur5 { Texture = texMotionCur5; AddressU = Clamp; AddressV = Clamp; MipFilter = Point; MinFilter = Point; MagFilter = Point; };
//sampler smpMLast5 { Texture = texMotionLast5; AddressU = Clamp; AddressV = Clamp; MipFilter = Point; MinFilter = Point; MagFilter = Point; };
sampler smpGCur6 { Texture = texGCur6; AddressU = Clamp; AddressV = Clamp; MipFilter = Linear; MinFilter = Linear; MagFilter = Point; };
sampler smpGLast6 { Texture = texGLast6; AddressU = Clamp; AddressV = Clamp; MipFilter = Linear; MinFilter = Linear; MagFilter = Point; };
sampler smpMCur6 { Texture = texMotionCur6; AddressU = Clamp; AddressV = Clamp; MipFilter = Point; MinFilter = Point; MagFilter = Point; };
//sampler smpMLast6 { Texture = texMotionLast6; AddressU = Clamp; AddressV = Clamp; MipFilter = Point; MinFilter = Point; MagFilter = Point; };
sampler smpGCur7 { Texture = texGCur7; AddressU = Clamp; AddressV = Clamp; MipFilter = Linear; MinFilter = Linear; MagFilter = Point; };
sampler smpGLast7 { Texture = texGLast7; AddressU = Clamp; AddressV = Clamp; MipFilter = Linear; MinFilter = Linear; MagFilter = Point; };
sampler smpMCur7 { Texture = texMotionCur7; AddressU = Clamp; AddressV = Clamp; MipFilter = Point; MinFilter = Point; MagFilter = Point; };
//sampler smpMLast7 { Texture = texMotionLast7; AddressU = Clamp; AddressV = Clamp; MipFilter = Point; MinFilter = Point; MagFilter = Point; };
// Passes
//Save old data and get new one
float4 SaveLastPS(float4 position : SV_Position, float2 texcoord : TEXCOORD, out float4 last : SV_Target1, out float4 lastGray : SV_Target2/*, out float4 lastMotionLayer : SV_Target3*/) : SV_Target0
{
last = tex2D(smpCur0, texcoord);
lastGray = tex2D(smpGCur0, texcoord);
//lastMotionLayer = tex2D(smpMCur0, texcoord);
return tex2D(ReShade::BackBuffer, texcoord);
}
float2 CurToGrayPS(float4 position : SV_Position, float2 texcoord : TEXCOORD) : SV_Target
{
return float2((dot(tex2D(smpCur0, texcoord).rgb, float3(0.3, 0.5, 0.2))), ReShade::GetLinearizedDepth(texcoord));
}
//Save Old Pyramid
float4 SaveGray1PS(float4 position : SV_Position, float2 texcoord : TEXCOORD/*, out float4 lastMotionLayer : SV_Target1*/) : SV_Target0
{
//llastMotionLayer = tex2D(smpMCur1, texcoord);
return tex2D(smpGCur1, texcoord);
}
float4 SaveGray2PS(float4 position : SV_Position, float2 texcoord : TEXCOORD/*, out float4 lastMotionLayer : SV_Target1*/) : SV_Target0
{
//lastMotionLayer = tex2D(smpMCur2, texcoord);
return tex2D(smpGCur2, texcoord);
}
float4 SaveGray3PS(float4 position : SV_Position, float2 texcoord : TEXCOORD/*, out float4 lastMotionLayer : SV_Target1*/) : SV_Target0
{
//lastMotionLayer = tex2D(smpMCur3, texcoord);
return tex2D(smpGCur3, texcoord);
}
float4 SaveGray4PS(float4 position : SV_Position, float2 texcoord : TEXCOORD/*, out float4 lastMotionLayer : SV_Target1*/) : SV_Target0
{
//lastMotionLayer = tex2D(smpMCur4, texcoord);
return tex2D(smpGCur4, texcoord);
}
float4 SaveGray5PS(float4 position : SV_Position, float2 texcoord : TEXCOORD/*, out float4 lastMotionLayer : SV_Target1*/) : SV_Target0
{
//lastMotionLayer = tex2D(smpMCur5, texcoord);
return tex2D(smpGCur5, texcoord);
}
float4 SaveGray6PS(float4 position : SV_Position, float2 texcoord : TEXCOORD/*, out float4 lastMotionLayer : SV_Target1*/) : SV_Target0
{
//lastMotionLayer = tex2D(smpMCur6, texcoord);
return tex2D(smpGCur6, texcoord);
}
//Build New Pyramid
float4 DownscaleGray1PS(float4 position : SV_Position, float2 texcoord : TEXCOORD ) : SV_Target
{
return tex2D(smpGCur0, texcoord);
}
float4 DownscaleGray2PS(float4 position : SV_Position, float2 texcoord : TEXCOORD ) : SV_Target
{
return tex2D(smpGCur1, texcoord);
}
float4 DownscaleGray3PS(float4 position : SV_Position, float2 texcoord : TEXCOORD ) : SV_Target
{
return tex2D(smpGCur2, texcoord);
}
float4 DownscaleGray4PS(float4 position : SV_Position, float2 texcoord : TEXCOORD ) : SV_Target
{
return tex2D(smpGCur3, texcoord);
}
float4 DownscaleGray5PS(float4 position : SV_Position, float2 texcoord : TEXCOORD ) : SV_Target
{
return tex2D(smpGCur4, texcoord);
}
float4 DownscaleGray6PS(float4 position : SV_Position, float2 texcoord : TEXCOORD ) : SV_Target
{
return tex2D(smpGCur5, texcoord);
}
#define TEMP_RESET_THRESH (0.01)
//Estimate motion for each Level of the pyramid
float4 MotionEstimation7PS(float4 position : SV_Position, float2 texcoord : TEXCOORD ) : SV_Target
{
float4 curMotionEstimation = 0;
[branch]
if (UI_ME_LAYER_MIN > 6)
curMotionEstimation = CalcMotionLayer(texcoord, float2(0, 0), smpGCur7, smpGLast7, UI_ME_MAX_ITERATIONS_PER_LEVEL);
return curMotionEstimation;
}
float4 MotionEstimation6PS(float4 position : SV_Position, float2 texcoord : TEXCOORD ) : SV_Target
{
float2 searchStart = float2(0, 0);
[branch]
if (UI_ME_LAYER_MIN > 6)
{
float4 upscaledLowerLayer = UpscaleMotion(texcoord, smpGCur6, smpGCur7, smpMCur7);
//if (UI_DEBUG_PYRAMID_MERGE)
searchStart = motionFromGBuffer(upscaledLowerLayer);
}
float4 curMotionEstimation = 0;
[branch]
if (UI_ME_LAYER_MIN > 5)
curMotionEstimation = CalcMotionLayer(texcoord, searchStart, smpGCur6, smpGLast6, UI_ME_MAX_ITERATIONS_PER_LEVEL);
return curMotionEstimation;
}
float4 MotionEstimation5PS(float4 position : SV_Position, float2 texcoord : TEXCOORD ) : SV_Target
{
float2 searchStart = float2(0, 0);
[branch]
if (UI_ME_LAYER_MIN > 5)
{
float4 upscaledLowerLayer = UpscaleMotion(texcoord, smpGCur5, smpGCur6, smpMCur6);
//if (UI_DEBUG_PYRAMID_MERGE)
searchStart = motionFromGBuffer(upscaledLowerLayer);
}
float4 curMotionEstimation = 0;
[branch]
if (UI_ME_LAYER_MIN > 4)
curMotionEstimation = CalcMotionLayer(texcoord, searchStart, smpGCur5, smpGLast5, UI_ME_MAX_ITERATIONS_PER_LEVEL);
return curMotionEstimation;
}
float4 MotionEstimation4PS(float4 position : SV_Position, float2 texcoord : TEXCOORD ) : SV_Target
{
float2 searchStart = float2(0, 0);
[branch]
if (UI_ME_LAYER_MIN > 4)
{
float4 upscaledLowerLayer = UpscaleMotion(texcoord, smpGCur4, smpGCur5, smpMCur5);
//if (UI_DEBUG_PYRAMID_MERGE)
searchStart = motionFromGBuffer(upscaledLowerLayer);
}
float4 curMotionEstimation = 0;
[branch]
if (UI_ME_LAYER_MIN > 3)
curMotionEstimation = CalcMotionLayer(texcoord, searchStart, smpGCur4, smpGLast4, UI_ME_MAX_ITERATIONS_PER_LEVEL);
return curMotionEstimation;
}
float4 MotionEstimation3PS(float4 position : SV_Position, float2 texcoord : TEXCOORD ) : SV_Target
{
float2 searchStart = float2(0, 0);
[branch]
if (UI_ME_LAYER_MIN > 3)
{
float4 upscaledLowerLayer = UpscaleMotion(texcoord, smpGCur3, smpGCur4, smpMCur4);
//if (UI_DEBUG_PYRAMID_MERGE)
searchStart = motionFromGBuffer(upscaledLowerLayer);
}
float4 curMotionEstimation = CalcMotionLayer(texcoord, searchStart, smpGCur3, smpGLast3, UI_ME_MAX_ITERATIONS_PER_LEVEL);
return curMotionEstimation;
}
float4 MotionEstimation2PS(float4 position : SV_Position, float2 texcoord : TEXCOORD ) : SV_Target
{
float4 upscaledLowerLayer = UpscaleMotion(texcoord, smpGCur2, smpGCur3, smpMCur3);
float2 searchStart = float2(0, 0);
//if (UI_DEBUG_PYRAMID_MERGE)
searchStart = motionFromGBuffer(upscaledLowerLayer);
float4 curMotionEstimation = CalcMotionLayer(texcoord, searchStart, smpGCur2, smpGLast2, UI_ME_MAX_ITERATIONS_PER_LEVEL);
return curMotionEstimation;
}
float4 MotionEstimation1PS(float4 position : SV_Position, float2 texcoord : TEXCOORD ) : SV_Target
{
float4 upscaledLowerLayer = UpscaleMotion(texcoord, smpGCur1, smpGCur2, smpMCur2);
if (UI_ME_LAYER_MAX > 1)
return upscaledLowerLayer;
float2 searchStart = float2(0, 0);
//if (UI_DEBUG_PYRAMID_MERGE)
searchStart = motionFromGBuffer(upscaledLowerLayer);
float4 curMotionEstimation = CalcMotionLayer(texcoord, searchStart, smpGCur1, smpGLast1, UI_ME_MAX_ITERATIONS_PER_LEVEL);
return curMotionEstimation;
}
float4 MotionEstimation0PS(float4 position : SV_Position, float2 texcoord : TEXCOORD ) : SV_Target
{
float4 upscaledLowerLayer = UpscaleMotion(texcoord, smpGCur0, smpGCur1, smpMCur1);
if (UI_ME_LAYER_MAX > 0)
return upscaledLowerLayer;
float2 searchStart = float2(0, 0);
//if (UI_DEBUG_PYRAMID_MERGE)
searchStart = motionFromGBuffer(upscaledLowerLayer);
float4 curMotionEstimation = CalcMotionLayer(texcoord, searchStart, smpGCur0, smpGLast0, UI_ME_MAX_ITERATIONS_PER_LEVEL);
return curMotionEstimation;
}
float4 FinalFilterXPS(float4 position : SV_Position, float2 texcoord : TEXCOORD ) : SV_Target
{
return tex2D(smpMCur0, texcoord);
}
float4 FinalFilterYPS(float4 position : SV_Position, float2 texcoord : TEXCOORD ) : SV_Target
{
return tex2D(smpMotionFilterX, texcoord);
}
float2 MotionOutputPS(float4 position : SV_Position, float2 texcoord : TEXCOORD ) : SV_Target
{
return tex2D(smpMCur0, texcoord).rg;
}
//
float4 OutputPS(float4 position : SV_Position, float2 texcoord : TEXCOORD) : SV_Target
{
float4 returnValue = 0;
//this will be preprocessor later
if (UI_DEBUG_ENABLE)
{
switch (UI_DEBUG_MODE)
{
//Show Grayscale Image
case 0:
{
switch (UI_DEBUG_LAYER)
{
case 0:
returnValue = tex2D(smpGCur0, texcoord).r;
break;
case 1:
returnValue = tex2D(smpGCur1, texcoord).r;
break;
case 2:
returnValue = tex2D(smpGCur2, texcoord).r;
break;
case 3:
returnValue = tex2D(smpGCur3, texcoord).r;
break;
case 4:
returnValue = tex2D(smpGCur4, texcoord).r;
break;
case 5:
returnValue = tex2D(smpGCur5, texcoord).r;
break;
case 6:
returnValue = tex2D(smpGLast6, texcoord).r;
break;
default:
break;
}
}
break;
//Show Depth
case 1:
{
switch (UI_DEBUG_LAYER)
{
case 0:
returnValue = tex2D(smpGCur0, texcoord).g;
break;
case 1:
returnValue = tex2D(smpGCur1, texcoord).g;
break;
case 2:
returnValue = tex2D(smpGCur2, texcoord).g;
break;
case 3:
returnValue = tex2D(smpGCur3, texcoord).g;
break;
case 4:
returnValue = tex2D(smpGCur4, texcoord).g;
break;
case 5:
returnValue = tex2D(smpGCur5, texcoord).g;
break;
case 6:
returnValue = tex2D(smpGCur6, texcoord).g;
break;
default:
break;
}
}
break;
//Show Frame Difference
case 2:
{
switch (UI_DEBUG_LAYER)
{
case 0:
returnValue = abs(tex2D(smpGCur0, texcoord).r - tex2D(smpGLast0, texcoord)).r;
break;
case 1:
returnValue = abs(tex2D(smpGCur1, texcoord).r - tex2D(smpGLast1, texcoord)).r;
break;
case 2:
returnValue = abs(tex2D(smpGCur2, texcoord).r - tex2D(smpGLast2, texcoord)).r;
break;
case 3:
returnValue = abs(tex2D(smpGCur3, texcoord).r - tex2D(smpGLast3, texcoord)).r;
break;
case 4:
returnValue = abs(tex2D(smpGCur4, texcoord).r - tex2D(smpGLast4, texcoord)).r;
break;
case 5:
returnValue = abs(tex2D(smpGCur5, texcoord).r - tex2D(smpGLast5, texcoord)).r;
break;
case 6:
returnValue = abs(tex2D(smpGCur6, texcoord).r - tex2D(smpGLast6, texcoord)).r;
break;
default:
break;
}
}
break;
//Feature Level
case 3:
{
float2 block[BLOCK_AREA];
switch (UI_DEBUG_LAYER)
{
case 0:
getBlock(texcoord, block, smpGCur0);
returnValue = getBlockFeatureLevel(block);
break;
case 1:
getBlock(texcoord, block, smpGCur1);
returnValue = getBlockFeatureLevel(block);
break;
case 2:
getBlock(texcoord, block, smpGCur2);
returnValue = getBlockFeatureLevel(block);
break;
case 3:
getBlock(texcoord, block, smpGCur3);
returnValue = getBlockFeatureLevel(block);
break;
case 4:
getBlock(texcoord, block, smpGCur4);
returnValue = getBlockFeatureLevel(block);
break;
case 5:
getBlock(texcoord, block, smpGCur5);
returnValue = getBlockFeatureLevel(block);
break;
case 6:
getBlock(texcoord, block, smpGCur6);
returnValue = getBlockFeatureLevel(block);
break;
default:
break;
}
}
break;
//Motion
case 4:
{
switch (UI_DEBUG_LAYER)
{
case 0:
returnValue = motionToLgbtq(motionFromGBuffer(tex2D(smpMCur0, texcoord)));
break;
case 1:
returnValue = motionToLgbtq(motionFromGBuffer(tex2D(smpMCur1, texcoord)));
break;
case 2:
returnValue = motionToLgbtq(motionFromGBuffer(tex2D(smpMCur2, texcoord)));
break;
case 3:
returnValue = motionToLgbtq(motionFromGBuffer(tex2D(smpMCur3, texcoord)));
break;
case 4:
returnValue = motionToLgbtq(motionFromGBuffer(tex2D(smpMCur4, texcoord)));
break;
case 5:
returnValue = motionToLgbtq(motionFromGBuffer(tex2D(smpMCur5, texcoord)));
break;
case 6:
returnValue = motionToLgbtq(motionFromGBuffer(tex2D(smpMCur6, texcoord)));
break;
default:
break;
}
}
break;
//Final Output
case 5:
{
returnValue = motionToLgbtq(tex2D(SamplerMotionVectors, texcoord).rg);
}
break;
//Velocity Buffer
case 6:
{
returnValue = float4(((tex2D(SamplerMotionVectors, texcoord).rg * 0.5 * UI_DEBUG_MULT) + 0.5), 0, 0);
}
break;
default:
break;
}
}
else
{
returnValue = tex2D(ReShade::BackBuffer, texcoord);
}
return returnValue;
}
// Technique
technique DRME
{
//Save Frames
pass SaveLastColorPass
{
VertexShader = PostProcessVS;
PixelShader = SaveLastPS;
RenderTarget0 = texCur0;
RenderTarget1 = texLast0;
RenderTarget2 = texGLast0;
//RenderTarget3 = texMotionLast0;
}
pass SaveGray1Pass
{
VertexShader = PostProcessVS;
PixelShader = SaveGray1PS;
RenderTarget0 = texGLast1;
//RenderTarget1 = texMotionLast1;
}
pass SaveGray2Pass
{
VertexShader = PostProcessVS;
PixelShader = SaveGray2PS;
RenderTarget0 = texGLast2;
//RenderTarget1 = texMotionLast2;
}
pass SaveGray3Pass
{
VertexShader = PostProcessVS;
PixelShader = SaveGray3PS;
RenderTarget0 = texGLast3;
//RenderTarget1 = texMotionLast3;
}
pass SaveGray4Pass
{
VertexShader = PostProcessVS;
PixelShader = SaveGray4PS;
RenderTarget0 = texGLast4;
//RenderTarget1 = texMotionLast4;
}
pass SaveGray5Pass
{
VertexShader = PostProcessVS;
PixelShader = SaveGray5PS;
RenderTarget0 = texGLast5;
//RenderTarget1 = texMotionLast5;
}
pass SaveGray6Pass
{
VertexShader = PostProcessVS;
PixelShader = SaveGray6PS;
RenderTarget0 = texGLast6;
//RenderTarget1 = texMotionLast6;
}
//Build gray and motion pyramid
pass MakeGrayPass
{
VertexShader = PostProcessVS;
PixelShader = CurToGrayPS;
RenderTarget = texGCur0;
}
pass DownscaleGray1Pass
{
VertexShader = PostProcessVS;
PixelShader = DownscaleGray1PS;
RenderTarget = texGCur1;
}
pass DownscaleGray2Pass
{
VertexShader = PostProcessVS;
PixelShader = DownscaleGray2PS;
RenderTarget = texGCur2;
}
pass DownscaleGray3Pass
{
VertexShader = PostProcessVS;
PixelShader = DownscaleGray3PS;
RenderTarget = texGCur3;
}
pass DownscaleGray4Pass
{
VertexShader = PostProcessVS;
PixelShader = DownscaleGray4PS;
RenderTarget = texGCur4;
}
pass DownscaleGray5Pass
{
VertexShader = PostProcessVS;
PixelShader = DownscaleGray5PS;
RenderTarget = texGCur5;
}
pass DownscaleGray6Pass
{
VertexShader = PostProcessVS;
PixelShader = DownscaleGray6PS;
RenderTarget = texGCur6;
}
//Estimate Motion
/*pass MotionEstimation7Pass
{
VertexShader = PostProcessVS;
PixelShader = MotionEstimation7PS;
RenderTarget = texMotionCur7;
}*/
pass MotionEstimation6Pass
{
VertexShader = PostProcessVS;
PixelShader = MotionEstimation6PS;
RenderTarget = texMotionCur6;
}
pass MotionEstimation5Pass
{
VertexShader = PostProcessVS;
PixelShader = MotionEstimation5PS;
RenderTarget = texMotionCur5;
}
pass MotionEstimation4Pass
{
VertexShader = PostProcessVS;
PixelShader = MotionEstimation4PS;
RenderTarget = texMotionCur4;
}
pass MotionEstimation3Pass
{
VertexShader = PostProcessVS;
PixelShader = MotionEstimation3PS;
RenderTarget = texMotionCur3;
}
pass MotionEstimation2Pass
{
VertexShader = PostProcessVS;
PixelShader = MotionEstimation2PS;
RenderTarget = texMotionCur2;
}
pass MotionEstimation1Pass
{
VertexShader = PostProcessVS;
PixelShader = MotionEstimation1PS;
RenderTarget = texMotionCur1;
}
pass MotionEstimation0Pass
{
VertexShader = PostProcessVS;
PixelShader = MotionEstimation0PS;
RenderTarget = texMotionCur0;
}
pass FinalFilterXPass
{
VertexShader = PostProcessVS;
PixelShader = FinalFilterXPS;
RenderTarget = texMotionFilterX;
}
pass FinalFilterXPass
{
VertexShader = PostProcessVS;
PixelShader = FinalFilterYPS;
RenderTarget = texMotionCur0;
}
pass MotionOutputPass
{
VertexShader = PostProcessVS;
PixelShader = MotionOutputPS;
RenderTarget = texMotionVectors;
}
//Output
pass OutputPass
{
VertexShader = PostProcessVS;
PixelShader = OutputPS;
}
}