@@ -349,16 +349,11 @@ bool OptiXDevice::load_kernels(const uint kernel_features)
349
349
pipeline_options.pipelineLaunchParamsVariableName = " kernel_params" ; /* See globals.h */
350
350
351
351
pipeline_options.usesPrimitiveTypeFlags = OPTIX_PRIMITIVE_TYPE_FLAGS_TRIANGLE;
352
- if (kernel_features & KERNEL_FEATURE_HAIR) {
353
- if (kernel_features & KERNEL_FEATURE_HAIR_THICK) {
354
- pipeline_options.usesPrimitiveTypeFlags |= OPTIX_PRIMITIVE_TYPE_FLAGS_ROUND_LINEAR |
355
- OPTIX_PRIMITIVE_TYPE_FLAGS_ROUND_CATMULLROM;
356
- }
357
- else {
358
- pipeline_options.usesPrimitiveTypeFlags |= OPTIX_PRIMITIVE_TYPE_FLAGS_CUSTOM;
359
- }
352
+ if (kernel_features & KERNEL_FEATURE_HAIR_THICK) {
353
+ pipeline_options.usesPrimitiveTypeFlags |= OPTIX_PRIMITIVE_TYPE_FLAGS_ROUND_LINEAR |
354
+ OPTIX_PRIMITIVE_TYPE_FLAGS_ROUND_CATMULLROM;
360
355
}
361
- if (kernel_features & KERNEL_FEATURE_POINTCLOUD) {
356
+ if (kernel_features & (KERNEL_FEATURE_HAIR_RIBBON | KERNEL_FEATURE_POINTCLOUD) ) {
362
357
pipeline_options.usesPrimitiveTypeFlags |= OPTIX_PRIMITIVE_TYPE_FLAGS_CUSTOM;
363
358
}
364
359
@@ -435,68 +430,84 @@ bool OptiXDevice::load_kernels(const uint kernel_features)
435
430
group_descs[PG_HITV].hitgroup .moduleAH = optix_module;
436
431
group_descs[PG_HITV].hitgroup .entryFunctionNameAH = " __anyhit__kernel_optix_volume_test" ;
437
432
438
- if (kernel_features & KERNEL_FEATURE_HAIR) {
439
- if (kernel_features & KERNEL_FEATURE_HAIR_THICK) {
440
- /* Built-in thick curve intersection. */
441
- OptixBuiltinISOptions builtin_options = {};
442
- builtin_options.builtinISModuleType = OPTIX_PRIMITIVE_TYPE_ROUND_CATMULLROM;
443
- builtin_options.buildFlags = OPTIX_BUILD_FLAG_PREFER_FAST_TRACE |
444
- OPTIX_BUILD_FLAG_ALLOW_COMPACTION |
445
- OPTIX_BUILD_FLAG_ALLOW_UPDATE;
446
- builtin_options.curveEndcapFlags = OPTIX_CURVE_ENDCAP_DEFAULT; /* Disable end-caps. */
447
- builtin_options.usesMotionBlur = false ;
433
+ OptixProgramGroupDesc ignore_desc = {};
434
+ ignore_desc.kind = OPTIX_PROGRAM_GROUP_KIND_HITGROUP;
435
+ ignore_desc.hitgroup .moduleCH = optix_module;
436
+ ignore_desc.hitgroup .entryFunctionNameCH = " __closesthit__kernel_optix_ignore" ;
437
+ ignore_desc.hitgroup .moduleAH = optix_module;
438
+ ignore_desc.hitgroup .entryFunctionNameAH = " __anyhit__kernel_optix_ignore" ;
439
+
440
+ if (kernel_features & KERNEL_FEATURE_HAIR_THICK) {
441
+ /* Built-in thick curve intersection. */
442
+ OptixBuiltinISOptions builtin_options = {};
443
+ builtin_options.builtinISModuleType = OPTIX_PRIMITIVE_TYPE_ROUND_CATMULLROM;
444
+ builtin_options.buildFlags = OPTIX_BUILD_FLAG_PREFER_FAST_TRACE |
445
+ OPTIX_BUILD_FLAG_ALLOW_COMPACTION | OPTIX_BUILD_FLAG_ALLOW_UPDATE;
446
+ builtin_options.curveEndcapFlags = OPTIX_CURVE_ENDCAP_DEFAULT; /* Disable end-caps. */
447
+ builtin_options.usesMotionBlur = false ;
448
+
449
+ optix_assert (optixBuiltinISModuleGet (
450
+ context, &module_options, &pipeline_options, &builtin_options, &builtin_modules[0 ]));
451
+
452
+ group_descs[PG_HITD].hitgroup .moduleIS = builtin_modules[0 ];
453
+ group_descs[PG_HITD].hitgroup .entryFunctionNameIS = nullptr ;
454
+ group_descs[PG_HITS].hitgroup .moduleIS = builtin_modules[0 ];
455
+ group_descs[PG_HITS].hitgroup .entryFunctionNameIS = nullptr ;
456
+
457
+ if (pipeline_options.usesMotionBlur ) {
458
+ builtin_options.usesMotionBlur = true ;
448
459
449
460
optix_assert (optixBuiltinISModuleGet (
450
- context, &module_options, &pipeline_options, &builtin_options, &builtin_modules[0 ]));
461
+ context, &module_options, &pipeline_options, &builtin_options, &builtin_modules[1 ]));
451
462
452
- group_descs[PG_HITD].hitgroup .moduleIS = builtin_modules[0 ];
453
- group_descs[PG_HITD].hitgroup .entryFunctionNameIS = nullptr ;
454
- group_descs[PG_HITS].hitgroup .moduleIS = builtin_modules[0 ];
455
- group_descs[PG_HITS].hitgroup .entryFunctionNameIS = nullptr ;
463
+ group_descs[PG_HITD_MOTION] = group_descs[PG_HITD];
464
+ group_descs[PG_HITD_MOTION].hitgroup .moduleIS = builtin_modules[1 ];
465
+ group_descs[PG_HITS_MOTION] = group_descs[PG_HITS];
466
+ group_descs[PG_HITS_MOTION].hitgroup .moduleIS = builtin_modules[1 ];
467
+ }
456
468
457
- if (pipeline_options. usesMotionBlur ) {
458
- builtin_options.usesMotionBlur = true ;
469
+ builtin_options. builtinISModuleType = OPTIX_PRIMITIVE_TYPE_ROUND_LINEAR;
470
+ builtin_options.usesMotionBlur = false ;
459
471
460
- optix_assert (optixBuiltinISModuleGet (
461
- context, &module_options, &pipeline_options, &builtin_options, &builtin_modules[1 ]));
472
+ optix_assert (optixBuiltinISModuleGet (
473
+ context, &module_options, &pipeline_options, &builtin_options, &builtin_modules[2 ]));
462
474
463
- group_descs[PG_HITD_MOTION] = group_descs[PG_HITD];
464
- group_descs[PG_HITD_MOTION].hitgroup .moduleIS = builtin_modules[1 ];
465
- group_descs[PG_HITS_MOTION] = group_descs[PG_HITS];
466
- group_descs[PG_HITS_MOTION].hitgroup .moduleIS = builtin_modules[1 ];
467
- }
475
+ group_descs[PG_HITD_CURVE_LINEAR] = group_descs[PG_HITD];
476
+ group_descs[PG_HITD_CURVE_LINEAR].hitgroup .moduleIS = builtin_modules[2 ];
477
+ group_descs[PG_HITS_CURVE_LINEAR] = group_descs[PG_HITS];
478
+ group_descs[PG_HITS_CURVE_LINEAR].hitgroup .moduleIS = builtin_modules[2 ];
479
+ group_descs[PG_HITV_CURVE_LINEAR] = ignore_desc;
480
+ group_descs[PG_HITL_CURVE_LINEAR] = ignore_desc;
468
481
469
- builtin_options. builtinISModuleType = OPTIX_PRIMITIVE_TYPE_ROUND_LINEAR;
470
- builtin_options.usesMotionBlur = false ;
482
+ if (pipeline_options. usesMotionBlur ) {
483
+ builtin_options.usesMotionBlur = true ;
471
484
472
485
optix_assert (optixBuiltinISModuleGet (
473
- context, &module_options, &pipeline_options, &builtin_options, &builtin_modules[2 ]));
474
-
475
- group_descs[PG_HITD_CURVE_LINEAR] = group_descs[PG_HITD];
476
- group_descs[PG_HITD_CURVE_LINEAR].hitgroup .moduleIS = builtin_modules[2 ];
477
- group_descs[PG_HITS_CURVE_LINEAR] = group_descs[PG_HITS];
478
- group_descs[PG_HITS_CURVE_LINEAR].hitgroup .moduleIS = builtin_modules[2 ];
479
-
480
- if (pipeline_options.usesMotionBlur ) {
481
- builtin_options.usesMotionBlur = true ;
482
-
483
- optix_assert (optixBuiltinISModuleGet (
484
- context, &module_options, &pipeline_options, &builtin_options, &builtin_modules[3 ]));
485
-
486
- group_descs[PG_HITD_CURVE_LINEAR_MOTION] = group_descs[PG_HITD_CURVE_LINEAR];
487
- group_descs[PG_HITD_CURVE_LINEAR_MOTION].hitgroup .moduleIS = builtin_modules[3 ];
488
- group_descs[PG_HITS_CURVE_LINEAR_MOTION] = group_descs[PG_HITS_CURVE_LINEAR];
489
- group_descs[PG_HITS_CURVE_LINEAR_MOTION].hitgroup .moduleIS = builtin_modules[3 ];
490
- }
491
- }
492
- else {
493
- /* Custom ribbon intersection. */
494
- group_descs[PG_HITD].hitgroup .moduleIS = optix_module;
495
- group_descs[PG_HITS].hitgroup .moduleIS = optix_module;
496
- group_descs[PG_HITD].hitgroup .entryFunctionNameIS = " __intersection__curve_ribbon" ;
497
- group_descs[PG_HITS].hitgroup .entryFunctionNameIS = " __intersection__curve_ribbon" ;
486
+ context, &module_options, &pipeline_options, &builtin_options, &builtin_modules[3 ]));
487
+
488
+ group_descs[PG_HITD_CURVE_LINEAR_MOTION] = group_descs[PG_HITD_CURVE_LINEAR];
489
+ group_descs[PG_HITD_CURVE_LINEAR_MOTION].hitgroup .moduleIS = builtin_modules[3 ];
490
+ group_descs[PG_HITS_CURVE_LINEAR_MOTION] = group_descs[PG_HITS_CURVE_LINEAR];
491
+ group_descs[PG_HITS_CURVE_LINEAR_MOTION].hitgroup .moduleIS = builtin_modules[3 ];
492
+ group_descs[PG_HITV_CURVE_LINEAR_MOTION] = ignore_desc;
493
+ group_descs[PG_HITL_CURVE_LINEAR_MOTION] = ignore_desc;
498
494
}
499
495
}
496
+ if (kernel_features & KERNEL_FEATURE_HAIR_RIBBON) {
497
+ /* Custom ribbon intersection. */
498
+ group_descs[PG_HITD_CURVE_RIBBON] = group_descs[PG_HITD];
499
+ group_descs[PG_HITD_CURVE_RIBBON].kind = OPTIX_PROGRAM_GROUP_KIND_HITGROUP;
500
+ group_descs[PG_HITD_CURVE_RIBBON].hitgroup .moduleIS = optix_module;
501
+ group_descs[PG_HITD_CURVE_RIBBON].hitgroup .entryFunctionNameIS =
502
+ " __intersection__curve_ribbon" ;
503
+ group_descs[PG_HITS_CURVE_RIBBON] = group_descs[PG_HITS];
504
+ group_descs[PG_HITS_CURVE_RIBBON].kind = OPTIX_PROGRAM_GROUP_KIND_HITGROUP;
505
+ group_descs[PG_HITS_CURVE_RIBBON].hitgroup .moduleIS = optix_module;
506
+ group_descs[PG_HITS_CURVE_RIBBON].hitgroup .entryFunctionNameIS =
507
+ " __intersection__curve_ribbon" ;
508
+ group_descs[PG_HITV_CURVE_RIBBON] = ignore_desc;
509
+ group_descs[PG_HITL_CURVE_RIBBON] = ignore_desc;
510
+ }
500
511
501
512
if (kernel_features & KERNEL_FEATURE_POINTCLOUD) {
502
513
group_descs[PG_HITD_POINTCLOUD] = group_descs[PG_HITD];
@@ -507,6 +518,8 @@ bool OptiXDevice::load_kernels(const uint kernel_features)
507
518
group_descs[PG_HITS_POINTCLOUD].kind = OPTIX_PROGRAM_GROUP_KIND_HITGROUP;
508
519
group_descs[PG_HITS_POINTCLOUD].hitgroup .moduleIS = optix_module;
509
520
group_descs[PG_HITS_POINTCLOUD].hitgroup .entryFunctionNameIS = " __intersection__point" ;
521
+ group_descs[PG_HITV_POINTCLOUD] = ignore_desc;
522
+ group_descs[PG_HITL_POINTCLOUD] = ignore_desc;
510
523
}
511
524
512
525
/* Add hit group for local intersections. */
@@ -647,6 +660,10 @@ bool OptiXDevice::load_kernels(const uint kernel_features)
647
660
trace_css = std::max (trace_css,
648
661
stack_size[PG_HITS_CURVE_LINEAR_MOTION].cssIS +
649
662
stack_size[PG_HITS_CURVE_LINEAR_MOTION].cssAH );
663
+ trace_css = std::max (
664
+ trace_css, stack_size[PG_HITD_CURVE_RIBBON].cssIS + stack_size[PG_HITD_CURVE_RIBBON].cssAH );
665
+ trace_css = std::max (
666
+ trace_css, stack_size[PG_HITS_CURVE_RIBBON].cssIS + stack_size[PG_HITS_CURVE_RIBBON].cssAH );
650
667
trace_css = std::max (
651
668
trace_css, stack_size[PG_HITD_POINTCLOUD].cssIS + stack_size[PG_HITD_POINTCLOUD].cssAH );
652
669
trace_css = std::max (
@@ -678,18 +695,32 @@ bool OptiXDevice::load_kernels(const uint kernel_features)
678
695
if (pipeline_options.usesMotionBlur ) {
679
696
pipeline_groups.push_back (groups[PG_HITD_MOTION]);
680
697
pipeline_groups.push_back (groups[PG_HITS_MOTION]);
698
+ pipeline_groups.push_back (groups[PG_HITV_MOTION]);
699
+ pipeline_groups.push_back (groups[PG_HITL_MOTION]);
681
700
}
682
701
if (kernel_features & KERNEL_FEATURE_HAIR_THICK) {
683
702
pipeline_groups.push_back (groups[PG_HITD_CURVE_LINEAR]);
684
703
pipeline_groups.push_back (groups[PG_HITS_CURVE_LINEAR]);
704
+ pipeline_groups.push_back (groups[PG_HITV_CURVE_LINEAR]);
705
+ pipeline_groups.push_back (groups[PG_HITL_CURVE_LINEAR]);
685
706
if (pipeline_options.usesMotionBlur ) {
686
707
pipeline_groups.push_back (groups[PG_HITD_CURVE_LINEAR_MOTION]);
687
708
pipeline_groups.push_back (groups[PG_HITS_CURVE_LINEAR_MOTION]);
709
+ pipeline_groups.push_back (groups[PG_HITV_CURVE_LINEAR_MOTION]);
710
+ pipeline_groups.push_back (groups[PG_HITL_CURVE_LINEAR_MOTION]);
688
711
}
689
712
}
713
+ if (kernel_features & KERNEL_FEATURE_HAIR_RIBBON) {
714
+ pipeline_groups.push_back (groups[PG_HITD_CURVE_RIBBON]);
715
+ pipeline_groups.push_back (groups[PG_HITS_CURVE_RIBBON]);
716
+ pipeline_groups.push_back (groups[PG_HITV_CURVE_RIBBON]);
717
+ pipeline_groups.push_back (groups[PG_HITL_CURVE_RIBBON]);
718
+ }
690
719
if (kernel_features & KERNEL_FEATURE_POINTCLOUD) {
691
720
pipeline_groups.push_back (groups[PG_HITD_POINTCLOUD]);
692
721
pipeline_groups.push_back (groups[PG_HITS_POINTCLOUD]);
722
+ pipeline_groups.push_back (groups[PG_HITV_POINTCLOUD]);
723
+ pipeline_groups.push_back (groups[PG_HITL_POINTCLOUD]);
693
724
}
694
725
695
726
optix_assert (optixPipelineCreate (context,
@@ -738,6 +769,10 @@ bool OptiXDevice::load_kernels(const uint kernel_features)
738
769
pipeline_groups.push_back (groups[PG_HITS_CURVE_LINEAR_MOTION]);
739
770
}
740
771
}
772
+ if (kernel_features & KERNEL_FEATURE_HAIR_RIBBON) {
773
+ pipeline_groups.push_back (groups[PG_HITD_CURVE_RIBBON]);
774
+ pipeline_groups.push_back (groups[PG_HITS_CURVE_RIBBON]);
775
+ }
741
776
if (kernel_features & KERNEL_FEATURE_POINTCLOUD) {
742
777
pipeline_groups.push_back (groups[PG_HITD_POINTCLOUD]);
743
778
pipeline_groups.push_back (groups[PG_HITS_POINTCLOUD]);
@@ -1671,17 +1706,22 @@ void OptiXDevice::build_bvh(BVH *bvh, Progress &progress, bool refit)
1671
1706
instance.visibilityMask = 0xFF ;
1672
1707
}
1673
1708
1674
- if (ob->get_geometry ()->is_hair () &&
1675
- static_cast <const Hair *>(ob->get_geometry ())->curve_shape != CURVE_RIBBON)
1676
- {
1677
- if (static_cast <const Hair *>(ob->get_geometry ())->curve_shape == CURVE_THICK_LINEAR) {
1709
+ if (ob->get_geometry ()->is_hair ()) {
1710
+ const Hair *hair = static_cast <const Hair *>(ob->get_geometry ());
1711
+ if (hair->curve_shape == CURVE_RIBBON) {
1712
+ instance.sbtOffset = PG_HITD_CURVE_RIBBON - PG_HITD;
1713
+
1714
+ /* Also skip curve ribbons in local trace calls. */
1715
+ instance.visibilityMask |= 4 ;
1716
+ }
1717
+ else if (hair->curve_shape == CURVE_THICK_LINEAR) {
1678
1718
instance.sbtOffset = PG_HITD_CURVE_LINEAR - PG_HITD;
1679
- if (pipeline_options.usesMotionBlur && ob-> get_geometry () ->has_motion_blur ()) {
1719
+ if (pipeline_options.usesMotionBlur && hair ->has_motion_blur ()) {
1680
1720
instance.sbtOffset = PG_HITD_CURVE_LINEAR_MOTION - PG_HITD;
1681
1721
}
1682
1722
}
1683
1723
else {
1684
- if (pipeline_options.usesMotionBlur && ob-> get_geometry () ->has_motion_blur ()) {
1724
+ if (pipeline_options.usesMotionBlur && hair ->has_motion_blur ()) {
1685
1725
/* Select between motion blur and non-motion blur built-in intersection module. */
1686
1726
instance.sbtOffset = PG_HITD_MOTION - PG_HITD;
1687
1727
}
0 commit comments