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 Medium * | medium |
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... | |
PathEdge * | clone (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... | |
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.
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.
pred
and succ
are the vertices associated with this edge, and that they have not been modified since the edge was created.pred | The predecessor vertex of this edge |
succ | The successor vertex of this edge |
Enumerator | |
---|---|
EValueImp | |
EValueRad | |
ECosineImp | |
ECosineRad | |
EValue | |
ECosine | |
EValueCosineImp | |
EValueCosineRad | |
EInverseSquareFalloff | |
ETransmittance | |
EGeometricTerm | |
EGeneralizedGeometricTerm | |
EEverything |
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).
scene | Pointer to the underlying scene |
predEdge | Pointer to an edge between vs and its predecessor (which is not needed by this function) |
vs | First path vertex to be connected. |
vt | Second path vertex to be connected. |
succEdge | Pointer to an edge between vt and its successor (which is not needed by this function) |
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.
pred
and succ
are the vertices associated with this edge, and that they have not been modified since the edge was created.pred | The predecessor vertex of this edge |
succ | The 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.
scene | Pointer to the underlying scene |
pred | Pointer to the preceding vertex |
succ | Pointer to the successor vertex |
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
.
pred | Pointer to the preceding vertex |
succ | Pointer to the successor vertex |
Spectrum mitsuba::PathEdge::evalTransmittance | ( | ) | const |
Return the transmittance value associated with this edge.
pred | Pointer to the preceding vertex |
succ | Pointer to the successor vertex |
Compare this edge against another edge.
Compare this edge against another edge.
|
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).
scene | Pointer to the underlying scene |
predEdge | Pointer to an edge between vs and its predecessor (which is not needed by this function) |
vs | First path vertex to be connected. |
result | A path data structure that will be filled with the created vertices and edges |
vt | Second path vertex to be connected. |
succEdge | Pointer to an edge between vt and its successor (which is not needed by this function) |
maxInteractions | Specifies the maximum permissible number of intermediate vertices (-1 == arbitrarily many) |
pool | Reference to memory pool that will be used to allocate edges and vertices. |
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.
scene | Pointer to the underlying scene |
predEdge | Pointer to an edge between vs and its predecessor (which is not needed by this function) |
vs | First path vertex to be connected. |
vt | Second path vertex to be connected. |
succEdge | Pointer to an edge between vt and its successor (which is not needed by this function) |
interactions | Specifies 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. |
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.
scene | Pointer to the underlying scene |
pred | Pointer to the preceding vertex |
ray | Specifies the direction and origin associated with one endpoint of the edge. The sampling routine will then determine the other endpoint. |
dist | Specifies the desired distance between the current vertex and succ (this only applies when desiredType=EMediumInteraction ) |
desiredType | Specifies the desired vertex type of succ . |
succ | Pointer to an unused vertex data structure, which will be filled with information about the successor vertex |
mode | Specifies whether radiance or importance is being transported |
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.
scene | Pointer to the underlying scene |
sampler | Pointer to a sample generator |
pred | Pointer to the preceding vertex |
ray | Specifies the direction and origin associated with one endpoint of the edge. The sampling routine will then determine the other endpoint. |
succ | Pointer to an unused vertex data structure, which will be filled with information about the successor vertex |
mode | Specifies whether radiance or importance is being transported |
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
.
scene | Pointer to the underlying scene |
pred | Pointer to the vertex adjacent in the emitter direction or NULL |
succ | Pointer to the vertex adjacent in the sensor direction or NULL |
mode | Transport mode – disambiguates the meaning of pred and succ . |
os | Target output stream for error messages |
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.