Mitsuba Renderer  0.5.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
mitsuba::PhotonMap Class Reference

Implementation of the photon map data structure. More...

#include <mitsuba/render/photonmap.h>

+ Inheritance diagram for mitsuba::PhotonMap:

Public Types

typedef PointKDTree< PhotonPhotonTree
 
typedef PhotonTree::IndexType IndexType
 
typedef PhotonTree::SearchResult SearchResult
 

Public Member Functions

 PhotonMap (size_t photonCount=0)
 Create an empty photon map and reserve memory for a specified number of photons. More...
 
 PhotonMap (Stream *stream, InstanceManager *manager)
 Unserialize a photon map from a binary data stream. More...
 
bool tryAppend (const Photon &photon)
 Try to append a photon to the photon map. More...
 
void setScaleFactor (Float value)
 Scale all photon power values contained in this photon map. More...
 
Float getScaleFactor () const
 Return the power scale factor of this photon map. More...
 
void build (bool recomputeAABB=false)
 Build a photon map over the supplied photons. More...
 
size_t getDepth () const
 Return the depth of the constructed KD-tree. More...
 
bool isFull () const
 Determine if the photon map is completely filled. More...
 
void serialize (Stream *stream, InstanceManager *manager) const
 Serialize a photon map to a binary data stream. More...
 
void dumpOBJ (const std::string &filename)
 Dump the photons to an OBJ file to analyze their spatial distribution. More...
 
std::string toString () const
 Return a string representation. More...
 
virtual const ClassgetClass () const
 Retrieve this object's class. More...
 
\c stl::vector-like interface
void clear ()
 Clear the kd-tree array. More...
 
void resize (size_t size)
 Resize the kd-tree array. More...
 
void reserve (size_t size)
 Reserve a certain amount of memory for the kd-tree array. More...
 
size_t size () const
 Return the size of the kd-tree. More...
 
size_t capacity () const
 Return the capacity of the kd-tree. More...
 
void push_back (const Photon &photon)
 Append a kd-tree photon to the photon array. More...
 
Photonoperator[] (size_t idx)
 Return one of the photons by index. More...
 
const Photonoperator[] (size_t idx) const
 Return one of the photons by index (const version) More...
 
\c Photon map query functions
Spectrum estimateIrradiance (const Point &p, const Normal &n, Float searchRadius, int maxDepth, size_t maxPhotons) const
 Estimate the irradiance at a given surface position. More...
 
Spectrum estimateRadiance (const Intersection &its, Float searchRadius, size_t maxPhotons) const
 Estimate the radiance received from an intersected surface. More...
 
size_t estimateRadianceRaw (const Intersection &its, Float searchRadius, Spectrum &result, int maxDepth) const
 Compute scattered contributions from all photons within the specified radius. More...
 
size_t nnSearch (const Point &p, Float &sqrSearchRadius, size_t k, SearchResult *results) const
 Perform a nearest-neighbor query, see PointKDTree for details. More...
 
size_t nnSearch (const Point &p, size_t k, SearchResult *results) const
 Perform a nearest-neighbor query, see PointKDTree for details. More...
 
- Public Member Functions inherited from mitsuba::SerializableObject
 SerializableObject (Stream *stream, InstanceManager *manager)
 Unserialize a serializable object. 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 Attributes

static Classm_theClass
 
- Static Public Attributes inherited from mitsuba::SerializableObject
static Classm_theClass
 
- Static Public Attributes inherited from Object
static Classm_theClass
 Pointer to the object's class descriptor. More...
 

Protected Member Functions

virtual ~PhotonMap ()
 Virtual destructor. More...
 
- Protected Member Functions inherited from mitsuba::SerializableObject
 SerializableObject ()
 Construct a serializable object. More...
 
virtual ~SerializableObject ()
 Virtual deconstructor. More...
 
- Protected Member Functions inherited from Object
virtual ~Object ()
 Virtual private deconstructor. (Will only be called by ref) More...
 

Protected Attributes

PhotonTree m_kdtree
 
Float m_scale
 

Additional Inherited Members

- 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...
 

Detailed Description

Implementation of the photon map data structure.

Based on Henrik Wann Jensen's book "Realistic Image Synthesis Using Photon Mapping".

Member Typedef Documentation

typedef PhotonTree::SearchResult mitsuba::PhotonMap::SearchResult

Constructor & Destructor Documentation

mitsuba::PhotonMap::PhotonMap ( size_t  photonCount = 0)

Create an empty photon map and reserve memory for a specified number of photons.

mitsuba::PhotonMap::PhotonMap ( Stream stream,
InstanceManager manager 
)

Unserialize a photon map from a binary data stream.

virtual mitsuba::PhotonMap::~PhotonMap ( )
protectedvirtual

Virtual destructor.

Member Function Documentation

void mitsuba::PhotonMap::build ( bool  recomputeAABB = false)
inline

Build a photon map over the supplied photons.

This has to be done once after all photons have been stored, but prior to executing any queries.

size_t mitsuba::PhotonMap::capacity ( ) const
inline

Return the capacity of the kd-tree.

void mitsuba::PhotonMap::clear ( )
inline

Clear the kd-tree array.

void mitsuba::PhotonMap::dumpOBJ ( const std::string &  filename)

Dump the photons to an OBJ file to analyze their spatial distribution.

Spectrum mitsuba::PhotonMap::estimateIrradiance ( const Point p,
const Normal n,
Float  searchRadius,
int  maxDepth,
size_t  maxPhotons 
) const

Estimate the irradiance at a given surface position.

Uses a Simpson filter to smooth the data.

Parameters
pThe surface position for the estimate
nNormal vector of the surface in question
searchRadiusSize of the spherical photon search region
maxDepthIgnore photons that have undergone more than maxDepth interactions
maxPhotonsHow many photon should (at most) be used in the estimate?
Spectrum mitsuba::PhotonMap::estimateRadiance ( const Intersection its,
Float  searchRadius,
size_t  maxPhotons 
) const

Estimate the radiance received from an intersected surface.

Uses a Simpson filter to smooth the data.

Parameters
pThe surface position for the estimate
nNormal vector of the surface in question
searchRadiusSize of the spherical photon search region
maxPhotonsHow many photon should (at most) be used in the estimate?
size_t mitsuba::PhotonMap::estimateRadianceRaw ( const Intersection its,
Float  searchRadius,
Spectrum result,
int  maxDepth 
) const

Compute scattered contributions from all photons within the specified radius.

Does no weighting/filtering/dynamic search radius reduction and simply sums over all photons. Only considers photons with a depth value less than or equal to the maxDepth parameter. This function is meant to be used with progressive photon mapping.

virtual const Class* mitsuba::PhotonMap::getClass ( ) const
virtual

Retrieve this object's class.

Reimplemented from mitsuba::SerializableObject.

size_t mitsuba::PhotonMap::getDepth ( ) const
inline

Return the depth of the constructed KD-tree.

Float mitsuba::PhotonMap::getScaleFactor ( ) const
inline

Return the power scale factor of this photon map.

bool mitsuba::PhotonMap::isFull ( ) const
inline

Determine if the photon map is completely filled.

size_t mitsuba::PhotonMap::nnSearch ( const Point p,
Float sqrSearchRadius,
size_t  k,
SearchResult results 
) const
inline

Perform a nearest-neighbor query, see PointKDTree for details.

size_t mitsuba::PhotonMap::nnSearch ( const Point p,
size_t  k,
SearchResult results 
) const
inline

Perform a nearest-neighbor query, see PointKDTree for details.

Photon& mitsuba::PhotonMap::operator[] ( size_t  idx)
inline

Return one of the photons by index.

const Photon& mitsuba::PhotonMap::operator[] ( size_t  idx) const
inline

Return one of the photons by index (const version)

void mitsuba::PhotonMap::push_back ( const Photon photon)
inline

Append a kd-tree photon to the photon array.

void mitsuba::PhotonMap::reserve ( size_t  size)
inline

Reserve a certain amount of memory for the kd-tree array.

void mitsuba::PhotonMap::resize ( size_t  size)
inline

Resize the kd-tree array.

void mitsuba::PhotonMap::serialize ( Stream stream,
InstanceManager manager 
) const
virtual

Serialize a photon map to a binary data stream.

Implements mitsuba::SerializableObject.

void mitsuba::PhotonMap::setScaleFactor ( Float  value)
inline

Scale all photon power values contained in this photon map.

size_t mitsuba::PhotonMap::size ( ) const
inline

Return the size of the kd-tree.

std::string mitsuba::PhotonMap::toString ( ) const
virtual

Return a string representation.

Reimplemented from Object.

bool mitsuba::PhotonMap::tryAppend ( const Photon photon)
inline

Try to append a photon to the photon map.

Returns
false If the photon map is full

Member Data Documentation

PhotonTree mitsuba::PhotonMap::m_kdtree
protected
Float mitsuba::PhotonMap::m_scale
protected
Class* mitsuba::PhotonMap::m_theClass
static

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