Open CASCADE Technology 7.8.2.dev
|
This class contains specular and diffuse maps required for Image Base Lighting (IBL) in PBR shading model with it's generation methods. More...
#include <OpenGl_PBREnvironment.hxx>
Public Member Functions | |
void | Bind (const Handle< OpenGl_Context > &theCtx) |
Binds diffuse and specular IBL maps to the corresponding texture units. | |
void | Unbind (const Handle< OpenGl_Context > &theCtx) |
Unbinds diffuse and specular IBL maps. | |
void | Clear (const Handle< OpenGl_Context > &theCtx, const Graphic3d_Vec3 &theColor=Graphic3d_Vec3(1.f)) |
Fills all mipmaps of specular IBL map and diffuse IBL map with one color. So that environment illumination will be constant. | |
void | Bake (const Handle< OpenGl_Context > &theCtx, const Handle< OpenGl_Texture > &theEnvMap, Standard_Boolean theZIsInverted=Standard_False, Standard_Boolean theIsTopDown=Standard_True, Standard_Size theDiffMapNbSamples=1024, Standard_Size theSpecMapNbSamples=256, Standard_ShortReal theProbability=0.99f) |
Generates specular and diffuse (irradiance) IBL maps. | |
unsigned int | SpecMapLevelsNumber () const |
Returns number of mipmap levels used in specular IBL map. It can be different from value passed to creation method. | |
unsigned int | Pow2Size () const |
Returns size of IBL maps sides as power of 2. So that the real size can be calculated as 2^Pow2Size() | |
bool | SizesAreDifferent (unsigned int thePow2Size, unsigned int theSpecMapLevelsNumber) const |
Checks whether the given sizes affects to the current ones. It can be imagined as creation of new PBR environment. If creation method with this values returns the PBR environment having real sizes which are equals to current ones then this method will return false. It is handful when sizes are required to be changed. If this method returns false there is no reason to recreate PBR environment in order to change sizes. | |
bool | IsNeededToBeBound () const |
Indicates whether IBL map's textures have to be bound or it is not obligate. | |
virtual void | Release (OpenGl_Context *theCtx) override |
Releases all OpenGL resources. It must be called before destruction. | |
virtual Standard_Size | EstimatedDataSize () const override |
Returns estimated GPU memory usage for holding data without considering overheads and allocation alignment rules. | |
Standard_Boolean | IsComplete () const |
Checks completeness of PBR environment. Creation method returns only completed objects or null handles otherwise. | |
virtual | ~OpenGl_PBREnvironment () |
Destructor. Warning! 'Release' method must be called before destruction. Otherwise unhandled critical error will be generated. | |
Public Member Functions inherited from OpenGl_NamedResource | |
OpenGl_NamedResource (const TCollection_AsciiString &theId) | |
Empty constructor. | |
const TCollection_AsciiString & | ResourceId () const |
Return resource name. | |
Public Member Functions inherited from OpenGl_Resource | |
OpenGl_Resource () | |
Empty constructor. | |
virtual | ~OpenGl_Resource () |
Destructor. Inheritors should call Clean (NULL) within it. | |
virtual void | DumpJson (Standard_OStream &theOStream, Standard_Integer theDepth=-1) const |
Dumps the content of me into the stream. | |
Public Member Functions inherited from Standard_Transient | |
Standard_Transient () | |
Empty constructor. | |
Standard_Transient (const Standard_Transient &) | |
Copy constructor – does nothing. | |
Standard_Transient & | operator= (const Standard_Transient &) |
Assignment operator, needed to avoid copying reference counter. | |
virtual | ~Standard_Transient () |
Destructor must be virtual. | |
virtual const opencascade::handle< Standard_Type > & | DynamicType () const |
Returns a type descriptor about this object. | |
Standard_Boolean | IsInstance (const opencascade::handle< Standard_Type > &theType) const |
Returns a true value if this is an instance of Type. | |
Standard_Boolean | IsInstance (const Standard_CString theTypeName) const |
Returns a true value if this is an instance of TypeName. | |
Standard_Boolean | IsKind (const opencascade::handle< Standard_Type > &theType) const |
Returns true if this is an instance of Type or an instance of any class that inherits from Type. Note that multiple inheritance is not supported by OCCT RTTI mechanism. | |
Standard_Boolean | IsKind (const Standard_CString theTypeName) const |
Returns true if this is an instance of TypeName or an instance of any class that inherits from TypeName. Note that multiple inheritance is not supported by OCCT RTTI mechanism. | |
Standard_Transient * | This () const |
Returns non-const pointer to this object (like const_cast). For protection against creating handle to objects allocated in stack or call from constructor, it will raise exception Standard_ProgramError if reference counter is zero. | |
Standard_Integer | GetRefCount () const noexcept |
Get the reference counter of this object. | |
void | IncrementRefCounter () noexcept |
Increments the reference counter of this object. | |
Standard_Integer | DecrementRefCounter () noexcept |
Decrements the reference counter of this object; returns the decremented value. | |
virtual void | Delete () const |
Memory deallocator for transient classes. | |
Static Public Member Functions | |
static Handle< OpenGl_PBREnvironment > | Create (const Handle< OpenGl_Context > &theCtx, unsigned int thePow2Size=9, unsigned int theSpecMapLevelsNum=6, const TCollection_AsciiString &theId="PBREnvironment") |
Creates and initializes new PBR environment. It is the only way to create OpenGl_PBREnvironment. | |
Static Public Member Functions inherited from Standard_Transient | |
static constexpr const char * | get_type_name () |
Returns a type descriptor about this object. | |
static const opencascade::handle< Standard_Type > & | get_type_descriptor () |
Returns type descriptor of Standard_Transient class. | |
Additional Inherited Members | |
Public Types inherited from Standard_Transient | |
typedef void | base_type |
Returns a type descriptor about this object. | |
Protected Attributes inherited from OpenGl_NamedResource | |
TCollection_AsciiString | myResourceId |
resource name | |
This class contains specular and diffuse maps required for Image Base Lighting (IBL) in PBR shading model with it's generation methods.
|
virtual |
Destructor. Warning! 'Release' method must be called before destruction. Otherwise unhandled critical error will be generated.
void OpenGl_PBREnvironment::Bake | ( | const Handle< OpenGl_Context > & | theCtx, |
const Handle< OpenGl_Texture > & | theEnvMap, | ||
Standard_Boolean | theZIsInverted = Standard_False, | ||
Standard_Boolean | theIsTopDown = Standard_True, | ||
Standard_Size | theDiffMapNbSamples = 1024, | ||
Standard_Size | theSpecMapNbSamples = 256, | ||
Standard_ShortReal | theProbability = 0.99f ) |
Generates specular and diffuse (irradiance) IBL maps.
theCtx | OpenGL context |
theEnvMap | source environment map |
theZIsInverted | flags indicates whether environment cubemap has inverted Z axis or not |
theIsTopDown | flags indicates whether environment cubemap has top-down memory layout or not |
theDiffMapNbSamples | number of samples in Monte-Carlo integration for diffuse IBL spherical harmonics calculation |
theSpecMapNbSamples | number of samples in Monte-Carlo integration for specular IBL map generation |
theProbability | controls strength of samples number reducing strategy during specular IBL map baking (see 'SpecIBLMapSamplesFactor' for details) theZIsInverted and theIsTopDown can be taken from Graphic3d_CubeMap source of environment cubemap. theDiffMapNbSamples and theSpecMapNbSamples is the main parameter directly affected to performance. |
void OpenGl_PBREnvironment::Bind | ( | const Handle< OpenGl_Context > & | theCtx | ) |
Binds diffuse and specular IBL maps to the corresponding texture units.
void OpenGl_PBREnvironment::Clear | ( | const Handle< OpenGl_Context > & | theCtx, |
const Graphic3d_Vec3 & | theColor = Graphic3d_Vec3(1.f) ) |
Fills all mipmaps of specular IBL map and diffuse IBL map with one color. So that environment illumination will be constant.
|
static |
Creates and initializes new PBR environment. It is the only way to create OpenGl_PBREnvironment.
theCtx | OpenGL context where environment will be created |
thePow2Size | final size of texture's sides can be calculated as 2^thePow2Size; if thePow2Size less than 1 it will be set to 1 |
theSpecMapLevelsNum | number of mipmap levels used in specular IBL map; if theSpecMapLevelsNum less than 2 or less than Pow2Size + 1 it will be set to the corresponding values. |
theId | OpenGl_Resource name |
|
inlineoverridevirtual |
Returns estimated GPU memory usage for holding data without considering overheads and allocation alignment rules.
Implements OpenGl_Resource.
|
inline |
Checks completeness of PBR environment. Creation method returns only completed objects or null handles otherwise.
|
inline |
Indicates whether IBL map's textures have to be bound or it is not obligate.
|
inline |
Returns size of IBL maps sides as power of 2. So that the real size can be calculated as 2^Pow2Size()
|
overridevirtual |
Releases all OpenGL resources. It must be called before destruction.
Implements OpenGl_Resource.
bool OpenGl_PBREnvironment::SizesAreDifferent | ( | unsigned int | thePow2Size, |
unsigned int | theSpecMapLevelsNumber ) const |
Checks whether the given sizes affects to the current ones. It can be imagined as creation of new PBR environment. If creation method with this values returns the PBR environment having real sizes which are equals to current ones then this method will return false. It is handful when sizes are required to be changed. If this method returns false there is no reason to recreate PBR environment in order to change sizes.
|
inline |
Returns number of mipmap levels used in specular IBL map. It can be different from value passed to creation method.
void OpenGl_PBREnvironment::Unbind | ( | const Handle< OpenGl_Context > & | theCtx | ) |
Unbinds diffuse and specular IBL maps.