Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-17 08:18:43

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 <Graphic3d_Vec.hxx>
0018 #include <Image_Texture.hxx>
0019 #include <Quantity_ColorRGBA.hxx>
0020 #include <Standard_Dump.hxx>
0021 
0022 //! Metallic-roughness PBR material definition.
0023 struct XCAFDoc_VisMaterialPBR
0024 {
0025   Handle(Image_Texture) BaseColorTexture; //!< RGB texture for the base color
0026                                           // clang-format off
0027   Handle(Image_Texture)   MetallicRoughnessTexture; //!< RG texture packing the metallic and roughness properties together
0028   Handle(Image_Texture)   EmissiveTexture;          //!< RGB emissive map controls the color and intensity of the light being emitted by the material
0029   Handle(Image_Texture)   OcclusionTexture;         //!< R occlusion map indicating areas of indirect lighting
0030   Handle(Image_Texture)   NormalTexture;            //!< normal map
0031   Quantity_ColorRGBA      BaseColor;                //!< base color (or scale factor to the texture); [1.0, 1.0, 1.0, 1.0] by default
0032   Graphic3d_Vec3          EmissiveFactor;           //!< emissive color; [0.0, 0.0, 0.0] by default
0033   Standard_ShortReal      Metallic;                 //!< metalness  (or scale factor to the texture) within range [0.0, 1.0]; 1.0 by default
0034   Standard_ShortReal      Roughness;                //!< roughness  (or scale factor to the texture) within range [0.0, 1.0]; 1.0 by default
0035   Standard_ShortReal      RefractionIndex;          //!< IOR (index of refraction) within range [1.0, 3.0]; 1.5 by default
0036                                           // clang-format on
0037   Standard_Boolean IsDefined;             //!< defined flag; TRUE by default
0038 
0039   //! Empty constructor.
0040   XCAFDoc_VisMaterialPBR()
0041       : BaseColor(1.0f, 1.0f, 1.0f, 1.0f),
0042         EmissiveFactor(0.0f, 0.0f, 0.0f),
0043         Metallic(1.0f),
0044         Roughness(1.0f),
0045         RefractionIndex(1.5f),
0046         IsDefined(Standard_True)
0047   {
0048   }
0049 
0050   //! Compare two materials.
0051   Standard_Boolean IsEqual(const XCAFDoc_VisMaterialPBR& theOther) const
0052   {
0053     if (&theOther == this)
0054     {
0055       return true;
0056     }
0057     else if (theOther.IsDefined != IsDefined)
0058     {
0059       return false;
0060     }
0061     else if (!IsDefined)
0062     {
0063       return true;
0064     }
0065 
0066     return theOther.BaseColorTexture == BaseColorTexture
0067            && theOther.MetallicRoughnessTexture == MetallicRoughnessTexture
0068            && theOther.EmissiveTexture == EmissiveTexture
0069            && theOther.OcclusionTexture == OcclusionTexture
0070            && theOther.NormalTexture == NormalTexture && theOther.BaseColor == BaseColor
0071            && theOther.EmissiveFactor == EmissiveFactor && theOther.Metallic == Metallic
0072            && theOther.Roughness == Roughness && theOther.RefractionIndex == RefractionIndex;
0073   }
0074 
0075   //! Dumps the content of me into the stream
0076   void DumpJson(Standard_OStream& theOStream, Standard_Integer theDepth = -1) const
0077   {
0078     OCCT_DUMP_CLASS_BEGIN(theOStream, XCAFDoc_VisMaterialPBR)
0079 
0080     OCCT_DUMP_FIELD_VALUES_DUMPED(theOStream, theDepth, BaseColorTexture.get())
0081     OCCT_DUMP_FIELD_VALUES_DUMPED(theOStream, theDepth, MetallicRoughnessTexture.get())
0082     OCCT_DUMP_FIELD_VALUES_DUMPED(theOStream, theDepth, EmissiveTexture.get())
0083     OCCT_DUMP_FIELD_VALUES_DUMPED(theOStream, theDepth, OcclusionTexture.get())
0084     OCCT_DUMP_FIELD_VALUES_DUMPED(theOStream, theDepth, NormalTexture.get())
0085 
0086     OCCT_DUMP_FIELD_VALUES_DUMPED(theOStream, theDepth, &BaseColor)
0087     OCCT_DUMP_FIELD_VALUES_DUMPED(theOStream, theDepth, &EmissiveFactor)
0088 
0089     OCCT_DUMP_FIELD_VALUE_NUMERICAL(theOStream, Metallic)
0090     OCCT_DUMP_FIELD_VALUE_NUMERICAL(theOStream, Roughness)
0091     OCCT_DUMP_FIELD_VALUE_NUMERICAL(theOStream, RefractionIndex)
0092     OCCT_DUMP_FIELD_VALUE_NUMERICAL(theOStream, IsDefined)
0093   }
0094 };
0095 
0096 #endif // _XCAFDoc_VisMaterialPBR_HeaderFile