File indexing completed on 2026-07-26 09:16:33
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 Graphic3d_Fresnel()
0039 : 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,
0068 Graphic3d_Vec3(0.f, theRefractionIndex, theAbsorptionIndex));
0069 }
0070
0071
0072 Standard_EXPORT static Graphic3d_Fresnel CreateConductor(
0073 const Graphic3d_Vec3& theRefractionIndex,
0074 const Graphic3d_Vec3& theAbsorptionIndex);
0075
0076 public:
0077
0078 Standard_EXPORT Graphic3d_Vec4 Serialize() const;
0079
0080
0081 bool operator==(const Graphic3d_Fresnel& theOther) const
0082 {
0083 return myFresnelType == theOther.myFresnelType && myFresnelData == theOther.myFresnelData;
0084 }
0085
0086
0087 Graphic3d_FresnelModel FresnelType() const { return myFresnelType; }
0088
0089
0090 Standard_EXPORT void DumpJson(Standard_OStream& theOStream, Standard_Integer theDepth = -1) const;
0091
0092 protected:
0093
0094 Graphic3d_Fresnel(Graphic3d_FresnelModel theType, const Graphic3d_Vec3& theData)
0095 : myFresnelType(theType),
0096 myFresnelData(theData)
0097 {
0098
0099 }
0100
0101 private:
0102
0103 Graphic3d_FresnelModel myFresnelType;
0104
0105
0106 Graphic3d_Vec3 myFresnelData;
0107 };
0108
0109
0110
0111
0112
0113
0114
0115
0116
0117
0118
0119 class Graphic3d_BSDF
0120 {
0121 public:
0122
0123 Graphic3d_Vec4 Kc;
0124
0125
0126 Graphic3d_Vec3 Kd;
0127
0128
0129 Graphic3d_Vec4 Ks;
0130
0131
0132 Graphic3d_Vec3 Kt;
0133
0134
0135 Graphic3d_Vec3 Le;
0136
0137
0138 Graphic3d_Vec4 Absorption;
0139
0140
0141 Graphic3d_Fresnel FresnelCoat;
0142
0143
0144 Graphic3d_Fresnel FresnelBase;
0145
0146 public:
0147
0148 static Standard_EXPORT Graphic3d_BSDF CreateDiffuse(const Graphic3d_Vec3& theWeight);
0149
0150
0151 static Standard_EXPORT Graphic3d_BSDF CreateMetallic(const Graphic3d_Vec3& theWeight,
0152 const Graphic3d_Fresnel& theFresnel,
0153 const Standard_ShortReal theRoughness);
0154
0155
0156
0157
0158 static Standard_EXPORT Graphic3d_BSDF
0159 CreateTransparent(const Graphic3d_Vec3& theWeight,
0160 const Graphic3d_Vec3& theAbsorptionColor,
0161 const Standard_ShortReal theAbsorptionCoeff);
0162
0163
0164
0165
0166 static Standard_EXPORT Graphic3d_BSDF CreateGlass(const Graphic3d_Vec3& theWeight,
0167 const Graphic3d_Vec3& theAbsorptionColor,
0168 const Standard_ShortReal theAbsorptionCoeff,
0169 const Standard_ShortReal theRefractionIndex);
0170
0171
0172 static Standard_EXPORT Graphic3d_BSDF
0173 CreateMetallicRoughness(const Graphic3d_PBRMaterial& thePbr);
0174
0175 public:
0176
0177 Standard_EXPORT Graphic3d_BSDF();
0178
0179
0180 Standard_EXPORT void Normalize();
0181
0182
0183 Standard_EXPORT bool operator==(const Graphic3d_BSDF& theOther) const;
0184
0185
0186 Standard_EXPORT void DumpJson(Standard_OStream& theOStream, Standard_Integer theDepth = -1) const;
0187 };
0188
0189 #endif