0031668: Visualization - WebGL sample doesn't work on Emscripten 1.39
[occt.git] / src / XCAFDoc / XCAFDoc_VisMaterialPBR.hxx
CommitLineData
a4815d55 1// Copyright (c) 2019 OPEN CASCADE SAS
2//
3// This file is part of Open CASCADE Technology software library.
4//
5// This library is free software; you can redistribute it and/or modify it under
6// the terms of the GNU Lesser General Public License version 2.1 as published
7// by the Free Software Foundation, with special exception defined in the file
8// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
9// distribution for complete text of the license and disclaimer of any warranty.
10//
11// Alternatively, this file may be used under the terms of Open CASCADE
12// commercial license or contractual agreement.
13
14#ifndef _XCAFDoc_VisMaterialPBR_HeaderFile
15#define _XCAFDoc_VisMaterialPBR_HeaderFile
16
17#include <Graphic3d_AlphaMode.hxx>
18#include <Graphic3d_Vec.hxx>
19#include <Image_Texture.hxx>
20#include <Quantity_ColorRGBA.hxx>
bc73b006 21#include <Standard_Dump.hxx>
a4815d55 22
23//! Metallic-roughness PBR material definition.
24struct XCAFDoc_VisMaterialPBR
25{
26 Handle(Image_Texture) BaseColorTexture; //!< RGB texture for the base color
27 Handle(Image_Texture) MetallicRoughnessTexture; //!< RG texture packing the metallic and roughness properties together
28 Handle(Image_Texture) EmissiveTexture; //!< RGB emissive map controls the color and intensity of the light being emitted by the material
29 Handle(Image_Texture) OcclusionTexture; //!< R occlusion map indicating areas of indirect lighting
30 Handle(Image_Texture) NormalTexture; //!< normal map
31 Quantity_ColorRGBA BaseColor; //!< base color (or scale factor to the texture); [1.0, 1.0, 1.0, 1.0] by default
32 Graphic3d_Vec3 EmissiveFactor; //!< emissive color; [0.0, 0.0, 0.0] by default
33 Standard_ShortReal Metallic; //!< metalness (or scale factor to the texture) within range [0.0, 1.0]; 1.0 by default
34 Standard_ShortReal Roughness; //!< roughness (or scale factor to the texture) within range [0.0, 1.0]; 1.0 by default
0858125f 35 Standard_ShortReal RefractionIndex; //!< IOR (index of refraction) within range [1.0, 3.0]; 1.5 by default
a4815d55 36 Standard_Boolean IsDefined; //!< defined flag; FALSE by default
37
38 //! Empty constructor.
39 XCAFDoc_VisMaterialPBR()
40 : BaseColor (1.0f, 1.0f, 1.0f, 1.0f),
41 EmissiveFactor (0.0f, 0.0f, 0.0f),
42 Metallic (1.0f),
43 Roughness (1.0f),
0858125f 44 RefractionIndex (1.5f),
a4815d55 45 IsDefined (Standard_False) {}
46
47 //! Compare two materials.
48 Standard_Boolean IsEqual (const XCAFDoc_VisMaterialPBR& theOther) const
49 {
50 if (&theOther == this)
51 {
52 return true;
53 }
54 else if (theOther.IsDefined != IsDefined)
55 {
56 return false;
57 }
58 else if (!IsDefined)
59 {
60 return true;
61 }
62
63 return theOther.BaseColorTexture == BaseColorTexture
64 && theOther.MetallicRoughnessTexture == MetallicRoughnessTexture
65 && theOther.EmissiveTexture == EmissiveTexture
66 && theOther.OcclusionTexture == OcclusionTexture
67 && theOther.NormalTexture == NormalTexture
68 && theOther.BaseColor == BaseColor
69 && theOther.EmissiveFactor == EmissiveFactor
70 && theOther.Metallic == Metallic
0858125f 71 && theOther.Roughness == Roughness
72 && theOther.RefractionIndex == RefractionIndex;
a4815d55 73 }
bc73b006 74
75 //! Dumps the content of me into the stream
76 void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const
77 {
78 OCCT_DUMP_CLASS_BEGIN (theOStream, XCAFDoc_VisMaterialPBR)
79
80 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, BaseColorTexture.get())
81 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, MetallicRoughnessTexture.get())
82 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, EmissiveTexture.get())
83 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, OcclusionTexture.get())
84 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, NormalTexture.get())
85
86 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &BaseColor)
87 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &EmissiveFactor)
88
89 OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, Metallic)
90 OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, Roughness)
91 OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, RefractionIndex)
92 OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, IsDefined)
93 }
a4815d55 94};
95
96#endif // _XCAFDoc_VisMaterialPBR_HeaderFile