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

Bidirectional path edge data structure. More...

#include <mitsuba/bidir/edge.h>

Public Member Functions

Sampling-related functions
bool sampleNext (const Scene *scene, Sampler *sampler, const PathVertex *pred, const Ray &ray, PathVertex *next, ETransportMode mode)
 Given a ray ray, sample a distance in this direction and fill the edge data structure, as well as its target vertex with content. More...
 
bool perturbDirection (const Scene *scene, const PathVertex *pred, const Ray &ray, Float dist, PathVertex::EVertexType desiredType, PathVertex *next, ETransportMode mode)
 Create a perturbed successor vertex and edge. More...
 

Public Attributes

Enumerations and Fields
const Mediummedium
 Pointer to the medium that contains this edge (where NULL is vacuum) More...
 
Vector d
 Normalized direction vector associated with this edge. More...
 
Float length
 Length of this edge in world-space distance units. More...
 
Spectrum weight [ETransportModes]
 Measurement contribution weight. More...
 
Float pdf [ETransportModes]
 Medium sampling density of the adjacent vertices. More...
 

Query functions

enum  ECachedValues {
  EValueImp = 0x01, EValueRad = 0x02, ECosineImp = 0x04, ECosineRad = 0x08,
  EValue = EValueImp | EValueRad, ECosine = ECosineImp | ECosineRad, EValueCosineImp = EValueImp | ECosineImp, EValueCosineRad = EValueRad | ECosineRad,
  EInverseSquareFalloff = 0x10, ETransmittance = 0x20, EGeometricTerm = ECosine | EInverseSquareFalloff, EGeneralizedGeometricTerm = EGeometricTerm | ETransmittance,
  EEverything = EValue | EGeneralizedGeometricTerm
}
 Evaluate cached quantities associated with this edge. More...
 
Spectrum evalCached (const PathVertex *pred, const PathVertex *succ, unsigned int what) const
 Evaluate cached quantities associated with this edge. More...
 
Float evalPdf (const PathVertex *pred, const PathVertex *succ) const
 Compute the density of a successor node. More...
 
Spectrum evalTransmittance (const PathVertex *pred, const PathVertex *succ) const
 Compute the transmittance between an arbitrary pair of vertices. More...
 
Spectrum evalTransmittance () const
 Return the transmittance value associated with this edge. More...
 
Float evalCosine (const PathVertex *pred, const PathVertex *succ, const PathVertex *base) const
 Evaluate the one of the cosine factors associated with the geometric term over an edge. More...
 

Miscellaneous

bool verify (const Scene *scene, const PathVertex *adjL, const PathVertex *adjE, ETransportMode mode, std::ostream &os) const
 Verify the cached values stored in this path vertex for consistency. More...
 
bool connect (const Scene *scene, const PathEdge *predEdge, const PathVertex *vs, const PathVertex *vt, const PathEdge *succEdge)
 Create a connection edge between two vertices. More...
 
bool pathConnectAndCollapse (const Scene *scene, const PathEdge *predEdge, const PathVertex *vs, const PathVertex *vt, const PathEdge *succEdge, int &interactions)
 Create a connection path between two vertices and collapse it into a single edge that summarizes its properties. More...
 
PathEdgeclone (MemoryPool &pool) const
 Create a deep copy of this edge. More...
 
bool operator== (const PathEdge &edge) const
 Compare this edge against another edge. More...
 
bool operator!= (const PathEdge &edge) const
 Compare this edge against another edge. More...
 
std::string toString () const
 Return a string representation of the information stored in this vertex. More...
 
static bool pathConnect (const Scene *scene, const PathEdge *predEdge, const PathVertex *vs, Path &result, const PathVertex *vt, const PathEdge *succEdge, int maxInteractions, MemoryPool &pool)
 Create a connection path between two vertices. More...
 

Detailed Description

Bidirectional path edge data structure.

The path edge data structure is responsible for representing the transport of light between pairs of scattering or emission events. Amongst other things, it keeps track of the medium that fills the space between adjacent vertices of a Path. Furthermore, it can be used to evaluate and sample the visibility and transmittance functions of the scene.

Although they do not correspond to any real transport, this implementation also places edges next to "supernode" vertices (see PathVertex for a description), which simplifies the implementations of various rendering algorithms that make use of this framework.

See Also
PathVertex
Author
Wenzel Jakob

Member Enumeration Documentation

Evaluate cached quantities associated with this edge.

This function computes the product of certain terms that are cached in this edge and its adjacent vertices. The what parameter specifies the terms to be included; it must be a combination of the flags in the enumeration ECachedValues.

Remarks
This function assumes that pred and succ are the vertices associated with this edge, and that they have not been modified since the edge was created.
Parameters
predThe predecessor vertex of this edge
succThe successor vertex of this edge
Enumerator
EValueImp 
EValueRad 
ECosineImp 
ECosineRad 
EValue 
ECosine 
EValueCosineImp 
EValueCosineRad 
EInverseSquareFalloff 
ETransmittance 
EGeometricTerm 
EGeneralizedGeometricTerm 
EEverything 

Member Function Documentation

PathEdge* mitsuba::PathEdge::clone ( MemoryPool pool) const

Create a deep copy of this edge.

bool mitsuba::PathEdge::connect ( const Scene scene,
const PathEdge predEdge,
const PathVertex vs,
const PathVertex vt,
const PathEdge succEdge 
)

Create a connection edge between two vertices.

This function can be used to create an edge data structure when connecting two separately sampled path vertices. This involves checking that they are mutually visible and computing the attenuation caused by the medium in between (if any).

Parameters
scenePointer to the underlying scene
predEdgePointer to an edge between vs and its predecessor (which is not needed by this function)
vsFirst path vertex to be connected.
vtSecond path vertex to be connected.
succEdgePointer to an edge between vt and its successor (which is not needed by this function)
Returns
true upon success, false when there is no throughput or an inconsistency has been detected.
Spectrum mitsuba::PathEdge::evalCached ( const PathVertex pred,
const PathVertex succ,
unsigned int  what 
) const

Evaluate cached quantities associated with this edge.

This function computes the product of certain terms that are cached in this edge and its adjacent vertices. The what parameter specifies the terms to be included; it must be a combination of the flags in the enumeration ECachedValues.

Remarks
This function assumes that pred and succ are the vertices associated with this edge, and that they have not been modified since the edge was created.
Parameters
predThe predecessor vertex of this edge
succThe successor vertex of this edge
Float mitsuba::PathEdge::evalCosine ( const PathVertex pred,
const PathVertex succ,
const PathVertex base 
) const

Evaluate the one of the cosine factors associated with the geometric term over an edge.

Float mitsuba::PathEdge::evalPdf ( const PathVertex pred,
const PathVertex succ 
) const

Compute the density of a successor node.

This function computes the hypothetical transport-related sampling density of a given successor node conditioned on a specified predecessor when using the sampling technique implemented by sampleNext(). Depending on whether or not the successor node is a medium interaction, the returned value is either a density per unit length or a discrete probability.

Note: this function only computes terms associated with the transport between vertices – to account for the vertices themselves, refer to PathEdge::evalPdf.

Parameters
scenePointer to the underlying scene
predPointer to the preceding vertex
succPointer to the successor vertex
Returns
The computed probability density
Spectrum mitsuba::PathEdge::evalTransmittance ( const PathVertex pred,
const PathVertex succ 
) const

Compute the transmittance between an arbitrary pair of vertices.

This function queries the medium associated with this edge for the transmittance between an arbitrary pair of nodes, pred and succ.

Parameters
predPointer to the preceding vertex
succPointer to the successor vertex
Returns
A spectrally varying transmittance value
Spectrum mitsuba::PathEdge::evalTransmittance ( ) const

Return the transmittance value associated with this edge.

Parameters
predPointer to the preceding vertex
succPointer to the successor vertex
Returns
A spectrally varying transmittance value
bool mitsuba::PathEdge::operator!= ( const PathEdge edge) const
inline

Compare this edge against another edge.

bool mitsuba::PathEdge::operator== ( const PathEdge edge) const

Compare this edge against another edge.

static bool mitsuba::PathEdge::pathConnect ( const Scene scene,
const PathEdge predEdge,
const PathVertex vs,
Path result,
const PathVertex vt,
const PathEdge succEdge,
int  maxInteractions,
MemoryPool pool 
)
static

Create a connection path between two vertices.

This function is conceptually similar to connect(). However, instead of a single edge, it potentially generates an entire connection path, where intermediate vertices are either index-matched medium transitions or other surface scattering events of type BSDF::ENull.

This is important to support efficient direct illumination sampling through such surfaces (e.g. a heterogeneous medium or a leaf with textured alpha transparency).

Parameters
scenePointer to the underlying scene
predEdgePointer to an edge between vs and its predecessor (which is not needed by this function)
vsFirst path vertex to be connected.
resultA path data structure that will be filled with the created vertices and edges
vtSecond path vertex to be connected.
succEdgePointer to an edge between vt and its successor (which is not needed by this function)
maxInteractionsSpecifies the maximum permissible number of intermediate vertices (-1 == arbitrarily many)
poolReference to memory pool that will be used to allocate edges and vertices.
Returns
true upon success, false when there is no throughput or an inconsistency has been detected.
bool mitsuba::PathEdge::pathConnectAndCollapse ( const Scene scene,
const PathEdge predEdge,
const PathVertex vs,
const PathVertex vt,
const PathEdge succEdge,
int &  interactions 
)

Create a connection path between two vertices and collapse it into a single edge that summarizes its properties.

This function can be thought of as being half-way in between connect() and pathConnect(). Like pathConnect(), it potentially generates an entire connection path between the specified endpoints, where intermediate vertices are either index-matched medium transitions or other surface scattering events of type BSDF::ENull.

This is important to support efficient direct illumination sampling through such surfaces (e.g. a heterogeneous medium or a leaf with textured alpha transparency).

However, this variant does not return the intermediate vertices and edges – instead, everything is collapsed into a single edge that captures the aggregate weight and probability densities.

This function is used by bidirectional path tracing, since it creates connections through index-matched boundaries but does not require explicit knowledge about the associated path vertices.

Parameters
scenePointer to the underlying scene
predEdgePointer to an edge between vs and its predecessor (which is not needed by this function)
vsFirst path vertex to be connected.
vtSecond path vertex to be connected.
succEdgePointer to an edge between vt and its successor (which is not needed by this function)
interactionsSpecifies the maximum permissible number of index-matched medium transitions or BSDF::ENull scattering events on the way to the light source. (interactions<0 means arbitrarily many). When the function is successful, this parameter will additionally be used to return the actual number of intermediate interactions.
Returns
true upon success, false when there is no throughput or an inconsistency has been detected.
bool mitsuba::PathEdge::perturbDirection ( const Scene scene,
const PathVertex pred,
const Ray ray,
Float  dist,
PathVertex::EVertexType  desiredType,
PathVertex next,
ETransportMode  mode 
)

Create a perturbed successor vertex and edge.

This function behaves similar to sampleNext() in that it generates a successor edge and vertex.

The main difference is that the desired direction, distance, and type of the successor vertex are all specified, which makes the sampling process completely deterministic. This is useful for implementing path-space perturbation strategies.

Parameters
scenePointer to the underlying scene
predPointer to the preceding vertex
raySpecifies the direction and origin associated with one endpoint of the edge. The sampling routine will then determine the other endpoint.
distSpecifies the desired distance between the current vertex and succ (this only applies when desiredType=EMediumInteraction)
desiredTypeSpecifies the desired vertex type of succ.
succPointer to an unused vertex data structure, which will be filled with information about the successor vertex
modeSpecifies whether radiance or importance is being transported
Returns
true on success
bool mitsuba::PathEdge::sampleNext ( const Scene scene,
Sampler sampler,
const PathVertex pred,
const Ray ray,
PathVertex next,
ETransportMode  mode 
)

Given a ray ray, sample a distance in this direction and fill the edge data structure, as well as its target vertex with content.

Parameters
scenePointer to the underlying scene
samplerPointer to a sample generator
predPointer to the preceding vertex
raySpecifies the direction and origin associated with one endpoint of the edge. The sampling routine will then determine the other endpoint.
succPointer to an unused vertex data structure, which will be filled with information about the successor vertex
modeSpecifies whether radiance or importance is being transported
Returns
true on success
std::string mitsuba::PathEdge::toString ( ) const

Return a string representation of the information stored in this vertex.

bool mitsuba::PathEdge::verify ( const Scene scene,
const PathVertex adjL,
const PathVertex adjE,
ETransportMode  mode,
std::ostream &  os 
) const

Verify the cached values stored in this path vertex for consistency.

This function re-evaluates a series of quantities associated with this edge and compares them to locally cached values. If any mismatch is found, the function sends debug output to a specified output stream and returns false.

Parameters
scenePointer to the underlying scene
predPointer to the vertex adjacent in the emitter direction or NULL
succPointer to the vertex adjacent in the sensor direction or NULL
modeTransport mode – disambiguates the meaning of pred and succ.
osTarget output stream for error messages

Member Data Documentation

Vector mitsuba::PathEdge::d

Normalized direction vector associated with this edge.

The direction always points along the light path (from the light)

Float mitsuba::PathEdge::length

Length of this edge in world-space distance units.

Note that edges adjacent to supernodes have length zero to mark them as such.

const Medium* mitsuba::PathEdge::medium

Pointer to the medium that contains this edge (where NULL is vacuum)

Float mitsuba::PathEdge::pdf[ETransportModes]

Medium sampling density of the adjacent vertices.

This field stores the probability of sampling the preceding and successive path vertices using the sampling technique implemented by the function PathEdge::sampleNext(). Depending on whether or not they are medium interactions, this eintries either store a density per unit length or a discrete probability.

Spectrum mitsuba::PathEdge::weight[ETransportModes]

Measurement contribution weight.

This field stores the terms of the path-space measurement contribution function that are coupled to this specific edge divided by the associated density function.

More specifically, it stores the transmittance of the medium across this edge divided by the density per unit length of the adjacent vertices int the radiance and importance transport directions (hence, it is an array with two entries).

Note that this field only accounts for medium-related terms. The interactions with vertices are captured by PathVertex::weight.


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