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