Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:05:34

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