File indexing completed on 2025-01-18 10:03:47
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 #ifndef _Graphic3d_BSDF_HeaderFile
0017 #define _Graphic3d_BSDF_HeaderFile
0018
0019 #include <Graphic3d_Vec3.hxx>
0020 #include <Graphic3d_Vec4.hxx>
0021
0022 class Graphic3d_PBRMaterial;
0023
0024
0025 enum Graphic3d_FresnelModel
0026 {
0027 Graphic3d_FM_SCHLICK = 0,
0028 Graphic3d_FM_CONSTANT = 1,
0029 Graphic3d_FM_CONDUCTOR = 2,
0030 Graphic3d_FM_DIELECTRIC = 3
0031 };
0032
0033
0034 class Graphic3d_Fresnel
0035 {
0036 public:
0037
0038
0039 Graphic3d_Fresnel() : myFresnelType (Graphic3d_FM_CONSTANT)
0040 {
0041
0042 myFresnelData = Graphic3d_Vec3 (0.f, 1.f, 0.f);
0043 }
0044
0045
0046 static Graphic3d_Fresnel CreateSchlick (const Graphic3d_Vec3& theSpecularColor)
0047 {
0048 return Graphic3d_Fresnel (Graphic3d_FM_SCHLICK, theSpecularColor);
0049 }
0050
0051
0052 static Graphic3d_Fresnel CreateConstant (const Standard_ShortReal theReflection)
0053 {
0054 return Graphic3d_Fresnel (Graphic3d_FM_CONSTANT, Graphic3d_Vec3 (0.f, 1.f, theReflection));
0055 }
0056
0057
0058 static Graphic3d_Fresnel CreateDielectric (Standard_ShortReal theRefractionIndex)
0059 {
0060 return Graphic3d_Fresnel (Graphic3d_FM_DIELECTRIC, Graphic3d_Vec3 (0.f, theRefractionIndex, 0.f));
0061 }
0062
0063
0064 static Graphic3d_Fresnel CreateConductor (Standard_ShortReal theRefractionIndex,
0065 Standard_ShortReal theAbsorptionIndex)
0066 {
0067 return Graphic3d_Fresnel (Graphic3d_FM_CONDUCTOR, Graphic3d_Vec3 (0.f, theRefractionIndex, theAbsorptionIndex));
0068 }
0069
0070
0071 Standard_EXPORT static Graphic3d_Fresnel CreateConductor (const Graphic3d_Vec3& theRefractionIndex,
0072 const Graphic3d_Vec3& theAbsorptionIndex);
0073
0074 public:
0075
0076
0077 Standard_EXPORT Graphic3d_Vec4 Serialize() const;
0078
0079
0080 bool operator== (const Graphic3d_Fresnel& theOther) const
0081 {
0082 return myFresnelType == theOther.myFresnelType
0083 && myFresnelData == theOther.myFresnelData;
0084 }
0085
0086
0087 Graphic3d_FresnelModel FresnelType() const
0088 {
0089 return myFresnelType;
0090 }
0091
0092
0093 Standard_EXPORT void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const;
0094
0095 protected:
0096
0097
0098 Graphic3d_Fresnel (Graphic3d_FresnelModel theType, const Graphic3d_Vec3& theData)
0099 : myFresnelType (theType),
0100 myFresnelData (theData)
0101 {
0102
0103 }
0104
0105 private:
0106
0107
0108 Graphic3d_FresnelModel myFresnelType;
0109
0110
0111 Graphic3d_Vec3 myFresnelData;
0112 };
0113
0114
0115
0116
0117
0118
0119
0120
0121
0122
0123
0124 class Graphic3d_BSDF
0125 {
0126 public:
0127
0128
0129 Graphic3d_Vec4 Kc;
0130
0131
0132 Graphic3d_Vec3 Kd;
0133
0134
0135 Graphic3d_Vec4 Ks;
0136
0137
0138 Graphic3d_Vec3 Kt;
0139
0140
0141 Graphic3d_Vec3 Le;
0142
0143
0144 Graphic3d_Vec4 Absorption;
0145
0146
0147 Graphic3d_Fresnel FresnelCoat;
0148
0149
0150 Graphic3d_Fresnel FresnelBase;
0151
0152 public:
0153
0154
0155 static Standard_EXPORT Graphic3d_BSDF CreateDiffuse (const Graphic3d_Vec3& theWeight);
0156
0157
0158 static Standard_EXPORT Graphic3d_BSDF CreateMetallic (const Graphic3d_Vec3& theWeight,
0159 const Graphic3d_Fresnel& theFresnel,
0160 const Standard_ShortReal theRoughness);
0161
0162
0163
0164
0165 static Standard_EXPORT Graphic3d_BSDF CreateTransparent (const Graphic3d_Vec3& theWeight,
0166 const Graphic3d_Vec3& theAbsorptionColor,
0167 const Standard_ShortReal theAbsorptionCoeff);
0168
0169
0170
0171
0172 static Standard_EXPORT Graphic3d_BSDF CreateGlass (const Graphic3d_Vec3& theWeight,
0173 const Graphic3d_Vec3& theAbsorptionColor,
0174 const Standard_ShortReal theAbsorptionCoeff,
0175 const Standard_ShortReal theRefractionIndex);
0176
0177
0178 static Standard_EXPORT Graphic3d_BSDF CreateMetallicRoughness (const Graphic3d_PBRMaterial& thePbr);
0179
0180 public:
0181
0182
0183 Standard_EXPORT Graphic3d_BSDF();
0184
0185
0186 Standard_EXPORT void Normalize();
0187
0188
0189 Standard_EXPORT bool operator== (const Graphic3d_BSDF& theOther) const;
0190
0191
0192 Standard_EXPORT void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const;
0193
0194 };
0195
0196 #endif