Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-11-13 10:47:38

0001 // Copyright (c) 2019 OPEN CASCADE SAS
0002 //
0003 // This file is part of Open CASCADE Technology software library.
0004 //
0005 // This library is free software; you can redistribute it and/or modify it under
0006 // the terms of the GNU Lesser General Public License version 2.1 as published
0007 // by the Free Software Foundation, with special exception defined in the file
0008 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0009 // distribution for complete text of the license and disclaimer of any warranty.
0010 //
0011 // Alternatively, this file may be used under the terms of Open CASCADE
0012 // commercial license or contractual agreement.
0013 
0014 #ifndef _XCAFDoc_VisMaterialPBR_HeaderFile
0015 #define _XCAFDoc_VisMaterialPBR_HeaderFile
0016 
0017 #include <NCollection_Vec2.hxx>
0018 
0019 #include <Standard_TypeDef.hxx>
0020 
0021 #include <NCollection_Vec3.hxx>
0022 
0023 #include <NCollection_Vec4.hxx>
0024 
0025 #include <NCollection_Mat4.hxx>
0026 #include <Image_Texture.hxx>
0027 #include <Quantity_ColorRGBA.hxx>
0028 #include <Standard_Dump.hxx>
0029 
0030 //! Metallic-roughness PBR material definition.
0031 struct XCAFDoc_VisMaterialPBR
0032 {
0033   occ::handle<Image_Texture> BaseColorTexture; //!< RGB texture for the base color
0034                                                // clang-format off
0035   occ::handle<Image_Texture>   MetallicRoughnessTexture; //!< RG texture packing the metallic and roughness properties together
0036   occ::handle<Image_Texture>   EmissiveTexture;          //!< RGB emissive map controls the color and intensity of the light being emitted by the material
0037   occ::handle<Image_Texture>   OcclusionTexture;         //!< R occlusion map indicating areas of indirect lighting
0038   occ::handle<Image_Texture>   NormalTexture;            //!< normal map
0039   Quantity_ColorRGBA      BaseColor;                //!< base color (or scale factor to the texture); [1.0, 1.0, 1.0, 1.0] by default
0040   NCollection_Vec3<float>          EmissiveFactor;           //!< emissive color; [0.0, 0.0, 0.0] by default
0041   float      Metallic;                 //!< metalness  (or scale factor to the texture) within range [0.0, 1.0]; 1.0 by default
0042   float      Roughness;                //!< roughness  (or scale factor to the texture) within range [0.0, 1.0]; 1.0 by default
0043   float      RefractionIndex;          //!< IOR (index of refraction) within range [1.0, 3.0]; 1.5 by default
0044                                                // clang-format on
0045   bool IsDefined;                              //!< defined flag; TRUE by default
0046 
0047   //! Empty constructor.
0048   XCAFDoc_VisMaterialPBR()
0049       : BaseColor(1.0f, 1.0f, 1.0f, 1.0f),
0050         EmissiveFactor(0.0f, 0.0f, 0.0f),
0051         Metallic(1.0f),
0052         Roughness(1.0f),
0053         RefractionIndex(1.5f),
0054         IsDefined(true)
0055   {
0056   }
0057 
0058   //! Compare two materials.
0059   bool IsEqual(const XCAFDoc_VisMaterialPBR& theOther) const
0060   {
0061     if (&theOther == this)
0062     {
0063       return true;
0064     }
0065     else if (theOther.IsDefined != IsDefined)
0066     {
0067       return false;
0068     }
0069     else if (!IsDefined)
0070     {
0071       return true;
0072     }
0073 
0074     return theOther.BaseColorTexture == BaseColorTexture
0075            && theOther.MetallicRoughnessTexture == MetallicRoughnessTexture
0076            && theOther.EmissiveTexture == EmissiveTexture
0077            && theOther.OcclusionTexture == OcclusionTexture
0078            && theOther.NormalTexture == NormalTexture && theOther.BaseColor == BaseColor
0079            && theOther.EmissiveFactor == EmissiveFactor && theOther.Metallic == Metallic
0080            && theOther.Roughness == Roughness && theOther.RefractionIndex == RefractionIndex;
0081   }
0082 
0083   //! Dumps the content of me into the stream
0084   void DumpJson(Standard_OStream& theOStream, int theDepth = -1) const
0085   {
0086     OCCT_DUMP_CLASS_BEGIN(theOStream, XCAFDoc_VisMaterialPBR)
0087 
0088     OCCT_DUMP_FIELD_VALUES_DUMPED(theOStream, theDepth, BaseColorTexture.get())
0089     OCCT_DUMP_FIELD_VALUES_DUMPED(theOStream, theDepth, MetallicRoughnessTexture.get())
0090     OCCT_DUMP_FIELD_VALUES_DUMPED(theOStream, theDepth, EmissiveTexture.get())
0091     OCCT_DUMP_FIELD_VALUES_DUMPED(theOStream, theDepth, OcclusionTexture.get())
0092     OCCT_DUMP_FIELD_VALUES_DUMPED(theOStream, theDepth, NormalTexture.get())
0093 
0094     OCCT_DUMP_FIELD_VALUES_DUMPED(theOStream, theDepth, &BaseColor)
0095     OCCT_DUMP_FIELD_VALUES_DUMPED(theOStream, theDepth, &EmissiveFactor)
0096 
0097     OCCT_DUMP_FIELD_VALUE_NUMERICAL(theOStream, Metallic)
0098     OCCT_DUMP_FIELD_VALUE_NUMERICAL(theOStream, Roughness)
0099     OCCT_DUMP_FIELD_VALUE_NUMERICAL(theOStream, RefractionIndex)
0100     OCCT_DUMP_FIELD_VALUE_NUMERICAL(theOStream, IsDefined)
0101   }
0102 };
0103 
0104 #endif // _XCAFDoc_VisMaterialPBR_HeaderFile