Open CASCADE Technology  7.3.0
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes

OpenGl_TileSampler Class Reference

Tool object used for sampling screen tiles according to estimated pixel variance (used in path tracing engine). To improve GPU thread coherency, rendering window is split into pixel blocks or tiles. The important feature of this approach is that it is possible to keep the same number of tiles for any screen resolution (e.g. 256 tiles can be used for both 512 x 512 window and 1920 x 1080 window). So, a smaller number of tiles allows to increase interactivity (FPS), but at the cost of higher per-frame variance ('noise'). On the contrary a larger number of tiles decrease interactivity, but leads to lower per-frame variance. Note that the total time needed to produce final final image is the same for both cases. More...

#include <OpenGl_TileSampler.hxx>

Public Member Functions

 OpenGl_TileSampler ()
 Creates new tile sampler. More...
 
int SizeX () const
 Returns width of ray-tracing viewport. More...
 
int SizeY () const
 Returns height of ray-tracing viewport. More...
 
int NbTilesX () const
 Returns number of tiles in X dimension. More...
 
int NbTilesY () const
 Returns number of tiles in Y dimension. More...
 
int NbTiles () const
 Returns total number of tiles in viewport. More...
 
void SetSize (const int theSizeX, const int theSizeY)
 Specifies size of ray-tracing viewport. More...
 
int TileArea (const int theX, const int theY) const
 Returns number of pixels in the given tile. More...
 
void GrabVarianceMap (const Handle< OpenGl_Context > &theContext)
 Fetches current error estimation from the GPU and builds 2D discrete distribution for tile sampling. More...
 
void Sample (int &theOffsetX, int &theOffsetY)
 Samples tile location according to estimated error. More...
 
void Reset ()
 Resets tile sampler to initial state. More...
 
void Upload (const Handle< OpenGl_Context > &theContext, const Handle< OpenGl_Texture > &theTexture, const int theNbTilesX, const int theNbTilesY, const bool theAdaptive)
 Uploads offsets of sampled tiles to the given OpenGL texture. More...
 

Static Public Member Functions

static int TileSize ()
 Size of individual tile in pixels. More...
 

Protected Member Functions

float Tile (const int theX, const int theY) const
 Returns tile value (estimated error). More...
 
float & ChangeTile (const int theX, const int theY)
 Returns tile value (estimated error). More...
 

Protected Attributes

std::vector< float > myVarianceMap
 Estimation of visual error per tile. More...
 
std::vector< float > myMarginalMap
 Marginal distribution of 2D error map. More...
 
OpenGl_HaltonSampler mySampler
 Halton sequence generator. More...
 
int mySample
 Index of generated sample. More...
 
int mySizeX
 Width of ray-tracing viewport. More...
 
int mySizeY
 Height of ray-tracing viewport. More...
 
int myTilesX
 Number of tiles in X dimension. More...
 
int myTilesY
 Number of tiles in Y dimension. More...
 

Detailed Description

Tool object used for sampling screen tiles according to estimated pixel variance (used in path tracing engine). To improve GPU thread coherency, rendering window is split into pixel blocks or tiles. The important feature of this approach is that it is possible to keep the same number of tiles for any screen resolution (e.g. 256 tiles can be used for both 512 x 512 window and 1920 x 1080 window). So, a smaller number of tiles allows to increase interactivity (FPS), but at the cost of higher per-frame variance ('noise'). On the contrary a larger number of tiles decrease interactivity, but leads to lower per-frame variance. Note that the total time needed to produce final final image is the same for both cases.

Constructor & Destructor Documentation

◆ OpenGl_TileSampler()

OpenGl_TileSampler::OpenGl_TileSampler ( )

Creates new tile sampler.

Member Function Documentation

◆ ChangeTile()

float& OpenGl_TileSampler::ChangeTile ( const int  theX,
const int  theY 
)
inlineprotected

Returns tile value (estimated error).

◆ GrabVarianceMap()

void OpenGl_TileSampler::GrabVarianceMap ( const Handle< OpenGl_Context > &  theContext)

Fetches current error estimation from the GPU and builds 2D discrete distribution for tile sampling.

◆ NbTiles()

int OpenGl_TileSampler::NbTiles ( ) const
inline

Returns total number of tiles in viewport.

◆ NbTilesX()

int OpenGl_TileSampler::NbTilesX ( ) const
inline

Returns number of tiles in X dimension.

◆ NbTilesY()

int OpenGl_TileSampler::NbTilesY ( ) const
inline

Returns number of tiles in Y dimension.

◆ Reset()

void OpenGl_TileSampler::Reset ( void  )
inline

Resets tile sampler to initial state.

◆ Sample()

void OpenGl_TileSampler::Sample ( int &  theOffsetX,
int &  theOffsetY 
)

Samples tile location according to estimated error.

◆ SetSize()

void OpenGl_TileSampler::SetSize ( const int  theSizeX,
const int  theSizeY 
)

Specifies size of ray-tracing viewport.

◆ SizeX()

int OpenGl_TileSampler::SizeX ( ) const
inline

Returns width of ray-tracing viewport.

◆ SizeY()

int OpenGl_TileSampler::SizeY ( ) const
inline

Returns height of ray-tracing viewport.

◆ Tile()

float OpenGl_TileSampler::Tile ( const int  theX,
const int  theY 
) const
inlineprotected

Returns tile value (estimated error).

◆ TileArea()

int OpenGl_TileSampler::TileArea ( const int  theX,
const int  theY 
) const
inline

Returns number of pixels in the given tile.

◆ TileSize()

static int OpenGl_TileSampler::TileSize ( )
inlinestatic

Size of individual tile in pixels.

◆ Upload()

void OpenGl_TileSampler::Upload ( const Handle< OpenGl_Context > &  theContext,
const Handle< OpenGl_Texture > &  theTexture,
const int  theNbTilesX,
const int  theNbTilesY,
const bool  theAdaptive 
)

Uploads offsets of sampled tiles to the given OpenGL texture.

Field Documentation

◆ myMarginalMap

std::vector<float> OpenGl_TileSampler::myMarginalMap
protected

Marginal distribution of 2D error map.

◆ mySample

int OpenGl_TileSampler::mySample
protected

Index of generated sample.

◆ mySampler

OpenGl_HaltonSampler OpenGl_TileSampler::mySampler
protected

Halton sequence generator.

◆ mySizeX

int OpenGl_TileSampler::mySizeX
protected

Width of ray-tracing viewport.

◆ mySizeY

int OpenGl_TileSampler::mySizeY
protected

Height of ray-tracing viewport.

◆ myTilesX

int OpenGl_TileSampler::myTilesX
protected

Number of tiles in X dimension.

◆ myTilesY

int OpenGl_TileSampler::myTilesY
protected

Number of tiles in Y dimension.

◆ myVarianceMap

std::vector<float> OpenGl_TileSampler::myVarianceMap
protected

Estimation of visual error per tile.


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