Mitsuba Renderer  0.5.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
mitsuba::TMIPMap< Value, QuantizedValue > Class Template Reference

MIP map class with support for elliptically weighted averages. More...

#include <mitsuba/render/mipmap.h>

+ Inheritance diagram for mitsuba::TMIPMap< Value, QuantizedValue >:

Classes

struct  MIPMapHeader
 Header file for MIP map cache files. More...
 

Public Types

typedef BlockedArray
< QuantizedValue > 
Array2DType
 Use a blocked array to store MIP map data. More...
 
typedef
ReconstructionFilter::EBoundaryCondition 
EBoundaryCondition
 Shortcut. More...
 

Public Member Functions

 TMIPMap (Bitmap *bitmap_, Bitmap::EPixelFormat pixelFormat, Bitmap::EComponentFormat componentFormat, const ReconstructionFilter *rfilter, EBoundaryCondition bcu=ReconstructionFilter::ERepeat, EBoundaryCondition bcv=ReconstructionFilter::ERepeat, EMIPFilterType filterType=EEWA, Float maxAnisotropy=20.0f, fs::path cacheFilename=fs::path(), uint64_t timestamp=0, Float maxValue=1.0f, Spectrum::EConversionIntent intent=Spectrum::EReflectance)
 Construct a new MIP map from the given bitmap. More...
 
 TMIPMap (fs::path cacheFilename, Float maxAnisotropy=20.0f)
 Construct a new MIP map from a previously created cache file. More...
 
 ~TMIPMap ()
 Release all memory. More...
 
size_t getBufferSize () const
 Return the size of all buffers. More...
 
const Vector2igetSize () const
 Return the size of the underlying full resolution texture. More...
 
int getWidth () const
 Return the width of the represented texture. More...
 
int getHeight () const
 Return the height of the represented texture. More...
 
int getLevels () const
 Return the number of mip-map levels. More...
 
EMIPFilterType getFilterType () const
 Return the filter type that is used to pre-filter lookups. More...
 
const Value & getMinimum () const
 Get the component-wise maximum at the zero level. More...
 
const Value & getMaximum () const
 Get the component-wise minimum. More...
 
const Value & getAverage () const
 Get the component-wise average. More...
 
const Array2DTypegetArray (int level=0) const
 Return the blocked array used to store a given MIP level. More...
 
ref< BitmaptoBitmap (int level=0) const
 Return a bitmap representation of the given level. More...
 
Value evalTexel (int level, int x, int y) const
 Return the texture value at a texel specified using integer coordinates, while accounting for boundary conditions. More...
 
Value evalBox (int level, const Point2 &uv) const
 Evaluate the texture at the given resolution using a box filter. More...
 
Value evalBilinear (int level, const Point2 &uv) const
 Evaluate the texture using fractional texture coordinates and bilinear interpolation. The desired MIP level must be specified. More...
 
void evalGradientBilinear (int level, const Point2 &uv, Value *gradient) const
 Evaluate the gradient of the texture at the given MIP level. More...
 
Value eval (const Point2 &uv, const Vector2 &d0, const Vector2 &d1) const
 Perform a filtered texture lookup using the configured method. More...
 
std::string toString () const
 Return a human-readable string representation. More...
 
virtual const ClassgetClass () const
 Retrieve this object's class. More...
 
- Public Member Functions inherited from Object
 Object ()
 Construct a new object. More...
 
int getRefCount () const
 Return the current reference count. More...
 
void incRef () const
 Increase the reference count of the object by one. More...
 
void decRef (bool autoDeallocate=true) const
 Decrease the reference count of the object and possibly deallocate it. More...
 

Static Public Member Functions

static bool validateCacheFile (const fs::path &path, uint64_t timestamp, Bitmap::EPixelFormat pixelFormat, EBoundaryCondition bcu, EBoundaryCondition bcv, EMIPFilterType filterType, Float gamma)
 Check if a MIP map cache is up-to-date and matches the desired configuration. More...
 
- Static Public Member Functions inherited from Object
static void staticInitialization ()
 Initializes the built-in reference count debugger (if enabled) More...
 
static void staticShutdown ()
 Free the memory taken by staticInitialization() More...
 

Static Public Attributes

static Classm_theClass = new Class("MIPMap", false, "Object")
 
- Static Public Attributes inherited from Object
static Classm_theClass
 Pointer to the object's class descriptor. More...
 

Protected Member Functions

Value evalEWA (int level, const Point2 &uv, Float A, Float B, Float C) const
 Calculate the elliptically weighted average of a sample and associated Jacobian. More...
 
- Protected Member Functions inherited from Object
virtual ~Object ()
 Virtual private deconstructor. (Will only be called by ref) More...
 

Detailed Description

template<typename Value, typename QuantizedValue>
class mitsuba::TMIPMap< Value, QuantizedValue >

MIP map class with support for elliptically weighted averages.

This class stores a precomputed collection of images that provide a hierarchy of resolution levels of an input image. These are used to prefilter texture lookups at render time, reducing aliasing artifacts. The implementation here supports non-power-of two images, different data types and quantizations thereof, as well as the computation of elliptically weighted averages that account for the anisotropy of texture lookups in UV space.

Generating good mip maps is costly, and therefore this class provides the means to cache them on disk if desired.

Template Parameters
ValueThis class can be parameterized to yield MIP map classes for RGB values, color spectra, or just plain floats. This parameter specifies the underlying type.
QuantizedValueIf desired, the MIP map can store its contents using a quantized representation (e.g. half precision). In that case, this type denotes the associated data type.

Member Typedef Documentation

template<typename Value , typename QuantizedValue >
typedef BlockedArray<QuantizedValue> mitsuba::TMIPMap< Value, QuantizedValue >::Array2DType

Use a blocked array to store MIP map data.

template<typename Value , typename QuantizedValue >
typedef ReconstructionFilter::EBoundaryCondition mitsuba::TMIPMap< Value, QuantizedValue >::EBoundaryCondition

Shortcut.

Constructor & Destructor Documentation

template<typename Value , typename QuantizedValue >
mitsuba::TMIPMap< Value, QuantizedValue >::TMIPMap ( Bitmap bitmap_,
Bitmap::EPixelFormat  pixelFormat,
Bitmap::EComponentFormat  componentFormat,
const ReconstructionFilter rfilter,
EBoundaryCondition  bcu = ReconstructionFilter::ERepeat,
EBoundaryCondition  bcv = ReconstructionFilter::ERepeat,
EMIPFilterType  filterType = EEWA,
Float  maxAnisotropy = 20.0f,
fs::path  cacheFilename = fs::path(),
uint64_t  timestamp = 0,
Float  maxValue = 1.0f,
Spectrum::EConversionIntent  intent = Spectrum::EReflectance 
)
inline

Construct a new MIP map from the given bitmap.

Parameters
bitmapAn arbitrary input bitmap that will (if necessary) be transformed into a representation that is compatible with the desired MIP map pixel format.

pixelFormat A pixel format that is compatible with the Value and QuantizedValue types

componentFormat A component format that is compatible with the Value type.

Parameters
rfilterAn image reconstruction filter that is used to create progressively lower-resolution versions of the input image.
bcuSpecifies how to handle texture lookups outside of the horizontal range [0, 1]
bcvSpecifies how to handle texture lookups outside of the vertical range [0, 1]
filterTypeDenotes the desired filter type to use for lookups; the default is to use elliptically weighted averages.
maxAnisotropyDenotes the highest tolerated anisotropy of the lookup kernel. This is necessary to bound the computational cost of filtered lookups.
cacheFilenameOptional filename of a memory-mapped cache file that is used to keep MIP map data out of core, and to avoid having to load and downsample textures over and over again in subsequent Mitsuba runs.
maxValueMaximum image value. This is used to clamp out-of-range values that occur during the image resampling process
intentWhen an RGB image is transformed into a spectral representation, this parameter specifies what conversion method should be used. See Spectrum::EConversionIntent for further details.
template<typename Value , typename QuantizedValue >
mitsuba::TMIPMap< Value, QuantizedValue >::TMIPMap ( fs::path  cacheFilename,
Float  maxAnisotropy = 20.0f 
)
inline

Construct a new MIP map from a previously created cache file.

Parameters
cacheFilenameFilename of a memory-mapped cache file that is used to keep MIP map data out of core, and to avoid having to load and downsample textures over and over again in subsequent Mitsuba runs.
maxAnisotropyDenotes the highest tolerated anisotropy of the lookup kernel. This is necessary to bound the computational cost of filtered lookups. This parameter is independent of the cache file that was previously created.
template<typename Value , typename QuantizedValue >
mitsuba::TMIPMap< Value, QuantizedValue >::~TMIPMap ( )
inline

Release all memory.

Member Function Documentation

template<typename Value , typename QuantizedValue >
Value mitsuba::TMIPMap< Value, QuantizedValue >::eval ( const Point2 uv,
const Vector2 d0,
const Vector2 d1 
) const
inline

Perform a filtered texture lookup using the configured method.

template<typename Value , typename QuantizedValue >
Value mitsuba::TMIPMap< Value, QuantizedValue >::evalBilinear ( int  level,
const Point2 uv 
) const
inline

Evaluate the texture using fractional texture coordinates and bilinear interpolation. The desired MIP level must be specified.

template<typename Value , typename QuantizedValue >
Value mitsuba::TMIPMap< Value, QuantizedValue >::evalBox ( int  level,
const Point2 uv 
) const
inline

Evaluate the texture at the given resolution using a box filter.

template<typename Value , typename QuantizedValue >
Value mitsuba::TMIPMap< Value, QuantizedValue >::evalEWA ( int  level,
const Point2 uv,
Float  A,
Float  B,
Float  C 
) const
inlineprotected

Calculate the elliptically weighted average of a sample and associated Jacobian.

template<typename Value , typename QuantizedValue >
void mitsuba::TMIPMap< Value, QuantizedValue >::evalGradientBilinear ( int  level,
const Point2 uv,
Value *  gradient 
) const
inline

Evaluate the gradient of the texture at the given MIP level.

template<typename Value , typename QuantizedValue >
Value mitsuba::TMIPMap< Value, QuantizedValue >::evalTexel ( int  level,
int  x,
int  y 
) const
inline

Return the texture value at a texel specified using integer coordinates, while accounting for boundary conditions.

template<typename Value , typename QuantizedValue >
const Array2DType& mitsuba::TMIPMap< Value, QuantizedValue >::getArray ( int  level = 0) const
inline

Return the blocked array used to store a given MIP level.

template<typename Value , typename QuantizedValue >
const Value& mitsuba::TMIPMap< Value, QuantizedValue >::getAverage ( ) const
inline

Get the component-wise average.

template<typename Value , typename QuantizedValue >
size_t mitsuba::TMIPMap< Value, QuantizedValue >::getBufferSize ( ) const
inline

Return the size of all buffers.

template<typename Value , typename QuantizedValue >
const Class * mitsuba::TMIPMap< Value, QuantizedValue >::getClass ( ) const
virtual

Retrieve this object's class.

Reimplemented from Object.

template<typename Value , typename QuantizedValue >
EMIPFilterType mitsuba::TMIPMap< Value, QuantizedValue >::getFilterType ( ) const
inline

Return the filter type that is used to pre-filter lookups.

template<typename Value , typename QuantizedValue >
int mitsuba::TMIPMap< Value, QuantizedValue >::getHeight ( ) const
inline

Return the height of the represented texture.

template<typename Value , typename QuantizedValue >
int mitsuba::TMIPMap< Value, QuantizedValue >::getLevels ( ) const
inline

Return the number of mip-map levels.

template<typename Value , typename QuantizedValue >
const Value& mitsuba::TMIPMap< Value, QuantizedValue >::getMaximum ( ) const
inline

Get the component-wise minimum.

template<typename Value , typename QuantizedValue >
const Value& mitsuba::TMIPMap< Value, QuantizedValue >::getMinimum ( ) const
inline

Get the component-wise maximum at the zero level.

template<typename Value , typename QuantizedValue >
const Vector2i& mitsuba::TMIPMap< Value, QuantizedValue >::getSize ( ) const
inline

Return the size of the underlying full resolution texture.

template<typename Value , typename QuantizedValue >
int mitsuba::TMIPMap< Value, QuantizedValue >::getWidth ( ) const
inline

Return the width of the represented texture.

template<typename Value , typename QuantizedValue >
ref<Bitmap> mitsuba::TMIPMap< Value, QuantizedValue >::toBitmap ( int  level = 0) const
inline

Return a bitmap representation of the given level.

template<typename Value , typename QuantizedValue >
std::string mitsuba::TMIPMap< Value, QuantizedValue >::toString ( ) const
inlinevirtual

Return a human-readable string representation.

Reimplemented from Object.

template<typename Value , typename QuantizedValue >
static bool mitsuba::TMIPMap< Value, QuantizedValue >::validateCacheFile ( const fs::path &  path,
uint64_t  timestamp,
Bitmap::EPixelFormat  pixelFormat,
EBoundaryCondition  bcu,
EBoundaryCondition  bcv,
EMIPFilterType  filterType,
Float  gamma 
)
inlinestatic

Check if a MIP map cache is up-to-date and matches the desired configuration.

Parameters
pathFile system path of the MIP map cache
timestampTimestamp of the original texture file
bcuHorizontal boundary condition used when creating the MIP map pyramid
bcvVertical boundary condition used when creating the MIP map pyramid
gammaIf nonzero, it is verified that the provided gamma value matches that of the cache file.
Returns
true if the texture file is good for use

Member Data Documentation

template<typename Value , typename QuantizedValue >
Class * mitsuba::TMIPMap< Value, QuantizedValue >::m_theClass = new Class("MIPMap", false, "Object")
static

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