MCPcopy Create free account
hub / github.com/Kitware/VTK / MakeActorMaterial

Function MakeActorMaterial

Rendering/RayTracing/vtkOSPRayPolyDataMapperNode.cxx:676–787  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

674
675//------------------------------------------------------------------------------
676OSPMaterial MakeActorMaterial(vtkOSPRayRendererNode* orn, OSPRenderer oRenderer,
677 vtkProperty* property, double* ambientColor, double* diffuseColor, float* specularf,
678 double opacity, bool pt_avail, bool& useCustomMaterial, std::map<std::string, OSPMaterial>& mats,
679 const std::string& materialName)
680{
681 RTW::Backend* backend = orn->GetBackend();
682 useCustomMaterial = false;
683 if (backend == nullptr)
684 {
685 return OSPMaterial();
686 }
687
688 float lum = static_cast<float>(vtkOSPRayActorNode::GetLuminosity(property));
689
690 float diffusef[] = { static_cast<float>(diffuseColor[0] * property->GetDiffuse()),
691 static_cast<float>(diffuseColor[1] * property->GetDiffuse()),
692 static_cast<float>(diffuseColor[2] * property->GetDiffuse()) };
693 if (lum > 0.0)
694 {
695 OSPMaterial oMaterial = vtkOSPRayMaterialHelpers::NewMaterial(orn, oRenderer, "luminous");
696 ospSetVec3f(oMaterial, "color", diffusef[0], diffusef[1], diffusef[2]);
697 ospSetFloat(oMaterial, "intensity", lum);
698 return oMaterial;
699 }
700
701 if (pt_avail && property->GetMaterialName())
702 {
703 if (std::string("Value Indexed") == property->GetMaterialName())
704 {
705 vtkOSPRayMaterialHelpers::MakeMaterials(
706 orn, oRenderer, mats); // todo: do an mtime check to avoid doing this when unchanged
707 std::string requested_mat_name = materialName;
708 if (!requested_mat_name.empty() && requested_mat_name != "Value Indexed")
709 {
710 useCustomMaterial = true;
711 return vtkOSPRayMaterialHelpers::MakeMaterial(orn, oRenderer, requested_mat_name.c_str());
712 }
713 }
714 else
715 {
716 useCustomMaterial = true;
717 return vtkOSPRayMaterialHelpers::MakeMaterial(orn, oRenderer, property->GetMaterialName());
718 }
719 }
720
721 OSPMaterial oMaterial;
722 if (pt_avail && property->GetInterpolation() == VTK_PBR)
723 {
724 oMaterial = vtkOSPRayMaterialHelpers::NewMaterial(orn, oRenderer, "principled");
725
726 ospSetVec3f(oMaterial, "baseColor", diffusef[0], diffusef[1], diffusef[2]);
727 ospSetFloat(oMaterial, "metallic", static_cast<float>(property->GetMetallic()));
728 ospSetFloat(oMaterial, "roughness", static_cast<float>(property->GetRoughness()));
729 ospSetFloat(oMaterial, "opacity", static_cast<float>(opacity));
730 // As OSPRay seems to not recalculate the refractive index of the base layer
731 // we need to recalculate, from the effective reflectance of the base layer (with the
732 // coat), the ior of the base that will produce the same reflectance but with the air
733 // with an ior of 1.0

Callers 1

ORenderPolyMethod · 0.85

Calls 14

NewMaterialFunction · 0.85
MakeMaterialsFunction · 0.85
MakeMaterialFunction · 0.85
GetMaterialNameMethod · 0.80
GetSpecularPowerMethod · 0.80
stringClass · 0.50
GetBackendMethod · 0.45
GetDiffuseMethod · 0.45
emptyMethod · 0.45
c_strMethod · 0.45
GetInterpolationMethod · 0.45

Tested by

no test coverage detected