Open CASCADE Technology 7.8.0
|
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. | |
Graphic3d_Vec2i | TileSize () const |
Size of individual tile in pixels. | |
float | VarianceScaleFactor () const |
Scale factor for quantization of visual error (float) into signed integer. | |
int | NbTilesX () const |
Returns number of tiles in X dimension. | |
int | NbTilesY () const |
Returns number of tiles in Y dimension. | |
int | NbTiles () const |
Returns total number of tiles in viewport. | |
const Graphic3d_Vec2i & | ViewSize () const |
Returns ray-tracing viewport. | |
Graphic3d_Vec2i | NbOffsetTiles (bool theAdaptive) const |
Number of tiles within offsets texture. | |
Graphic3d_Vec2i | NbOffsetTilesMax () const |
Maximum number of tiles within offsets texture. | |
Graphic3d_Vec2i | OffsetTilesViewport (bool theAdaptive) const |
Viewport for rendering using offsets texture. | |
Graphic3d_Vec2i | OffsetTilesViewportMax () const |
Maximum viewport for rendering using offsets texture. | |
int | MaxTileSamples () const |
Return maximum number of samples per tile. | |
void | SetSize (const Graphic3d_RenderingParams &theParams, const Graphic3d_Vec2i &theSize) |
Specifies size of ray-tracing viewport and recomputes tile size. | |
void | GrabVarianceMap (const Handle< OpenGl_Context > &theContext, const Handle< OpenGl_Texture > &theTexture) |
Fetches current error estimation from the GPU and builds 2D discrete distribution for tile sampling. | |
void | Reset () |
Resets (restart) tile sampler to initial state. | |
bool | UploadSamples (const Handle< OpenGl_Context > &theContext, const Handle< OpenGl_Texture > &theSamplesTexture, const bool theAdaptive) |
Uploads tile samples to the given OpenGL texture. | |
bool | UploadOffsets (const Handle< OpenGl_Context > &theContext, const Handle< OpenGl_Texture > &theOffsetsTexture, const bool theAdaptive) |
Uploads offsets of sampled tiles to the given OpenGL texture. | |
Protected Member Functions | |
int | tileArea (int theX, int theY) const |
Returns number of pixels in the given tile. | |
Graphic3d_Vec2i | nextTileToSample () |
Samples tile location according to estimated error. | |
bool | upload (const Handle< OpenGl_Context > &theContext, const Handle< OpenGl_Texture > &theSamplesTexture, const Handle< OpenGl_Texture > &theOffsetsTexture, const bool theAdaptive) |
Uploads offsets of sampled tiles to the given OpenGL texture. | |
void | dumpMap (std::ostream &theStream, const Image_PixMapTypedData< int > &theMap, const char *theTitle) const |
Auxiliary method for dumping 2D image map into stream (e.g. for debugging). | |
Protected Attributes | |
Image_PixMapTypedData< unsigned int > | myTiles |
number of samples per tile (initially all 1) | |
Image_PixMapTypedData< unsigned int > | myTileSamples |
number of samples for all pixels within the tile (initially equals to Tile area) | |
Image_PixMapTypedData< float > | myVarianceMap |
Estimation of visual error per tile. | |
Image_PixMapTypedData< int > | myVarianceRaw |
Estimation of visual error per tile (raw data) | |
Image_PixMapTypedData< Graphic3d_Vec2i > | myOffsets |
2D array of tiles redirecting to another tile | |
Image_PixMapTypedData< Graphic3d_Vec2i > | myOffsetsShrunk |
2D array of tiles redirecting to another tile (shrunk) | |
std::vector< float > | myMarginalMap |
Marginal distribution of 2D error map. | |
OpenGl_HaltonSampler | mySampler |
Halton sequence generator. | |
unsigned int | myLastSample |
Index of generated sample. | |
float | myScaleFactor |
scale factor for quantization of visual error (float) into signed integer | |
int | myTileSize |
tile size | |
Graphic3d_Vec2i | myViewSize |
ray-tracing viewport | |
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.
OpenGl_TileSampler::OpenGl_TileSampler | ( | ) |
Creates new tile sampler.
|
protected |
Auxiliary method for dumping 2D image map into stream (e.g. for debugging).
void OpenGl_TileSampler::GrabVarianceMap | ( | const Handle< OpenGl_Context > & | theContext, |
const Handle< OpenGl_Texture > & | theTexture | ||
) |
Fetches current error estimation from the GPU and builds 2D discrete distribution for tile sampling.
|
inline |
Return maximum number of samples per tile.
|
inline |
Number of tiles within offsets texture.
|
inline |
Maximum number of tiles within offsets texture.
|
inline |
Returns total number of tiles in viewport.
|
inline |
Returns number of tiles in X dimension.
|
inline |
Returns number of tiles in Y dimension.
|
protected |
Samples tile location according to estimated error.
|
inline |
Viewport for rendering using offsets texture.
|
inline |
Maximum viewport for rendering using offsets texture.
|
inline |
Resets (restart) tile sampler to initial state.
void OpenGl_TileSampler::SetSize | ( | const Graphic3d_RenderingParams & | theParams, |
const Graphic3d_Vec2i & | theSize | ||
) |
Specifies size of ray-tracing viewport and recomputes tile size.
Returns number of pixels in the given tile.
|
inline |
Size of individual tile in pixels.
|
protected |
Uploads offsets of sampled tiles to the given OpenGL texture.
|
inline |
Uploads offsets of sampled tiles to the given OpenGL texture.
|
inline |
Uploads tile samples to the given OpenGL texture.
|
inline |
Scale factor for quantization of visual error (float) into signed integer.
|
inline |
Returns ray-tracing viewport.
|
protected |
Marginal distribution of 2D error map.
|
protected |
2D array of tiles redirecting to another tile
|
protected |
2D array of tiles redirecting to another tile (shrunk)
|
protected |
Halton sequence generator.
|
protected |
scale factor for quantization of visual error (float) into signed integer
|
protected |
number of samples per tile (initially all 1)
|
protected |
number of samples for all pixels within the tile (initially equals to Tile area)
|
protected |
tile size
|
protected |
Estimation of visual error per tile.
|
protected |
Estimation of visual error per tile (raw data)
|
protected |
ray-tracing viewport