Open CASCADE Technology Reference Manual 8.0.0
Loading...
Searching...
No Matches
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 occ::handle< OpenGl_Context > &theCtx)
 Binds diffuse and specular IBL maps to the corresponding texture units.
 
void Unbind (const occ::handle< OpenGl_Context > &theCtx)
 Unbinds diffuse and specular IBL maps.
 
void Clear (const occ::handle< OpenGl_Context > &theCtx, const NCollection_Vec3< float > &theColor=NCollection_Vec3< float >(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 occ::handle< OpenGl_Context > &theCtx, const occ::handle< OpenGl_Texture > &theEnvMap, bool theZIsInverted=false, bool theIsTopDown=true, size_t theDiffMapNbSamples=1024, size_t theSpecMapNbSamples=256, float 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.
 
void Release (OpenGl_Context *theCtx) override
 Releases all OpenGL resources. It must be called before destruction.
 
size_t EstimatedDataSize () const override
 Returns estimated GPU memory usage for holding data without considering overheads and allocation alignment rules.
 
bool IsComplete () const
 Checks completeness of PBR environment. Creation method returns only completed objects or null handles otherwise.
 
 ~OpenGl_PBREnvironment () override
 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_AsciiStringResourceId () const
 Return resource name.
 
- Public Member Functions inherited from OpenGl_Resource
 OpenGl_Resource ()
 Empty constructor.
 
 ~OpenGl_Resource () override
 Destructor. Inheritors should call Clean (NULL) within it.
 
virtual void DumpJson (Standard_OStream &theOStream, int 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_Transientoperator= (const Standard_Transient &)
 Assignment operator, needed to avoid copying reference counter.
 
virtual ~Standard_Transient ()=default
 Destructor must be virtual.
 
virtual const opencascade::handle< Standard_Type > & DynamicType () const
 Returns a type descriptor about this object.
 
bool IsInstance (const opencascade::handle< Standard_Type > &theType) const
 Returns a true value if this is an instance of Type.
 
bool IsInstance (const char *const theTypeName) const
 Returns a true value if this is an instance of TypeName.
 
bool 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.
 
bool IsKind (const char *const 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_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.
 
int GetRefCount () const noexcept
 Get the reference counter of this object.
 
void IncrementRefCounter () noexcept
 Increments the reference counter of this object. Uses relaxed memory ordering since incrementing only requires atomicity, not synchronization with other memory operations.
 
int DecrementRefCounter () noexcept
 Decrements the reference counter of this object; returns the decremented value. Uses release ordering for the decrement to ensure all writes to the object are visible before the count reaches zero. An acquire fence is added only when the count reaches zero, ensuring proper synchronization before deletion. This is more efficient than using acq_rel for every decrement.
 
virtual void Delete () const
 Memory deallocator for transient classes.
 

Static Public Member Functions

static occ::handle< OpenGl_PBREnvironmentCreate (const occ::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 charget_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
 

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()

OpenGl_PBREnvironment::~OpenGl_PBREnvironment ( )
override

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 occ::handle< OpenGl_Context > & theCtx,
const occ::handle< OpenGl_Texture > & theEnvMap,
bool theZIsInverted = false,
bool theIsTopDown = true,
size_t theDiffMapNbSamples = 1024,
size_t theSpecMapNbSamples = 256,
float 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 occ::handle< OpenGl_Context > & theCtx)

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

◆ Clear()

void OpenGl_PBREnvironment::Clear ( const occ::handle< OpenGl_Context > & theCtx,
const NCollection_Vec3< float > & theColor = NCollection_Vec3float >(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 occ::handle< OpenGl_PBREnvironment > OpenGl_PBREnvironment::Create ( const occ::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()

size_t OpenGl_PBREnvironment::EstimatedDataSize ( ) const
inlineoverridevirtual

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

Implements OpenGl_Resource.

◆ IsComplete()

bool 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()

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 occ::handle< OpenGl_Context > & theCtx)

Unbinds diffuse and specular IBL maps.


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