-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathtest_shading.cpp
More file actions
1919 lines (1551 loc) · 75.5 KB
/
Copy pathtest_shading.cpp
File metadata and controls
1919 lines (1551 loc) · 75.5 KB
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
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#include "test_common.h"
#include <cstdint>
#include <cstring>
#include <algorithm>
#include <chrono>
#include <fstream>
#include "../Ray.h"
#include "../internal/TextureUtils.h"
#include "test_scene.h"
#include "thread_pool.h"
#include "utils.h"
extern bool g_determine_sample_count;
extern bool g_minimal_output;
extern bool g_nohwrt;
extern bool g_nodx;
std::mutex g_stdout_mtx;
extern int g_validation_level;
template <typename MatDesc>
void run_material_test(const char *arch_list[], std::string_view preferred_device, const char *test_name,
const MatDesc &mat_desc, const int sample_count, const double min_psnr, const int pix_thres,
const eDenoiseMethod denoise = eDenoiseMethod::None, const bool partial = false,
const char *textures[] = nullptr, const eTestScene test_scene = eTestScene::Standard) {
run_material_test(arch_list, preferred_device, test_name, mat_desc, sample_count, sample_count, 0.0f, min_psnr,
pix_thres, denoise, partial, false, textures, test_scene);
}
template <typename MatDesc>
void run_material_test(const char *arch_list[], std::string_view preferred_device, const char *test_name,
const MatDesc &mat_desc, const int min_sample_count, const int max_sample_count,
const float variance_threshold, const double min_psnr, const int pix_thres,
const eDenoiseMethod denoise = eDenoiseMethod::None, const bool partial = false,
const bool caching = false, const char *textures[] = nullptr,
const eTestScene test_scene = eTestScene::Standard) {
using namespace std::chrono;
using namespace Ray;
char name_buf[1024];
snprintf(name_buf, sizeof(name_buf), "test_data/%s/ref.tga", test_name);
int test_img_w, test_img_h;
const auto test_img = LoadTGA(name_buf, test_img_w, test_img_h);
require_return(!test_img.empty());
settings_t s;
s.w = test_img_w;
s.h = test_img_h;
s.preferred_device = preferred_device;
s.validation_level = g_validation_level;
s.use_spatial_cache = caching;
ThreadPool threads(std::thread::hardware_concurrency());
const int DiffThres = 32;
for (const char **arch = arch_list; *arch; ++arch) {
const auto rt = RendererTypeFromName(*arch);
if (g_nodx && rt == eRendererType::DirectX12) {
continue;
}
for (const bool use_hwrt : {false, true}) {
if (use_hwrt && g_nohwrt) {
continue;
}
s.use_hwrt = use_hwrt;
int current_sample_count = max_sample_count;
int failed_count = -1, succeeded_count = 4096;
bool images_match = false, searching = false;
do {
const auto start_time = high_resolution_clock::now();
using namespace std::placeholders;
auto parallel_for =
std::bind(&ThreadPool::ParallelFor<ParallelForFunction>, std::ref(threads), _1, _2, _3);
auto renderer = std::unique_ptr<RendererBase>(CreateRenderer(s, &g_log_err, parallel_for, rt));
if (!renderer || renderer->type() != rt || renderer->is_hwrt() != use_hwrt ||
renderer->is_spatial_caching_enabled() != caching) {
// skip unsupported (we fell back to some other renderer)
break;
}
if (!preferred_device.empty()) {
// make sure we use requested device
if (!require(MatchDeviceNames(renderer->device_name(), preferred_device))) {
std::lock_guard<std::mutex> _(g_stdout_mtx);
printf("Wrong device: %s (%s was requested)\n", renderer->device_name().data(),
preferred_device.data());
return;
}
}
auto scene = std::unique_ptr<SceneBase>(renderer->CreateScene());
setup_test_scene(threads, *scene, min_sample_count, variance_threshold, mat_desc, textures, test_scene);
{ // test Resize robustness
renderer->Resize(test_img_w / 2, test_img_h / 2);
renderer->Resize(test_img_w, test_img_h);
}
snprintf(name_buf, sizeof(name_buf), "Test %-25s", test_name);
schedule_render_jobs(threads, *renderer, scene.get(), s, current_sample_count, denoise, partial,
name_buf);
const color_data_rgba_t pixels = renderer->get_pixels_ref();
auto img_data_u8 = std::make_unique<uint8_t[]>(test_img_w * test_img_h * 3);
auto diff_data_u8 = std::make_unique<uint8_t[]>(test_img_w * test_img_h * 3);
auto mask_data_u8 = std::make_unique<uint8_t[]>(test_img_w * test_img_h * 3);
memset(&mask_data_u8[0], 0, test_img_w * test_img_h * 3);
double mse = 0.0;
int error_pixels = 0;
for (int j = 0; j < test_img_h; j++) {
for (int i = 0; i < test_img_w; i++) {
const color_rgba_t &p = pixels.ptr[j * pixels.pitch + i];
const auto r = uint8_t(p.v[0] * 255);
const auto g = uint8_t(p.v[1] * 255);
const auto b = uint8_t(p.v[2] * 255);
img_data_u8[3 * (j * test_img_w + i) + 0] = r;
img_data_u8[3 * (j * test_img_w + i) + 1] = g;
img_data_u8[3 * (j * test_img_w + i) + 2] = b;
const uint8_t diff_r = std::abs(r - test_img[4 * (j * test_img_w + i) + 0]);
const uint8_t diff_g = std::abs(g - test_img[4 * (j * test_img_w + i) + 1]);
const uint8_t diff_b = std::abs(b - test_img[4 * (j * test_img_w + i) + 2]);
diff_data_u8[3 * (j * test_img_w + i) + 0] = diff_r;
diff_data_u8[3 * (j * test_img_w + i) + 1] = diff_g;
diff_data_u8[3 * (j * test_img_w + i) + 2] = diff_b;
if (diff_r > DiffThres || diff_g > DiffThres || diff_b > DiffThres) {
mask_data_u8[3 * (j * test_img_w + i) + 0] = 255;
++error_pixels;
}
mse += diff_r * diff_r;
mse += diff_g * diff_g;
mse += diff_b * diff_b;
}
}
mse /= 3.0;
mse /= (test_img_w * test_img_h);
double psnr = -10.0 * std::log10(mse / (255.0 * 255.0));
psnr = std::floor(psnr * 100.0) / 100.0;
const double test_duration_m =
duration<double>(high_resolution_clock::now() - start_time).count() / 60.0;
{
std::lock_guard<std::mutex> _(g_stdout_mtx);
if (g_minimal_output) {
printf("\r%s (%6s, %s): %.1f%% ", name_buf, RendererTypeName(rt).data(),
s.use_hwrt ? "HWRT" : "SWRT", 100.0);
}
printf("(PSNR: %.2f/%.2f dB, Fireflies: %i/%i, Time: %.2fm)\n", psnr, min_psnr, error_pixels,
pix_thres, test_duration_m);
fflush(stdout);
}
std::string type(RendererTypeName(rt));
if (use_hwrt) {
type += "_HWRT";
}
snprintf(name_buf, sizeof(name_buf), "test_data/%s/%s_out.tga", test_name, type.c_str());
WriteTGA(&img_data_u8[0], test_img_w, test_img_h, 3, name_buf);
snprintf(name_buf, sizeof(name_buf), "test_data/%s/%s_diff.tga", test_name, type.c_str());
WriteTGA(&diff_data_u8[0], test_img_w, test_img_h, 3, name_buf);
snprintf(name_buf, sizeof(name_buf), "test_data/%s/%s_mask.tga", test_name, type.c_str());
WriteTGA(&mask_data_u8[0], test_img_w, test_img_h, 3, name_buf);
images_match = (psnr >= min_psnr) && (error_pixels <= pix_thres);
require(images_match || searching);
if (!images_match) {
failed_count = std::max(failed_count, current_sample_count);
if (succeeded_count != 4096) {
current_sample_count = (failed_count + succeeded_count) / 2;
} else {
current_sample_count *= 2;
}
} else {
succeeded_count = std::min(succeeded_count, current_sample_count);
current_sample_count = (failed_count + succeeded_count) / 2;
}
if (searching) {
std::lock_guard<std::mutex> _(g_stdout_mtx);
printf("Current_sample_count = %i (%i - %i)\n", current_sample_count, failed_count,
succeeded_count);
}
searching |= !images_match;
} while (g_determine_sample_count && searching && (succeeded_count - failed_count) > 1);
if (g_determine_sample_count && searching && succeeded_count != max_sample_count) {
std::lock_guard<std::mutex> _(g_stdout_mtx);
printf("Required sample count for %s: %i\n", test_name, succeeded_count);
}
}
}
}
void assemble_material_test_images(const char *arch_list[]) {
using namespace Ray;
static const int ImgCountW = 5;
static const char *test_names[][ImgCountW] = {
{"oren_mat0", "oren_mat1", "oren_mat2", "diff_mat0", "diff_mat1"},
{"diff_mat2", "sheen_mat0", "sheen_mat1", "sheen_mat2", "sheen_mat3"},
{"glossy_mat0", "glossy_mat1", "glossy_mat2", "spec_mat0", "spec_mat1"},
{"spec_mat2", "aniso_mat0", "aniso_mat1", "aniso_mat2", "aniso_mat3"},
{"aniso_mat4", "aniso_mat5", "aniso_mat6", "aniso_mat7", "metal_mat0"},
{"metal_mat1", "metal_mat2", "plastic_mat0", "plastic_mat1", "plastic_mat2"},
{"tint_mat0", "tint_mat1", "tint_mat2", "emit_mat0", "emit_mat1"},
{"coat_mat0", "coat_mat1", "coat_mat2", "refr_mis0", "refr_mis1"},
{"refr_mat0", "refr_mat1", "refr_mat2", "refr_mat3", "trans_mat5"},
{"trans_mat0", "trans_mat1", "trans_mat2", "trans_mat3", "trans_mat4"},
{"alpha_mat0", "alpha_mat1", "alpha_mat2", "alpha_mat3", "alpha_mat4"},
{"complex_mat0", "complex_mat1", "complex_mat2", "complex_mat3", "complex_mat4"},
{"complex_mat5", "complex_mat5_mesh_lights", "complex_mat5_sphere_light", "complex_mat5_sun_light",
"complex_mat5_hdr_light"},
{"complex_mat6", "complex_mat6_mesh_lights", "complex_mat6_sphere_light", "complex_mat6_hdr_light"},
{"complex_mat5_regions", "complex_mat5_dof", "complex_mat5_spot_light", "complex_mat6_dof",
"complex_mat6_spot_light"},
{"refr_mis2", "complex_mat5_nlm_filter", "complex_mat5_adaptive", "complex_mat5_clipped",
"complex_mat6_nlm_filter"},
{"complex_mat5_unet_filter", "complex_mat6_unet_filter", "complex_mat5_dir_light", "complex_mat6_dir_light",
"complex_mat5_moon_light"}};
const int ImgCountH = sizeof(test_names) / sizeof(test_names[0]);
const int OutImageW = 256 * ImgCountW;
const int OutImageH = 256 * ImgCountH;
auto material_refs = std::make_unique<uint8_t[]>(OutImageH * OutImageW * 4);
auto material_imgs = std::make_unique<uint8_t[]>(OutImageH * OutImageW * 4);
auto material_masks = std::make_unique<uint8_t[]>(OutImageH * OutImageW * 4);
memset(material_refs.get(), 0, OutImageH * OutImageW * 4);
memset(material_imgs.get(), 0, OutImageH * OutImageW * 4);
memset(material_masks.get(), 0, OutImageH * OutImageW * 4);
int font_img_w, font_img_h;
const auto font_img = LoadTGA("test_data/font.tga", font_img_w, font_img_h);
auto blit_chars_to_alpha = [&](uint8_t out_img[], const int x, const int y, const char *str) {
const int GlyphH = font_img_h;
const int GlyphW = (GlyphH / 2);
int cur_offset_x = x;
while (*str) {
const int glyph_index = int(*str) - 32;
for (int j = 0; j < GlyphH; ++j) {
for (int i = 0; i < GlyphW; ++i) {
const uint8_t val = font_img[4 * (j * font_img_w + i + glyph_index * GlyphW) + 0];
out_img[4 * ((y + j) * OutImageW + cur_offset_x + i) + 3] = val;
}
}
cur_offset_x += GlyphW;
++str;
}
};
char name_buf[1024];
for (const char **arch = arch_list; *arch; ++arch) {
std::string type = *arch;
for (const bool hwrt : {false, true}) {
const auto rt = RendererTypeFromName(type.c_str());
if (hwrt) {
if (!RendererSupportsHWRT(rt)) {
continue;
}
type += "_HWRT";
}
bool found_at_least_one_image = false;
for (int j = 0; j < ImgCountH; ++j) {
for (int i = 0; i < ImgCountW && test_names[j][i]; ++i) {
{ // reference image
snprintf(name_buf, sizeof(name_buf), "test_data/%s/ref.tga", test_names[j][i]);
int test_img_w, test_img_h;
const auto img_ref = LoadTGA(name_buf, test_img_w, test_img_h);
if (!img_ref.empty()) {
for (int k = 0; k < test_img_h; ++k) {
memcpy(&material_refs[((j * 256 + k) * OutImageW + i * 256) * 4],
&img_ref[k * test_img_w * 4], test_img_w * 4);
}
}
blit_chars_to_alpha(material_refs.get(), i * 256, j * 256, test_names[j][i]);
}
{ // test output
snprintf(name_buf, sizeof(name_buf), "test_data/%s/%s_out.tga", test_names[j][i], type.c_str());
int test_img_w, test_img_h;
const auto test_img = LoadTGA(name_buf, test_img_w, test_img_h);
if (!test_img.empty()) {
for (int k = 0; k < test_img_h; ++k) {
memcpy(&material_imgs[((j * 256 + k) * OutImageW + i * 256) * 4],
&test_img[k * test_img_w * 4], test_img_w * 4);
}
found_at_least_one_image = true;
}
blit_chars_to_alpha(material_imgs.get(), i * 256, j * 256, test_names[j][i]);
}
{ // error mask
snprintf(name_buf, sizeof(name_buf), "test_data/%s/%s_mask.tga", test_names[j][i],
type.c_str());
int test_img_w, test_img_h;
const auto test_img = LoadTGA(name_buf, test_img_w, test_img_h);
if (!test_img.empty()) {
for (int k = 0; k < test_img_h; ++k) {
memcpy(&material_masks[((j * 256 + k) * OutImageW + i * 256) * 4],
&test_img[k * test_img_w * 4], test_img_w * 4);
}
}
blit_chars_to_alpha(material_masks.get(), i * 256, j * 256, test_names[j][i]);
}
}
}
if (found_at_least_one_image) {
snprintf(name_buf, sizeof(name_buf), "test_data/material_%s_imgs.tga", type.c_str());
WriteTGA(material_imgs.get(), OutImageW, OutImageH, 4, name_buf);
snprintf(name_buf, sizeof(name_buf), "test_data/material_%s_masks.tga", type.c_str());
WriteTGA(material_masks.get(), OutImageW, OutImageH, 4, name_buf);
}
}
}
WriteTGA(material_refs.get(), OutImageW, OutImageH, 4, "test_data/material_refs.tga");
}
const double DefaultMinPSNR = 30.0;
const double FastMinPSNR = 28.0;
const double VeryFastMinPSNR = 25.0;
//
// Oren-nayar material tests
//
void test_oren_mat0(const char *arch_list[], std::string_view preferred_device) {
const int SampleCount = 11;
const int PixThres = 394;
Ray::shading_node_desc_t desc;
desc.type = Ray::eShadingNode::Diffuse;
desc.base_color[0] = 0.5f;
desc.base_color[1] = 0.0f;
desc.base_color[2] = 0.0f;
run_material_test(arch_list, preferred_device, "oren_mat0", desc, SampleCount, DefaultMinPSNR, PixThres);
}
void test_oren_mat1(const char *arch_list[], std::string_view preferred_device) {
const int SampleCount = 12;
const int PixThres = 308;
Ray::shading_node_desc_t desc;
desc.type = Ray::eShadingNode::Diffuse;
desc.base_color[0] = 0.0f;
desc.base_color[1] = 0.5f;
desc.base_color[2] = 0.5f;
desc.roughness = 0.5f;
run_material_test(arch_list, preferred_device, "oren_mat1", desc, SampleCount, DefaultMinPSNR, PixThres);
}
void test_oren_mat2(const char *arch_list[], std::string_view preferred_device) {
const int SampleCount = 12;
const double MinPSNR = 30.7;
const int PixThres = 390;
Ray::shading_node_desc_t desc;
desc.type = Ray::eShadingNode::Diffuse;
desc.base_color[0] = 0.0f;
desc.base_color[1] = 0.0f;
desc.base_color[2] = 0.5f;
desc.roughness = 1.0f;
run_material_test(arch_list, preferred_device, "oren_mat2", desc, SampleCount, MinPSNR, PixThres);
}
//
// Diffuse material tests
//
void test_diff_mat0(const char *arch_list[], std::string_view preferred_device) {
const int SampleCount = 10;
const int PixThres = 330;
Ray::principled_mat_desc_t desc;
desc.base_color[0] = 0.5f;
desc.base_color[1] = 0.0f;
desc.base_color[2] = 0.0f;
desc.roughness = 0.0f;
desc.specular = 0.0f;
run_material_test(arch_list, preferred_device, "diff_mat0", desc, SampleCount, DefaultMinPSNR, PixThres);
}
void test_diff_mat1(const char *arch_list[], std::string_view preferred_device) {
const int SampleCount = 12;
const double MinPSNR = 30.5;
const int PixThres = 230;
Ray::principled_mat_desc_t desc;
desc.base_color[0] = 0.0f;
desc.base_color[1] = 0.5f;
desc.base_color[2] = 0.5f;
desc.roughness = 0.5f;
desc.specular = 0.0f;
run_material_test(arch_list, preferred_device, "diff_mat1", desc, SampleCount, MinPSNR, PixThres);
}
void test_diff_mat2(const char *arch_list[], std::string_view preferred_device) {
const int SampleCount = 12;
const double MinPSNR = 30.9;
const int PixThres = 255;
Ray::principled_mat_desc_t desc;
desc.base_color[0] = 0.0f;
desc.base_color[1] = 0.0f;
desc.base_color[2] = 0.5f;
desc.roughness = 1.0f;
desc.specular = 0.0f;
run_material_test(arch_list, preferred_device, "diff_mat2", desc, SampleCount, MinPSNR, PixThres);
}
//
// Sheen material tests
//
void test_sheen_mat0(const char *arch_list[], std::string_view preferred_device) {
const int SampleCount = 10;
const int PixThres = 230;
Ray::principled_mat_desc_t mat_desc;
mat_desc.base_color[0] = 0.0f;
mat_desc.base_color[1] = 0.0f;
mat_desc.base_color[2] = 0.0f;
mat_desc.roughness = 0.0f;
mat_desc.specular = 0.0f;
mat_desc.sheen = 0.5f;
mat_desc.sheen_tint = 0.0f;
run_material_test(arch_list, preferred_device, "sheen_mat0", mat_desc, SampleCount, DefaultMinPSNR, PixThres);
}
void test_sheen_mat1(const char *arch_list[], std::string_view preferred_device) {
const int SampleCount = 12;
const int PixThres = 155;
Ray::principled_mat_desc_t mat_desc;
mat_desc.base_color[0] = 0.0f;
mat_desc.base_color[1] = 0.0f;
mat_desc.base_color[2] = 0.0f;
mat_desc.roughness = 0.0f;
mat_desc.specular = 0.0f;
mat_desc.sheen = 1.0f;
mat_desc.sheen_tint = 0.0f;
run_material_test(arch_list, preferred_device, "sheen_mat1", mat_desc, SampleCount, DefaultMinPSNR, PixThres);
}
void test_sheen_mat2(const char *arch_list[], std::string_view preferred_device) {
const int SampleCount = 10;
const int PixThres = 275;
Ray::principled_mat_desc_t mat_desc;
mat_desc.base_color[0] = 0.1f;
mat_desc.base_color[1] = 0.0f;
mat_desc.base_color[2] = 0.1f;
mat_desc.roughness = 0.0f;
mat_desc.specular = 0.0f;
mat_desc.sheen = 1.0f;
mat_desc.sheen_tint = 0.0f;
run_material_test(arch_list, preferred_device, "sheen_mat2", mat_desc, SampleCount, DefaultMinPSNR, PixThres);
}
void test_sheen_mat3(const char *arch_list[], std::string_view preferred_device) {
const int SampleCount = 12;
const double MinPSNR = 30.5;
const int PixThres = 295;
Ray::principled_mat_desc_t mat_desc;
mat_desc.base_color[0] = 0.1f;
mat_desc.base_color[1] = 0.0f;
mat_desc.base_color[2] = 0.1f;
mat_desc.roughness = 0.0f;
mat_desc.specular = 0.0f;
mat_desc.sheen = 1.0f;
mat_desc.sheen_tint = 1.0f;
run_material_test(arch_list, preferred_device, "sheen_mat3", mat_desc, SampleCount, MinPSNR, PixThres);
}
//
// Glossy material tests
//
void test_glossy_mat0(const char *arch_list[], std::string_view preferred_device) {
const int SampleCount = 440;
const int PixThres = 375;
Ray::shading_node_desc_t node_desc;
node_desc.type = Ray::eShadingNode::Glossy;
node_desc.base_color[0] = 1.0f;
node_desc.base_color[1] = 1.0f;
node_desc.base_color[2] = 1.0f;
node_desc.roughness = 0.0f;
run_material_test(arch_list, preferred_device, "glossy_mat0", node_desc, SampleCount, DefaultMinPSNR, PixThres);
}
void test_glossy_mat1(const char *arch_list[], std::string_view preferred_device) {
const int SampleCount = 54;
const int PixThres = 350;
Ray::shading_node_desc_t node_desc;
node_desc.type = Ray::eShadingNode::Glossy;
node_desc.base_color[0] = 1.0f;
node_desc.base_color[1] = 1.0f;
node_desc.base_color[2] = 1.0f;
node_desc.roughness = 0.5f;
run_material_test(arch_list, preferred_device, "glossy_mat1", node_desc, SampleCount, DefaultMinPSNR, PixThres);
}
void test_glossy_mat2(const char *arch_list[], std::string_view preferred_device) {
const int SampleCount = 12;
const int PixThres = 140;
Ray::shading_node_desc_t node_desc;
node_desc.type = Ray::eShadingNode::Glossy;
node_desc.base_color[0] = 1.0f;
node_desc.base_color[1] = 1.0f;
node_desc.base_color[2] = 1.0f;
node_desc.roughness = 1.0f;
run_material_test(arch_list, preferred_device, "glossy_mat2", node_desc, SampleCount, DefaultMinPSNR, PixThres);
}
//
// Specular material tests
//
void test_spec_mat0(const char *arch_list[], std::string_view preferred_device) {
const int SampleCount = 440;
const int PixThres = 375;
Ray::principled_mat_desc_t spec_mat_desc;
spec_mat_desc.base_color[0] = 1.0f;
spec_mat_desc.base_color[1] = 1.0f;
spec_mat_desc.base_color[2] = 1.0f;
spec_mat_desc.roughness = 0.0f;
spec_mat_desc.metallic = 1.0f;
run_material_test(arch_list, preferred_device, "spec_mat0", spec_mat_desc, SampleCount, DefaultMinPSNR, PixThres);
}
void test_spec_mat1(const char *arch_list[], std::string_view preferred_device) {
const int SampleCount = 54;
const int PixThres = 350;
Ray::principled_mat_desc_t spec_mat_desc;
spec_mat_desc.base_color[0] = 1.0f;
spec_mat_desc.base_color[1] = 1.0f;
spec_mat_desc.base_color[2] = 1.0f;
spec_mat_desc.roughness = 0.5f;
spec_mat_desc.metallic = 1.0f;
run_material_test(arch_list, preferred_device, "spec_mat1", spec_mat_desc, SampleCount, DefaultMinPSNR, PixThres);
}
void test_spec_mat2(const char *arch_list[], std::string_view preferred_device) {
const int SampleCount = 12;
const int PixThres = 140;
Ray::principled_mat_desc_t spec_mat_desc;
spec_mat_desc.base_color[0] = 1.0f;
spec_mat_desc.base_color[1] = 1.0f;
spec_mat_desc.base_color[2] = 1.0f;
spec_mat_desc.roughness = 1.0f;
spec_mat_desc.metallic = 1.0f;
run_material_test(arch_list, preferred_device, "spec_mat2", spec_mat_desc, SampleCount, DefaultMinPSNR, PixThres);
}
//
// Anisotropic material tests
//
void test_aniso_mat0(const char *arch_list[], std::string_view preferred_device) {
const int SampleCount = 326;
const int PixThres = 490;
Ray::principled_mat_desc_t spec_mat_desc;
spec_mat_desc.base_color[0] = 1.0f;
spec_mat_desc.base_color[1] = 1.0f;
spec_mat_desc.base_color[2] = 1.0f;
spec_mat_desc.roughness = 0.25f;
spec_mat_desc.metallic = 1.0f;
spec_mat_desc.anisotropic = 0.25f;
spec_mat_desc.anisotropic_rotation = 0.0f;
run_material_test(arch_list, preferred_device, "aniso_mat0", spec_mat_desc, SampleCount, DefaultMinPSNR, PixThres);
}
void test_aniso_mat1(const char *arch_list[], std::string_view preferred_device) {
const int SampleCount = 334;
const int PixThres = 465;
Ray::principled_mat_desc_t spec_mat_desc;
spec_mat_desc.base_color[0] = 1.0f;
spec_mat_desc.base_color[1] = 1.0f;
spec_mat_desc.base_color[2] = 1.0f;
spec_mat_desc.roughness = 0.25f;
spec_mat_desc.metallic = 1.0f;
spec_mat_desc.anisotropic = 0.5f;
spec_mat_desc.anisotropic_rotation = 0.0f;
run_material_test(arch_list, preferred_device, "aniso_mat1", spec_mat_desc, SampleCount, DefaultMinPSNR, PixThres);
}
void test_aniso_mat2(const char *arch_list[], std::string_view preferred_device) {
const int SampleCount = 336;
const int PixThres = 455;
Ray::principled_mat_desc_t spec_mat_desc;
spec_mat_desc.base_color[0] = 1.0f;
spec_mat_desc.base_color[1] = 1.0f;
spec_mat_desc.base_color[2] = 1.0f;
spec_mat_desc.roughness = 0.25f;
spec_mat_desc.metallic = 1.0f;
spec_mat_desc.anisotropic = 0.75f;
spec_mat_desc.anisotropic_rotation = 0.0f;
run_material_test(arch_list, preferred_device, "aniso_mat2", spec_mat_desc, SampleCount, DefaultMinPSNR, PixThres);
}
void test_aniso_mat3(const char *arch_list[], std::string_view preferred_device) {
const int SampleCount = 352;
const int PixThres = 475;
Ray::principled_mat_desc_t spec_mat_desc;
spec_mat_desc.base_color[0] = 1.0f;
spec_mat_desc.base_color[1] = 1.0f;
spec_mat_desc.base_color[2] = 1.0f;
spec_mat_desc.roughness = 0.25f;
spec_mat_desc.metallic = 1.0f;
spec_mat_desc.anisotropic = 1.0f;
spec_mat_desc.anisotropic_rotation = 0.0f;
run_material_test(arch_list, preferred_device, "aniso_mat3", spec_mat_desc, SampleCount, DefaultMinPSNR, PixThres);
}
void test_aniso_mat4(const char *arch_list[], std::string_view preferred_device) {
const int SampleCount = 354;
const int PixThres = 505;
Ray::principled_mat_desc_t spec_mat_desc;
spec_mat_desc.base_color[0] = 1.0f;
spec_mat_desc.base_color[1] = 1.0f;
spec_mat_desc.base_color[2] = 1.0f;
spec_mat_desc.roughness = 0.25f;
spec_mat_desc.metallic = 1.0f;
spec_mat_desc.anisotropic = 1.0f;
spec_mat_desc.anisotropic_rotation = 0.125f;
run_material_test(arch_list, preferred_device, "aniso_mat4", spec_mat_desc, SampleCount, DefaultMinPSNR, PixThres);
}
void test_aniso_mat5(const char *arch_list[], std::string_view preferred_device) {
const int SampleCount = 310;
const int PixThres = 540;
Ray::principled_mat_desc_t spec_mat_desc;
spec_mat_desc.base_color[0] = 1.0f;
spec_mat_desc.base_color[1] = 1.0f;
spec_mat_desc.base_color[2] = 1.0f;
spec_mat_desc.roughness = 0.25f;
spec_mat_desc.metallic = 1.0f;
spec_mat_desc.anisotropic = 1.0f;
spec_mat_desc.anisotropic_rotation = 0.25f;
run_material_test(arch_list, preferred_device, "aniso_mat5", spec_mat_desc, SampleCount, DefaultMinPSNR, PixThres);
}
void test_aniso_mat6(const char *arch_list[], std::string_view preferred_device) {
const int SampleCount = 340;
const int PixThres = 510;
Ray::principled_mat_desc_t spec_mat_desc;
spec_mat_desc.base_color[0] = 1.0f;
spec_mat_desc.base_color[1] = 1.0f;
spec_mat_desc.base_color[2] = 1.0f;
spec_mat_desc.roughness = 0.25f;
spec_mat_desc.metallic = 1.0f;
spec_mat_desc.anisotropic = 1.0f;
spec_mat_desc.anisotropic_rotation = 0.375f;
run_material_test(arch_list, preferred_device, "aniso_mat6", spec_mat_desc, SampleCount, DefaultMinPSNR, PixThres);
}
void test_aniso_mat7(const char *arch_list[], std::string_view preferred_device) {
const int SampleCount = 352;
const int PixThres = 505;
Ray::principled_mat_desc_t spec_mat_desc;
spec_mat_desc.base_color[0] = 1.0f;
spec_mat_desc.base_color[1] = 1.0f;
spec_mat_desc.base_color[2] = 1.0f;
spec_mat_desc.roughness = 0.25f;
spec_mat_desc.metallic = 1.0f;
spec_mat_desc.anisotropic = 1.0f;
spec_mat_desc.anisotropic_rotation = 0.5f;
run_material_test(arch_list, preferred_device, "aniso_mat7", spec_mat_desc, SampleCount, DefaultMinPSNR, PixThres);
}
//
// Metal material tests
//
void test_metal_mat0(const char *arch_list[], std::string_view preferred_device) {
const int SampleCount = 86;
const int PixThres = 1110;
Ray::principled_mat_desc_t metal_mat_desc;
metal_mat_desc.base_color[0] = 0.0f;
metal_mat_desc.base_color[1] = 0.5f;
metal_mat_desc.base_color[2] = 0.5f;
metal_mat_desc.roughness = 0.0f;
metal_mat_desc.metallic = 1.0f;
run_material_test(arch_list, preferred_device, "metal_mat0", metal_mat_desc, SampleCount, DefaultMinPSNR, PixThres);
}
void test_metal_mat1(const char *arch_list[], std::string_view preferred_device) {
const int SampleCount = 16;
const int PixThres = 350;
Ray::principled_mat_desc_t metal_mat_desc;
metal_mat_desc.base_color[0] = 0.5f;
metal_mat_desc.base_color[1] = 0.0f;
metal_mat_desc.base_color[2] = 0.5f;
metal_mat_desc.roughness = 0.5f;
metal_mat_desc.metallic = 1.0f;
run_material_test(arch_list, preferred_device, "metal_mat1", metal_mat_desc, SampleCount, DefaultMinPSNR, PixThres);
}
void test_metal_mat2(const char *arch_list[], std::string_view preferred_device) {
const int SampleCount = 10;
const double MinPSNR = 30.6;
const int PixThres = 255;
Ray::principled_mat_desc_t metal_mat_desc;
metal_mat_desc.base_color[0] = 0.5f;
metal_mat_desc.base_color[1] = 0.0f;
metal_mat_desc.base_color[2] = 0.0f;
metal_mat_desc.roughness = 1.0f;
metal_mat_desc.metallic = 1.0f;
run_material_test(arch_list, preferred_device, "metal_mat2", metal_mat_desc, SampleCount, MinPSNR, PixThres);
}
//
// Plastic material tests
//
void test_plastic_mat0(const char *arch_list[], std::string_view preferred_device) {
const int SampleCount = 30;
const int PixThres = 910;
Ray::principled_mat_desc_t plastic_mat_desc;
plastic_mat_desc.base_color[0] = 0.0f;
plastic_mat_desc.base_color[1] = 0.0f;
plastic_mat_desc.base_color[2] = 0.5f;
plastic_mat_desc.roughness = 0.0f;
run_material_test(arch_list, preferred_device, "plastic_mat0", plastic_mat_desc, SampleCount, DefaultMinPSNR,
PixThres);
}
void test_plastic_mat1(const char *arch_list[], std::string_view preferred_device) {
const int SampleCount = 19;
const int PixThres = 210;
Ray::principled_mat_desc_t plastic_mat_desc;
plastic_mat_desc.base_color[0] = 0.0f;
plastic_mat_desc.base_color[1] = 0.5f;
plastic_mat_desc.base_color[2] = 0.0f;
plastic_mat_desc.roughness = 0.5f;
run_material_test(arch_list, preferred_device, "plastic_mat1", plastic_mat_desc, SampleCount, DefaultMinPSNR,
PixThres);
}
void test_plastic_mat2(const char *arch_list[], std::string_view preferred_device) {
const int SampleCount = 14;
const int PixThres = 275;
Ray::principled_mat_desc_t plastic_mat_desc;
plastic_mat_desc.base_color[0] = 0.0f;
plastic_mat_desc.base_color[1] = 0.5f;
plastic_mat_desc.base_color[2] = 0.5f;
plastic_mat_desc.roughness = 1.0f;
run_material_test(arch_list, preferred_device, "plastic_mat2", plastic_mat_desc, SampleCount, DefaultMinPSNR,
PixThres);
}
//
// Tint material tests
//
void test_tint_mat0(const char *arch_list[], std::string_view preferred_device) {
const int SampleCount = 28;
const int PixThres = 1120;
Ray::principled_mat_desc_t spec_mat_desc;
spec_mat_desc.base_color[0] = 0.5f;
spec_mat_desc.base_color[1] = 0.0f;
spec_mat_desc.base_color[2] = 0.0f;
spec_mat_desc.specular_tint = 1.0f;
spec_mat_desc.roughness = 0.0f;
run_material_test(arch_list, preferred_device, "tint_mat0", spec_mat_desc, SampleCount, DefaultMinPSNR, PixThres);
}
void test_tint_mat1(const char *arch_list[], std::string_view preferred_device) {
const int SampleCount = 27;
const int PixThres = 1630;
Ray::principled_mat_desc_t spec_mat_desc;
spec_mat_desc.base_color[0] = 0.0f;
spec_mat_desc.base_color[1] = 0.0f;
spec_mat_desc.base_color[2] = 0.5f;
spec_mat_desc.specular_tint = 1.0f;
spec_mat_desc.roughness = 0.5f;
run_material_test(arch_list, preferred_device, "tint_mat1", spec_mat_desc, SampleCount, DefaultMinPSNR, PixThres);
}
void test_tint_mat2(const char *arch_list[], std::string_view preferred_device) {
const int SampleCount = 16;
const int PixThres = 410;
Ray::principled_mat_desc_t spec_mat_desc;
spec_mat_desc.base_color[0] = 0.5f;
spec_mat_desc.base_color[1] = 0.0f;
spec_mat_desc.base_color[2] = 0.5f;
spec_mat_desc.specular_tint = 1.0f;
spec_mat_desc.roughness = 1.0f;
run_material_test(arch_list, preferred_device, "tint_mat2", spec_mat_desc, SampleCount, DefaultMinPSNR, PixThres);
}
//
// Emissive material tests
//
void test_emit_mat0(const char *arch_list[], std::string_view preferred_device) {
const int SampleCount = 90;
const int PixThres = 390;
Ray::principled_mat_desc_t mat_desc;
mat_desc.base_color[0] = 1.0f;
mat_desc.base_color[1] = 0.0f;
mat_desc.base_color[2] = 0.0f;
mat_desc.specular = 0.0f;
mat_desc.emission_color[0] = 1.0f;
mat_desc.emission_color[1] = 1.0f;
mat_desc.emission_color[2] = 1.0f;
mat_desc.emission_strength = 0.5f;
run_material_test(arch_list, preferred_device, "emit_mat0", mat_desc, SampleCount, DefaultMinPSNR, PixThres,
eDenoiseMethod::None, false, nullptr, eTestScene::Standard_NoLight);
}
void test_emit_mat1(const char *arch_list[], std::string_view preferred_device) {
const int SampleCount = 158;
const int PixThres = 505;
Ray::principled_mat_desc_t mat_desc;
mat_desc.base_color[0] = 0.0f;
mat_desc.base_color[1] = 1.0f;
mat_desc.base_color[2] = 0.0f;
mat_desc.specular = 0.0f;
mat_desc.emission_color[0] = 1.0f;
mat_desc.emission_color[1] = 1.0f;
mat_desc.emission_color[2] = 1.0f;
mat_desc.emission_strength = 1.0f;
run_material_test(arch_list, preferred_device, "emit_mat1", mat_desc, SampleCount, DefaultMinPSNR, PixThres,
eDenoiseMethod::None, false, nullptr, eTestScene::Standard_NoLight);
}
//
// Clear coat material tests
//
void test_coat_mat0(const char *arch_list[], std::string_view preferred_device) {
const int SampleCount = 10;
const double MinPSNR = 30.55;
const int PixThres = 285;
Ray::principled_mat_desc_t mat_desc;
mat_desc.base_color[0] = 0.0f;
mat_desc.base_color[1] = 0.0f;
mat_desc.base_color[2] = 0.0f;
mat_desc.specular = 0.0f;
mat_desc.clearcoat = 1.0f;
mat_desc.clearcoat_roughness = 0.0f;
run_material_test(arch_list, preferred_device, "coat_mat0", mat_desc, SampleCount, MinPSNR, PixThres);
}
void test_coat_mat1(const char *arch_list[], std::string_view preferred_device) {
const int SampleCount = 12;
const double MinPSNR = 31.75;
const int PixThres = 110;
Ray::principled_mat_desc_t mat_desc;
mat_desc.base_color[0] = 0.0f;
mat_desc.base_color[1] = 0.0f;
mat_desc.base_color[2] = 0.0f;
mat_desc.specular = 0.0f;
mat_desc.clearcoat = 1.0f;
mat_desc.clearcoat_roughness = 0.5f;
run_material_test(arch_list, preferred_device, "coat_mat1", mat_desc, SampleCount, MinPSNR, PixThres);
}
void test_coat_mat2(const char *arch_list[], std::string_view preferred_device) {
const int SampleCount = 10;
const int PixThres = 180;
Ray::principled_mat_desc_t mat_desc;
mat_desc.base_color[0] = 0.0f;
mat_desc.base_color[1] = 0.0f;
mat_desc.base_color[2] = 0.0f;
mat_desc.specular = 0.0f;
mat_desc.clearcoat = 1.0f;
mat_desc.clearcoat_roughness = 1.0f;
run_material_test(arch_list, preferred_device, "coat_mat2", mat_desc, SampleCount, DefaultMinPSNR, PixThres);
}
//
// Refractive material tests
//
void test_refr_mis0(const char *arch_list[], std::string_view preferred_device) {
const int SampleCount = 9;
const double MinPSNR = 30.90;
const int PixThres = 335;
Ray::shading_node_desc_t mat_desc;
mat_desc.type = Ray::eShadingNode::Refractive;
mat_desc.base_color[0] = 1.0f;
mat_desc.base_color[1] = 1.0f;
mat_desc.base_color[2] = 1.0f;
mat_desc.ior = 1.45f;
mat_desc.roughness = 0.0f;
run_material_test(arch_list, preferred_device, "refr_mis0", mat_desc, SampleCount, MinPSNR, PixThres,
eDenoiseMethod::None, false, nullptr, eTestScene::Refraction_Plane);
}
void test_refr_mis1(const char *arch_list[], std::string_view preferred_device) {
const int SampleCount = 13;
const double MinPSNR = 30.65;
const int PixThres = 265;
Ray::shading_node_desc_t mat_desc;