1 // Created on: 2015-01-15
2 // Created by: Danila ULYANOV
3 // Copyright (c) 2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #ifndef _Graphic3d_BSDF_HeaderFile
17 #define _Graphic3d_BSDF_HeaderFile
19 #include <Graphic3d_Vec3.hxx>
20 #include <Graphic3d_Vec4.hxx>
22 class Graphic3d_PBRMaterial;
24 //! Type of the Fresnel model.
25 enum Graphic3d_FresnelModel
27 Graphic3d_FM_SCHLICK = 0,
28 Graphic3d_FM_CONSTANT = 1,
29 Graphic3d_FM_CONDUCTOR = 2,
30 Graphic3d_FM_DIELECTRIC = 3
33 //! Describes Fresnel reflectance parameters.
34 class Graphic3d_Fresnel
38 //! Creates uninitialized Fresnel factor.
39 Graphic3d_Fresnel() : myFresnelType (Graphic3d_FM_CONSTANT)
41 // ideal specular reflector
42 myFresnelData = Graphic3d_Vec3 (0.f, 1.f, 0.f);
45 //! Creates Schlick's approximation of Fresnel factor.
46 static Graphic3d_Fresnel CreateSchlick (const Graphic3d_Vec3& theSpecularColor)
48 return Graphic3d_Fresnel (Graphic3d_FM_SCHLICK, theSpecularColor);
51 //! Creates Fresnel factor for constant reflection.
52 static Graphic3d_Fresnel CreateConstant (const Standard_ShortReal theReflection)
54 return Graphic3d_Fresnel (Graphic3d_FM_CONSTANT, Graphic3d_Vec3 (0.f, 1.f, theReflection));
57 //! Creates Fresnel factor for physical-based dielectric model.
58 static Graphic3d_Fresnel CreateDielectric (Standard_ShortReal theRefractionIndex)
60 return Graphic3d_Fresnel (Graphic3d_FM_DIELECTRIC, Graphic3d_Vec3 (0.f, theRefractionIndex, 0.f));
63 //! Creates Fresnel factor for physical-based conductor model.
64 static Graphic3d_Fresnel CreateConductor (Standard_ShortReal theRefractionIndex,
65 Standard_ShortReal theAbsorptionIndex)
67 return Graphic3d_Fresnel (Graphic3d_FM_CONDUCTOR, Graphic3d_Vec3 (0.f, theRefractionIndex, theAbsorptionIndex));
70 //! Creates Fresnel factor for physical-based conductor model (spectral version).
71 Standard_EXPORT static Graphic3d_Fresnel CreateConductor (const Graphic3d_Vec3& theRefractionIndex,
72 const Graphic3d_Vec3& theAbsorptionIndex);
76 //! Returns serialized representation of Fresnel factor.
77 Standard_EXPORT Graphic3d_Vec4 Serialize() const;
79 //! Performs comparison of two objects describing Fresnel factor.
80 bool operator== (const Graphic3d_Fresnel& theOther) const
82 return myFresnelType == theOther.myFresnelType
83 && myFresnelData == theOther.myFresnelData;
86 //! Returns type of Fresnel.
87 Graphic3d_FresnelModel FresnelType() const
94 //! Creates new Fresnel reflectance factor.
95 Graphic3d_Fresnel (Graphic3d_FresnelModel theType, const Graphic3d_Vec3& theData)
96 : myFresnelType (theType),
97 myFresnelData (theData)
104 //! Type of Fresnel approximation.
105 Graphic3d_FresnelModel myFresnelType;
107 //! Serialized parameters of specific approximation.
108 Graphic3d_Vec3 myFresnelData;
111 //! Describes material's BSDF (Bidirectional Scattering Distribution Function) used
112 //! for physically-based rendering (in path tracing engine). BSDF is represented as
113 //! weighted mixture of basic BRDFs/BTDFs (Bidirectional Reflectance (Transmittance)
114 //! Distribution Functions).
116 //! NOTE: OCCT uses two-layer material model. We have base diffuse, glossy, or transmissive
117 //! layer, covered by one glossy/specular coat. In the current model, the layers themselves
118 //! have no thickness; they can simply reflect light or transmits it to the layer under it.
119 //! We use actual BRDF model only for direct reflection by the coat layer. For transmission
120 //! through this layer, we approximate it as a flat specular surface.
125 //! Weight of coat specular/glossy BRDF.
128 //! Weight of base diffuse BRDF.
131 //! Weight of base specular/glossy BRDF.
134 //! Weight of base specular/glossy BTDF.
137 //! Radiance emitted by the surface.
140 //! Volume scattering color/density.
141 Graphic3d_Vec4 Absorption;
143 //! Parameters of Fresnel reflectance of coat layer.
144 Graphic3d_Fresnel FresnelCoat;
146 //! Parameters of Fresnel reflectance of base layer.
147 Graphic3d_Fresnel FresnelBase;
151 //! Creates BSDF describing diffuse (Lambertian) surface.
152 static Standard_EXPORT Graphic3d_BSDF CreateDiffuse (const Graphic3d_Vec3& theWeight);
154 //! Creates BSDF describing polished metallic-like surface.
155 static Standard_EXPORT Graphic3d_BSDF CreateMetallic (const Graphic3d_Vec3& theWeight,
156 const Graphic3d_Fresnel& theFresnel,
157 const Standard_ShortReal theRoughness);
159 //! Creates BSDF describing transparent object.
160 //! Transparent BSDF models simple transparency without
161 //! refraction (the ray passes straight through the surface).
162 static Standard_EXPORT Graphic3d_BSDF CreateTransparent (const Graphic3d_Vec3& theWeight,
163 const Graphic3d_Vec3& theAbsorptionColor,
164 const Standard_ShortReal theAbsorptionCoeff);
166 //! Creates BSDF describing glass-like object.
167 //! Glass-like BSDF mixes refraction and reflection effects at
168 //! grazing angles using physically-based Fresnel dielectric model.
169 static Standard_EXPORT Graphic3d_BSDF CreateGlass (const Graphic3d_Vec3& theWeight,
170 const Graphic3d_Vec3& theAbsorptionColor,
171 const Standard_ShortReal theAbsorptionCoeff,
172 const Standard_ShortReal theRefractionIndex);
174 //! Creates BSDF from PBR metallic-roughness material.
175 static Standard_EXPORT Graphic3d_BSDF CreateMetallicRoughness (const Graphic3d_PBRMaterial& thePbr);
179 //! Creates uninitialized BSDF.
180 Standard_EXPORT Graphic3d_BSDF();
182 //! Normalizes BSDF components.
183 Standard_EXPORT void Normalize();
185 //! Performs comparison of two BSDFs.
186 Standard_EXPORT bool operator== (const Graphic3d_BSDF& theOther) const;
190 #endif // _Graphic3d_BSDF_HeaderFile