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 //! Type of the Fresnel model.
23 enum Graphic3d_FresnelModel
25 Graphic3d_FM_SCHLICK = 0,
26 Graphic3d_FM_CONSTANT = 1,
27 Graphic3d_FM_CONDUCTOR = 2,
28 Graphic3d_FM_DIELECTRIC = 3
31 //! Describes Fresnel reflectance parameters.
32 class Graphic3d_Fresnel
36 //! Creates uninitialized Fresnel factor.
37 Graphic3d_Fresnel() : myFresnelType (Graphic3d_FM_CONSTANT)
39 // ideal specular reflector
40 myFresnelData = Graphic3d_Vec3 (0.f, 1.f, 0.f);
43 //! Creates Schlick's approximation of Fresnel factor.
44 static Graphic3d_Fresnel CreateSchlick (const Graphic3d_Vec3& theSpecularColor)
46 return Graphic3d_Fresnel (Graphic3d_FM_SCHLICK, theSpecularColor);
49 //! Creates Fresnel factor for constant reflection.
50 static Graphic3d_Fresnel CreateConstant (const Standard_ShortReal theReflection)
52 return Graphic3d_Fresnel (Graphic3d_FM_CONSTANT, Graphic3d_Vec3 (0.f, 1.f, theReflection));
55 //! Creates Fresnel factor for physical-based dielectric model.
56 static Graphic3d_Fresnel CreateDielectric (Standard_ShortReal theRefractionIndex)
58 return Graphic3d_Fresnel (Graphic3d_FM_DIELECTRIC, Graphic3d_Vec3 (0.f, theRefractionIndex, 0.f));
61 //! Creates Fresnel factor for physical-based conductor model.
62 static Graphic3d_Fresnel CreateConductor (Standard_ShortReal theRefractionIndex,
63 Standard_ShortReal theAbsorptionIndex)
65 return Graphic3d_Fresnel (Graphic3d_FM_CONDUCTOR, Graphic3d_Vec3 (0.f, theRefractionIndex, theAbsorptionIndex));
68 //! Creates Fresnel factor for physical-based conductor model (spectral version).
69 Standard_EXPORT static Graphic3d_Fresnel CreateConductor (const Graphic3d_Vec3& theRefractionIndex,
70 const Graphic3d_Vec3& theAbsorptionIndex);
74 //! Returns serialized representation of Fresnel factor.
75 Standard_EXPORT Graphic3d_Vec4 Serialize() const;
77 //! Performs comparison of two objects describing Fresnel factor.
78 bool operator== (const Graphic3d_Fresnel& theOther) const
80 return myFresnelType == theOther.myFresnelType
81 && myFresnelData == theOther.myFresnelData;
84 //! Returns type of Fresnel.
85 Graphic3d_FresnelModel FresnelType() const
92 //! Creates new Fresnel reflectance factor.
93 Graphic3d_Fresnel (Graphic3d_FresnelModel theType, const Graphic3d_Vec3& theData)
94 : myFresnelType (theType),
95 myFresnelData (theData)
102 //! Type of Fresnel approximation.
103 Graphic3d_FresnelModel myFresnelType;
105 //! Serialized parameters of specific approximation.
106 Graphic3d_Vec3 myFresnelData;
109 //! Describes material's BSDF (Bidirectional Scattering Distribution Function) used
110 //! for physically-based rendering (in path tracing engine). BSDF is represented as
111 //! weighted mixture of basic BRDFs/BTDFs (Bidirectional Reflectance (Transmittance)
112 //! Distribution Functions).
114 //! NOTE: OCCT uses two-layer material model. We have base diffuse, glossy, or transmissive
115 //! layer, covered by one glossy/specular coat. In the current model, the layers themselves
116 //! have no thickness; they can simply reflect light or transmits it to the layer under it.
117 //! We use actual BRDF model only for direct reflection by the coat layer. For transmission
118 //! through this layer, we approximate it as a flat specular surface.
123 //! Weight of coat specular/glossy BRDF.
126 //! Weight of base diffuse BRDF.
129 //! Weight of base specular/glossy BRDF.
132 //! Weight of base specular/glossy BTDF.
135 //! Radiance emitted by the surface.
138 //! Volume scattering color/density.
139 Graphic3d_Vec4 Absorption;
141 //! Parameters of Fresnel reflectance of coat layer.
142 Graphic3d_Fresnel FresnelCoat;
144 //! Parameters of Fresnel reflectance of base layer.
145 Graphic3d_Fresnel FresnelBase;
149 //! Creates BSDF describing diffuse (Lambertian) surface.
150 static Standard_EXPORT Graphic3d_BSDF CreateDiffuse (const Graphic3d_Vec3& theWeight);
152 //! Creates BSDF describing polished metallic-like surface.
153 static Standard_EXPORT Graphic3d_BSDF CreateMetallic (const Graphic3d_Vec3& theWeight,
154 const Graphic3d_Fresnel& theFresnel,
155 const Standard_ShortReal theRoughness);
157 //! Creates BSDF describing transparent object.
158 //! Transparent BSDF models simple transparency without
159 //! refraction (the ray passes straight through the surface).
160 static Standard_EXPORT Graphic3d_BSDF CreateTransparent (const Graphic3d_Vec3& theWeight,
161 const Graphic3d_Vec3& theAbsorptionColor,
162 const Standard_ShortReal theAbsorptionCoeff);
164 //! Creates BSDF describing glass-like object.
165 //! Glass-like BSDF mixes refraction and reflection effects at
166 //! grazing angles using physically-based Fresnel dielectric model.
167 static Standard_EXPORT Graphic3d_BSDF CreateGlass (const Graphic3d_Vec3& theWeight,
168 const Graphic3d_Vec3& theAbsorptionColor,
169 const Standard_ShortReal theAbsorptionCoeff,
170 const Standard_ShortReal theRefractionIndex);
174 //! Creates uninitialized BSDF.
175 Standard_EXPORT Graphic3d_BSDF();
177 //! Normalizes BSDF components.
178 Standard_EXPORT void Normalize();
180 //! Performs comparison of two BSDFs.
181 Standard_EXPORT bool operator== (const Graphic3d_BSDF& theOther) const;
185 #endif // _Graphic3d_BSDF_HeaderFile