aPbr.SetColor (myPbrMat.BaseColor);
aPbr.SetMetallic (myPbrMat.Metallic);
aPbr.SetRoughness(myPbrMat.Roughness);
- if (myPbrMat.EmissiveTexture.IsNull()) // TODO Temporal measure until emissive map will be implemented
- {
- aPbr.SetEmission(myPbrMat.EmissiveFactor);
- }
+ aPbr.SetEmission (myPbrMat.EmissiveFactor);
theAspect.SetPBRMaterial (aPbr);
theAspect.SetBSDF (Graphic3d_BSDF::CreateMetallicRoughness (aPbr));
}
theAspect->SetAlphaMode (myAlphaMode , myAlphaCutOff);
theAspect->SetSuppressBackFaces (!myIsDoubleSided);
- Handle(Image_Texture) aColorTexture, aNormTexture;
- if (!myCommonMat.DiffuseTexture.IsNull())
+ const Handle(Image_Texture)& aColorTexture = !myPbrMat.BaseColorTexture.IsNull() ? myPbrMat.BaseColorTexture : myCommonMat.DiffuseTexture;
+ Standard_Integer aNbTexUnits = 0;
+ if (!aColorTexture.IsNull()) { ++aNbTexUnits; }
+ if (!myPbrMat.EmissiveTexture.IsNull()) { ++aNbTexUnits; }
+ if (!myPbrMat.NormalTexture.IsNull()) { ++aNbTexUnits; }
+ if (!myPbrMat.OcclusionTexture.IsNull()) { ++aNbTexUnits; }
+ if (!myPbrMat.MetallicRoughnessTexture.IsNull()) { ++aNbTexUnits; }
+ if (aNbTexUnits == 0)
{
- aColorTexture = myCommonMat.DiffuseTexture;
+ return;
}
- else if (!myPbrMat.BaseColorTexture.IsNull())
+
+ Standard_Integer aTexIter = 0;
+ Handle(Graphic3d_TextureSet) aTextureSet = new Graphic3d_TextureSet (aNbTexUnits);
+ if (!aColorTexture.IsNull())
{
- aColorTexture = myPbrMat.BaseColorTexture;
+ aTextureSet->SetValue (aTexIter++, new XCAFPrs_Texture (*aColorTexture, Graphic3d_TextureUnit_BaseColor));
}
-
- if (!myPbrMat.NormalTexture.IsNull())
+ if (!myPbrMat.EmissiveTexture.IsNull())
{
- aNormTexture = myPbrMat.NormalTexture;
+ aTextureSet->SetValue (aTexIter++, new XCAFPrs_Texture (*myPbrMat.EmissiveTexture, Graphic3d_TextureUnit_Emissive));
}
-
- Standard_Integer aNbTextures = 0;
- if (!aColorTexture.IsNull())
+ if (!myPbrMat.OcclusionTexture.IsNull())
{
- ++aNbTextures;
+ aTextureSet->SetValue (aTexIter++, new XCAFPrs_Texture (*myPbrMat.OcclusionTexture, Graphic3d_TextureUnit_Occlusion));
}
- if (!aNormTexture.IsNull())
+ if (!myPbrMat.NormalTexture.IsNull())
{
- //++aNbTextures;
+ aTextureSet->SetValue (aTexIter++, new XCAFPrs_Texture (*myPbrMat.NormalTexture, Graphic3d_TextureUnit_Normal));
}
- if (aNbTextures != 0)
+ if (!myPbrMat.MetallicRoughnessTexture.IsNull())
{
- Handle(Graphic3d_TextureSet) aTextureSet = new Graphic3d_TextureSet (aNbTextures);
- Standard_Integer aTextureIndex = 0;
- if (!aColorTexture.IsNull())
- {
- aTextureSet->SetValue (aTextureIndex++, new XCAFPrs_Texture (*aColorTexture, Graphic3d_TextureUnit_BaseColor));
- }
- if (!aNormTexture.IsNull())
- {
- //aTextureSet->SetValue (aTextureIndex++, new XCAFPrs_Texture (*aColorTexture, Graphic3d_TextureUnit_Normal));
- }
- theAspect->SetTextureSet (aTextureSet);
- theAspect->SetTextureMapOn (true);
+ aTextureSet->SetValue (aTexIter++, new XCAFPrs_Texture (*myPbrMat.MetallicRoughnessTexture, Graphic3d_TextureUnit_MetallicRoughness));
}
+
+ theAspect->SetTextureSet (aTextureSet);
+ theAspect->SetTextureMapOn (true);
}