Open CASCADE Technology  7.5.0
Public Member Functions | Static Public Member Functions

OpenGl_PBREnvironment Class Reference

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>

Inheritance diagram for OpenGl_PBREnvironment:
Inheritance graph
[legend]

Public Member Functions

void Bind (const Handle< OpenGl_Context > &theCtx)
 Binds diffuse and specular IBL maps to the corresponding texture units. More...
 
void Unbind (const Handle< OpenGl_Context > &theCtx)
 Unbinds diffuse and specular IBL maps. More...
 
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. More...
 
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. More...
 
unsigned int SpecMapLevelsNumber () const
 Returns number of mipmap levels used in specular IBL map. It can be different from value passed to creation method. More...
 
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() More...
 
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. More...
 
bool IsNeededToBeBound () const
 Indicates whether IBL map's textures have to be bound or it is not obligate. More...
 
virtual void Release (OpenGl_Context *theCtx) override
 Releases all OpenGL resources. It must be called before destruction. More...
 
virtual Standard_Size EstimatedDataSize () const override
 Returns estimated GPU memory usage for holding data without considering overheads and allocation alignment rules. More...
 
Standard_Boolean IsComplete () const
 Checks completeness of PBR environment. Creation method returns only completed objects or null handles otherwise. More...
 
virtual ~OpenGl_PBREnvironment ()
 Destructor. Warning! 'Release' method must be called before destruction. Otherwise unhandled critical error will be generated. More...
 
- Public Member Functions inherited from OpenGl_NamedResource
 OpenGl_NamedResource (const TCollection_AsciiString &theId)
 Empty constructor. More...
 
const TCollection_AsciiStringResourceId () const
 Return resource name. More...
 
- Public Member Functions inherited from OpenGl_Resource
 OpenGl_Resource ()
 Empty constructor. More...
 
virtual ~OpenGl_Resource ()
 Destructor. Inheritors should call Clean (NULL) within it. More...
 
virtual void DumpJson (Standard_OStream &theOStream, Standard_Integer theDepth=-1) const
 Dumps the content of me into the stream. More...
 
- Public Member Functions inherited from Standard_Transient
 Standard_Transient ()
 Empty constructor. More...
 
 Standard_Transient (const Standard_Transient &)
 Copy constructor – does nothing. More...
 
Standard_Transientoperator= (const Standard_Transient &)
 Assignment operator, needed to avoid copying reference counter. More...
 
virtual ~Standard_Transient ()
 Destructor must be virtual. More...
 
virtual void Delete () const
 Memory deallocator for transient classes. More...
 
virtual const opencascade::handle< Standard_Type > & DynamicType () const
 Returns a type descriptor about this object. More...
 
Standard_Boolean IsInstance (const opencascade::handle< Standard_Type > &theType) const
 Returns a true value if this is an instance of Type. More...
 
Standard_Boolean IsInstance (const Standard_CString theTypeName) const
 Returns a true value if this is an instance of TypeName. More...
 
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. More...
 
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. More...
 
Standard_TransientThis () 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. More...
 
Standard_Integer GetRefCount () const
 Get the reference counter of this object. More...
 
void IncrementRefCounter () const
 Increments the reference counter of this object. More...
 
Standard_Integer DecrementRefCounter () const
 Decrements the reference counter of this object; returns the decremented value. More...
 

Static Public Member Functions

static Handle< OpenGl_PBREnvironmentCreate (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. More...
 
- Static Public Member Functions inherited from Standard_Transient
static const char * get_type_name ()
 Returns a type descriptor about this object. More...
 
static const opencascade::handle< Standard_Type > & get_type_descriptor ()
 Returns type descriptor of Standard_Transient class. More...
 

Additional Inherited Members

- Public Types inherited from Standard_Transient
typedef void base_type
 Returns a type descriptor about this object. More...
 
- Protected Attributes inherited from OpenGl_NamedResource
TCollection_AsciiString myResourceId
 resource name More...
 

Detailed Description

This class contains specular and diffuse maps required for Image Base Lighting (IBL) in PBR shading model with it's generation methods.

Constructor & Destructor Documentation

◆ ~OpenGl_PBREnvironment()

virtual OpenGl_PBREnvironment::~OpenGl_PBREnvironment ( )
virtual

Destructor. Warning! 'Release' method must be called before destruction. Otherwise unhandled critical error will be generated.

Member Function Documentation

◆ Bake()

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.

Parameters
theCtxOpenGL context
theEnvMapsource environment map
theZIsInvertedflags indicates whether environment cubemap has inverted Z axis or not
theIsTopDownflags indicates whether environment cubemap has top-down memory layout or not
theDiffMapNbSamplesnumber of samples in Monte-Carlo integration for diffuse IBL spherical harmonics calculation
theSpecMapNbSamplesnumber of samples in Monte-Carlo integration for specular IBL map generation
theProbabilitycontrols 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.

◆ Bind()

void OpenGl_PBREnvironment::Bind ( const Handle< OpenGl_Context > &  theCtx)

Binds diffuse and specular IBL maps to the corresponding texture units.

◆ Clear()

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.

◆ Create()

static Handle< OpenGl_PBREnvironment > OpenGl_PBREnvironment::Create ( const Handle< OpenGl_Context > &  theCtx,
unsigned int  thePow2Size = 9,
unsigned int  theSpecMapLevelsNum = 6,
const TCollection_AsciiString theId = "PBREnvironment" 
)
static

Creates and initializes new PBR environment. It is the only way to create OpenGl_PBREnvironment.

Parameters
theCtxOpenGL context where environment will be created
thePow2Sizefinal size of texture's sides can be calculated as 2^thePow2Size; if thePow2Size less than 1 it will be set to 1
theSpecMapLevelsNumnumber 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.
theIdOpenGl_Resource name
Returns
handle to created PBR environment or NULL handle in case of fail

◆ EstimatedDataSize()

virtual Standard_Size OpenGl_PBREnvironment::EstimatedDataSize ( ) const
inlineoverridevirtual

Returns estimated GPU memory usage for holding data without considering overheads and allocation alignment rules.

Implements OpenGl_Resource.

◆ IsComplete()

Standard_Boolean OpenGl_PBREnvironment::IsComplete ( ) const
inline

Checks completeness of PBR environment. Creation method returns only completed objects or null handles otherwise.

◆ IsNeededToBeBound()

bool OpenGl_PBREnvironment::IsNeededToBeBound ( ) const
inline

Indicates whether IBL map's textures have to be bound or it is not obligate.

◆ Pow2Size()

unsigned int OpenGl_PBREnvironment::Pow2Size ( ) const
inline

Returns size of IBL maps sides as power of 2. So that the real size can be calculated as 2^Pow2Size()

◆ Release()

virtual void OpenGl_PBREnvironment::Release ( OpenGl_Context theCtx)
overridevirtual

Releases all OpenGL resources. It must be called before destruction.

Implements OpenGl_Resource.

◆ SizesAreDifferent()

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.

◆ SpecMapLevelsNumber()

unsigned int OpenGl_PBREnvironment::SpecMapLevelsNumber ( ) const
inline

Returns number of mipmap levels used in specular IBL map. It can be different from value passed to creation method.

◆ Unbind()

void OpenGl_PBREnvironment::Unbind ( const Handle< OpenGl_Context > &  theCtx)

Unbinds diffuse and specular IBL maps.


The documentation for this class was generated from the following file: