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

Abstract sensor interface. More...

#include <mitsuba/render/sensor.h>

+ Inheritance diagram for mitsuba::Sensor:

Public Types

enum  ESensorFlags {
  EDeltaTime = 0x010, ENeedsApertureSample = 0x020, EProjectiveCamera = 0x100, EPerspectiveCamera = 0x200,
  EOrthographicCamera = 0x400, EPositionSampleMapsToPixels = 0x1000, EDirectionSampleMapsToPixels = 0x2000
}
 This list of flags is used to additionally characterize and classify the response functions of different types of sensors. More...
 
- Public Types inherited from mitsuba::AbstractEmitter
enum  EEmitterType { EDeltaDirection = 0x01, EDeltaPosition = 0x02, EOnSurface = 0x04 }
 Flags used to classify the emission profile of different types of emitters. More...
 

Public Member Functions

virtual const ClassgetClass () const
 Retrieve this object's class. More...
 
Additional sensor-related sampling functions
virtual Spectrum sampleRay (Ray &ray, const Point2 &samplePosition, const Point2 &apertureSample, Float timeSample) const =0
 Importance sample a ray according to the sensor response. More...
 
virtual Spectrum sampleRayDifferential (RayDifferential &ray, const Point2 &samplePosition, const Point2 &apertureSample, Float timeSample) const
 Importance sample a ray differential according to the sensor response. More...
 
Float sampleTime (Float sample) const
 Importance sample the temporal part of the sensor response function. More...
 
Additional query functions
virtual Spectrum eval (const Intersection &its, const Vector &d, Point2 &samplePos) const
 Return the emitted importance for the given surface intersection. More...
 
virtual bool getSamplePosition (const PositionSamplingRecord &pRec, const DirectionSamplingRecord &dRec, Point2 &position) const
 Return the sample position associated with a given position and direction sampling record. More...
 
Float pdfTime (const Ray &ray, EMeasure measure) const
 Evaluate the temporal component of the sampling density implemented by the sampleRay() method. More...
 
Float getShutterOpen () const
 Return the time value of the shutter opening event. More...
 
void setShutterOpen (Float time)
 Set the time value of the shutter opening event. More...
 
Float getShutterOpenTime () const
 Return the length, for which the shutter remains open. More...
 
void setShutterOpenTime (Float time)
 Set the length, for which the shutter remains open. More...
 
bool needsTimeSample () const
 Does the method sampleRay() require a uniformly distributed sample for the time-dependent component? More...
 
Miscellaneous
bool needsApertureSample () const
 Does the method sampleRay() require a uniformly distributed sample for the aperture component? More...
 
FilmgetFilm ()
 Return the Film instance associated with this sensor. More...
 
const FilmgetFilm () const
 Return the Film instance associated with this sensor (const) More...
 
Float getAspect () const
 Return the aspect ratio of the sensor and its underlying film. More...
 
SamplergetSampler ()
 Return the sensor's sample generator. More...
 
const SamplergetSampler () const
 Return the sensor's sampler (const version). More...
 
virtual void serialize (Stream *stream, InstanceManager *manager) const
 Serialize this sensor to a binary data stream. More...
 
ConfigurableObject interface
virtual void addChild (const std::string &name, ConfigurableObject *child)
 Add a child ConfigurableObject. More...
 
void addChild (ConfigurableObject *child)
 Add an unnamed child. More...
 
virtual void configure ()
 Configure the object (called once after construction and addition of all child ConfigurableObject instances). More...
 
- Public Member Functions inherited from mitsuba::AbstractEmitter
virtual Spectrum samplePosition (PositionSamplingRecord &pRec, const Point2 &sample, const Point2 *extra=NULL) const
 Importance sample the spatial component of the emission profile. More...
 
virtual Spectrum sampleDirection (DirectionSamplingRecord &dRec, PositionSamplingRecord &pRec, const Point2 &sample, const Point2 *extra=NULL) const
 Conditioned on the spatial component, importance sample the directional part of the emission profile. More...
 
virtual Spectrum sampleDirect (DirectSamplingRecord &dRec, const Point2 &sample) const
 Direct sampling: given a reference point in the scene, sample an emitter position that contributes towards it. More...
 
virtual Spectrum evalPosition (const PositionSamplingRecord &pRec) const
 Evaluate the spatial component of the emission profile. More...
 
virtual Spectrum evalDirection (const DirectionSamplingRecord &dRec, const PositionSamplingRecord &pRec) const
 Evaluate the directional component of the emission profile. More...
 
virtual Float pdfPosition (const PositionSamplingRecord &pRec) const
 Evaluate the spatial component of the sampling density implemented by the samplePosition() method. More...
 
virtual Float pdfDirection (const DirectionSamplingRecord &dRec, const PositionSamplingRecord &pRec) const
 Evaluate the directional component of the sampling density implemented by the sampleDirection() method. More...
 
virtual Float pdfDirect (const DirectSamplingRecord &dRec) const
 Evaluate the probability density of the direct sampling method implemented by the sampleDirect() method. More...
 
uint32_t getType () const
 Return a listing of classification flags combined using binary OR. More...
 
const AnimatedTransformgetWorldTransform () const
 Return the local space to world space transformation. More...
 
void setWorldTransform (AnimatedTransform *trafo)
 Set the local space to world space transformation. More...
 
bool needsPositionSample () const
 Does the method samplePosition() require a uniformly distributed sample for the spatial component? More...
 
bool needsDirectionSample () const
 Does the method sampleDirection() require a uniformly distributed sample for the direction component? More...
 
bool isOnSurface () const
 Does the emitter lie on some kind of surface? More...
 
bool isDegenerate () const
 Does the sensor have a degenerate directional or spatial distribution? More...
 
bool needsDirectSample () const
 Does the method sampleDirect() require a uniformly distributed sample? More...
 
EMeasure getDirectMeasure () const
 Return the measure associated with the sampleDirect() operation. More...
 
MediumgetMedium ()
 Return a pointer to the medium that surrounds the emitter. More...
 
const MediumgetMedium () const
 Return a pointer to the medium that surrounds the emitter (const version) More...
 
ShapegetShape ()
 Return the shape, to which the emitter is currently attached. More...
 
const ShapegetShape () const
 Return the shape, to which the emitter is currently attached (const version) More...
 
virtual ref< ShapecreateShape (const Scene *scene)
 Create a special shape that represents the emitter. More...
 
virtual AABB getAABB () const =0
 Return an axis-aligned box bounding the spatial extents of the emitter. More...
 
void setMedium (Medium *medium)
 Set the medium that surrounds the emitter. More...
 
void addChild (ConfigurableObject *child)
 Add an unnamed child. More...
 
- Public Member Functions inherited from mitsuba::ConfigurableObject
virtual void setParent (ConfigurableObject *parent)
 Notify the ConfigurableObject instance about its parent object. More...
 
void addChild (ConfigurableObject *child)
 Add an unnamed child. More...
 
const std::string & getID () const
 Return the identifier associated with this instance (or "unnamed") More...
 
void setID (const std::string &name)
 Set the identifier associated with this instance. More...
 
const PropertiesgetProperties () const
 Return the properties object that was originally used to create this instance. 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...
 
virtual std::string toString () const
 Return a human-readable string representation of the object's contents. More...
 

Static Public Attributes

static Classm_theClass
 
- Static Public Attributes inherited from mitsuba::AbstractEmitter
static Classm_theClass
 
- Static Public Attributes inherited from mitsuba::ConfigurableObject
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

 Sensor (const Properties &props)
 Construct a new sensor instance. More...
 
 Sensor (Stream *stream, InstanceManager *manager)
 Unserialize a sensor instance from a binary data stream. More...
 
virtual ~Sensor ()
 Virtual destructor. More...
 
- Protected Member Functions inherited from mitsuba::AbstractEmitter
 AbstractEmitter (const Properties &props)
 Construct a new emitter instance. More...
 
 AbstractEmitter (Stream *stream, InstanceManager *manager)
 Unserialize a emitter instance from a binary data stream. More...
 
virtual ~AbstractEmitter ()
 Virtual destructor. More...
 
- Protected Member Functions inherited from mitsuba::ConfigurableObject
virtual ~ConfigurableObject ()
 Virtual destructor. More...
 
 ConfigurableObject (const Properties &props)
 Construct a configurable object. More...
 
 ConfigurableObject (Stream *stream, InstanceManager *manager)
 Unserialize a configurable object. 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

ref< Filmm_film
 
ref< Samplerm_sampler
 
Vector2 m_resolution
 
Vector2 m_invResolution
 
Float m_shutterOpen
 
Float m_shutterOpenTime
 
Float m_aspect
 
- Protected Attributes inherited from mitsuba::AbstractEmitter
ref< const AnimatedTransformm_worldTransform
 
ref< Mediumm_medium
 
Shapem_shape
 
uint32_t m_type
 
- Protected Attributes inherited from mitsuba::ConfigurableObject
Properties m_properties
 

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

Abstract sensor interface.

This class provides an abstract interface to all sensor plugins in Mitsuba. It exposes functions for evaluating and sampling the response function of the sensor, and it allows querying the probability density of the sampling method.

Somewhat curiously, the Sensor class derives from AbstractEmitter. The reason for this is that much like radiance, the spectral response of a sensor can be interpreted as emitted quantity named importance. The Sensor interface thus inherits almost all of the emitter API and only needs to add a few camera-specific methods on top.

The concept of interpreting sensor response as an emitted quantity and the resulting flexibility of being able to dynamically transition between emitter and receiver interpretations of luminaires and sensors is a key insight that enables the construction of powerful bidirectional rendering techniques It is the reason why the API to these components may seem somewhat unorthodox.

In Mitsuba, a sensor can be as simple as an irradiance meter that performs a single measurement along a specified ray, but it can also represent sensors that are more commonly used in computer graphics, such as a perspective camera based on the thin lens equation.

An important difference between a luminaire and a sensor is that the sensor records spectral measurements to a film, and for that reason it needs a mapping between rays and film pixel coordinates. Apart from that, the interfaces are almost identical.

Mitsuba assumes that a sensor always has a form of "shutter", which opens for a certain time, during which the exposure takes place. The sensor itself may also undergo motion while the shutter is open, but a more complicated dependence on time is not allowed.

Member Enumeration Documentation

This list of flags is used to additionally characterize and classify the response functions of different types of sensors.

See Also
AbstractEmitter::EEmitterType
Enumerator
EDeltaTime 

Sensor response contains a Dirac delta term with respect to time.

ENeedsApertureSample 

Does the sampleRay() function need an aperture sample?

EProjectiveCamera 

Is the sensor a projective camera?

EPerspectiveCamera 

Is the sensor a perspective camera?

EOrthographicCamera 

Is the sensor an orthographic camera?

EPositionSampleMapsToPixels 

Does the sample given to samplePosition() determine the pixel coordinates.

EDirectionSampleMapsToPixels 

Does the sample given to sampleDirection() determine the pixel coordinates.

Constructor & Destructor Documentation

mitsuba::Sensor::Sensor ( const Properties props)
protected

Construct a new sensor instance.

mitsuba::Sensor::Sensor ( Stream stream,
InstanceManager manager 
)
protected

Unserialize a sensor instance from a binary data stream.

virtual mitsuba::Sensor::~Sensor ( )
protectedvirtual

Virtual destructor.

Member Function Documentation

virtual void mitsuba::Sensor::addChild ( const std::string &  name,
ConfigurableObject child 
)
virtual

Add a child ConfigurableObject.

Reimplemented from mitsuba::AbstractEmitter.

void mitsuba::Sensor::addChild ( ConfigurableObject child)
inline

Add an unnamed child.

virtual void mitsuba::Sensor::configure ( )
virtual

Configure the object (called once after construction and addition of all child ConfigurableObject instances).

Reimplemented from mitsuba::ConfigurableObject.

Reimplemented in mitsuba::PerspectiveCamera.

virtual Spectrum mitsuba::Sensor::eval ( const Intersection its,
const Vector d,
Point2 samplePos 
) const
virtual

Return the emitted importance for the given surface intersection.

This is function is used when a sensor has been hit by a ray in a particle tracing-style integrator, and it subsequently needs to be queried for the emitted importance along the negative ray direction.

It efficiently computes the product of evalPosition() and evalDirection(), though note that it does not include the cosine foreshortening factor of the latter method.

This function is provided here as a fast convenience function for unidirectional rendering techniques that support intersecting the sensor. The default implementation throws an exception, which states that the method is not implemented.

Parameters
itsAn intersect record that specfies the query position
dA unit vector, which specifies the query direction
resultThis argument is used to return the 2D sample position (i.e. the fractional pixel coordinates) associated with the intersection.
Returns
The emitted importance
Remarks
In the Python API, the signature of this function is spectrum, samplePos = sensor.eval(its, d)
Float mitsuba::Sensor::getAspect ( ) const
inline

Return the aspect ratio of the sensor and its underlying film.

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

Retrieve this object's class.

Reimplemented from mitsuba::AbstractEmitter.

Reimplemented in mitsuba::PerspectiveCamera, and mitsuba::ProjectiveCamera.

Film* mitsuba::Sensor::getFilm ( )
inline

Return the Film instance associated with this sensor.

const Film* mitsuba::Sensor::getFilm ( ) const
inline

Return the Film instance associated with this sensor (const)

virtual bool mitsuba::Sensor::getSamplePosition ( const PositionSamplingRecord pRec,
const DirectionSamplingRecord dRec,
Point2 position 
) const
virtual

Return the sample position associated with a given position and direction sampling record.

Parameters
dRecA direction sampling record, which specifies the query direction
pRecA position sampling record, which specifies the query position
Returns
true if the specified ray is visible by the camera
Remarks
In the Python API, the signature of this function is visible, position = sensor.getSamplePosition(pRec, dRec)
Sampler* mitsuba::Sensor::getSampler ( )
inline

Return the sensor's sample generator.

This is the root sampler, which will later be cloned a number of times to provide each participating worker thread with its own instance (see Scene::getSampler()). Therefore, this sampler should never be used for anything except creating clones.

const Sampler* mitsuba::Sensor::getSampler ( ) const
inline

Return the sensor's sampler (const version).

This is the root sampler, which will later be cloned a number of times to provide each participating worker thread with its own instance (see Scene::getSampler()). Therefore, this sampler should never be used for anything except creating clones.

Float mitsuba::Sensor::getShutterOpen ( ) const
inline

Return the time value of the shutter opening event.

Float mitsuba::Sensor::getShutterOpenTime ( ) const
inline

Return the length, for which the shutter remains open.

bool mitsuba::Sensor::needsApertureSample ( ) const
inline

Does the method sampleRay() require a uniformly distributed sample for the aperture component?

bool mitsuba::Sensor::needsTimeSample ( ) const
inline

Does the method sampleRay() require a uniformly distributed sample for the time-dependent component?

Float mitsuba::Sensor::pdfTime ( const Ray ray,
EMeasure  measure 
) const

Evaluate the temporal component of the sampling density implemented by the sampleRay() method.

virtual Spectrum mitsuba::Sensor::sampleRay ( Ray ray,
const Point2 samplePosition,
const Point2 apertureSample,
Float  timeSample 
) const
pure virtual

Importance sample a ray according to the sensor response.

This function combines all three of the steps of sampling a time, ray position, and direction value. It does not return any auxiliary sampling information and is mainly meant to be used by unidirectional rendering techniques.

Note that this function potentially uses a different sampling strategy compared to the sequence of running sampleArea() and sampleDirection(). The reason for this is that it may be possible to switch to a better technique when sampling both position and direction at the same time.

Parameters
rayA ray data structure to be populated with a position and direction value
samplePositionDenotes the desired sample position in fractional pixel coordinates relative to the crop window of the underlying film.
apertureSampleA uniformly distributed 2D vector that is used to sample a position on the aperture of the sensor if necessary. (Any value is valid when needsApertureSample() == false)
timeSampleA uniformly distributed 1D vector that is used to sample the temporal component of the emission profile. (Or any value when needsTimeSample() == false)
Returns
An importance weight associated with the sampled ray. This accounts for the difference between the sensor response and the sampling density function.
Remarks
In the Python API, the signature of this function is spectrum, ray = sensor.sampleRay(samplePosition, apertureSample)
virtual Spectrum mitsuba::Sensor::sampleRayDifferential ( RayDifferential ray,
const Point2 samplePosition,
const Point2 apertureSample,
Float  timeSample 
) const
virtual

Importance sample a ray differential according to the sensor response.

This function combines all three of the steps of sampling a time, ray position, and direction value. It does not return any auxiliary sampling information and is mainly meant to be used by unidirectional rendering techniques.

Note that this function potentially uses a different sampling strategy compared to the sequence of running sampleArea() and sampleDirection(). The reason for this is that it may be possible to switch to a better technique when sampling both position and direction at the same time.

The default implementation computes differentials using several internal calls to sampleRay(). Subclasses of the Sensor interface may optionally provide a more efficient approach.

Parameters
rayA ray data structure to be populated with a position and direction value
samplePositionDenotes the desired sample position in fractional pixel coordinates relative to the crop window of the underlying film.
apertureSampleA uniformly distributed 2D vector that is used to sample a position on the aperture of the sensor if necessary. (Any value is valid when needsApertureSample() == false)
timeSampleA uniformly distributed 1D vector that is used to sample the temporal component of the emission profile. (Or any value when needsTimeSample() == false)
Returns
An importance weight associated with the sampled ray. This accounts for the difference between the sensor response and the sampling density function.
Remarks
In the Python API, the signature of this function is spectrum, ray = sensor.sampleRayDifferential(samplePosition, apertureSample)
Float mitsuba::Sensor::sampleTime ( Float  sample) const
inline

Importance sample the temporal part of the sensor response function.

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

Serialize this sensor to a binary data stream.

Reimplemented from mitsuba::AbstractEmitter.

Reimplemented in mitsuba::PerspectiveCamera, and mitsuba::ProjectiveCamera.

void mitsuba::Sensor::setShutterOpen ( Float  time)
inline

Set the time value of the shutter opening event.

void mitsuba::Sensor::setShutterOpenTime ( Float  time)

Set the length, for which the shutter remains open.

Member Data Documentation

Float mitsuba::Sensor::m_aspect
protected
ref<Film> mitsuba::Sensor::m_film
protected
Vector2 mitsuba::Sensor::m_invResolution
protected
Vector2 mitsuba::Sensor::m_resolution
protected
ref<Sampler> mitsuba::Sensor::m_sampler
protected
Float mitsuba::Sensor::m_shutterOpen
protected
Float mitsuba::Sensor::m_shutterOpenTime
protected
Class* mitsuba::Sensor::m_theClass
static

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