Mitsuba Renderer  0.5.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
warp.h
Go to the documentation of this file.
1 /*
2  This file is part of Mitsuba, a physically based rendering system.
3 
4  Copyright (c) 2007-2014 by Wenzel Jakob and others.
5 
6  Mitsuba is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License Version 3
8  as published by the Free Software Foundation.
9 
10  Mitsuba is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18 
19 #pragma once
20 #if !defined(__MITSUBA_CORE_WARP_H_)
21 #define __MITSUBA_CORE_WARP_H_
22 
23 #include <mitsuba/core/frame.h>
24 
26 
27 /**
28  * \brief Implements common warping techniques that map from the unit
29  * square to other domains, such as spheres, hemispheres, etc.
30  *
31  * The main application of this class is to generate uniformly
32  * distributed or weighted point sets in certain common target domains.
33  */
34 namespace warp {
35  // =============================================================
36  //! @{ \name Warping techniques related to spheres and subsets
37  // =============================================================
38 
39  /// Uniformly sample a vector on the unit sphere with respect to solid angles
40  extern MTS_EXPORT_CORE Vector squareToUniformSphere(const Point2 &sample);
41 
42  /// Density of \ref squareToUniformSphere() with respect to solid angles
44 
45  /// Uniformly sample a vector on the unit hemisphere with respect to solid angles
47 
48  /// Density of \ref squareToUniformHemisphere() with respect to solid angles
50 
51  /// Sample a cosine-weighted vector on the unit hemisphere with respect to solid angles
53 
54  /// Density of \ref squareToCosineHemisphere() with respect to solid angles
56  { return INV_PI * Frame::cosTheta(d); }
57 
58  /**
59  * \brief Uniformly sample a vector that lies within a given
60  * cone of angles around the Z axis
61  *
62  * \param cosCutoff Cosine of the cutoff angle
63  * \param sample A uniformly distributed sample on \f$[0,1]^2\f$
64  */
65  extern MTS_EXPORT_CORE Vector squareToUniformCone(Float cosCutoff, const Point2 &sample);
66 
67  /**
68  * \brief Uniformly sample a vector that lies within a given
69  * cone of angles around the Z axis
70  *
71  * \param cosCutoff Cosine of the cutoff angle
72  * \param sample A uniformly distributed sample on \f$[0,1]^2\f$
73  */
75  return INV_TWOPI / (1-cosCutoff);
76  }
77 
78  //! @}
79  // =============================================================
80 
81  // =============================================================
82  //! @{ \name Warping techniques that operate in the plane
83  // =============================================================
84 
85  /// Uniformly sample a vector on a 2D disk
86  extern MTS_EXPORT_CORE Point2 squareToUniformDisk(const Point2 &sample);
87 
88  /// Density of \ref squareToUniformDisk per unit area
89  extern MTS_EXPORT_CORE inline Float squareToUniformDiskPdf() { return INV_PI; }
90 
91  /// Low-distortion concentric square to disk mapping by Peter Shirley (PDF: 1/PI)
93 
94  /// Inverse of the mapping \ref squareToUniformDiskConcentric
96 
97  /// Density of \ref squareToUniformDisk per unit area
99 
100  /// Convert an uniformly distributed square sample into barycentric coordinates
102 
103  /**
104  * \brief Sample a point on a 2D standard normal distribution
105  *
106  * Internally uses the Box-Muller transformation
107  */
108  extern MTS_EXPORT_CORE Point2 squareToStdNormal(const Point2 &sample);
109 
110  /// Density of \ref squareToStdNormal per unit area
112 
113  /// Warp a uniformly distributed square sample to a 2D tent distribution
114  extern MTS_EXPORT_CORE Point2 squareToTent(const Point2 &sample);
115 
116  /**
117  * \brief Warp a uniformly distributed sample on [0, 1] to a nonuniform
118  * tent distribution with nodes <tt>{a, b, c}</tt>
119  */
121 
122  //! @}
123  // =============================================================
124 };
125 
127 
128 #endif /* __MITSUBA_CORE_WARP_H_ */
Float squareToUniformDiskConcentricPdf()
Density of squareToUniformDisk per unit area.
Definition: warp.h:98
Point2 uniformDiskToSquareConcentric(const Point2 &p)
Inverse of the mapping squareToUniformDiskConcentric.
Point2 squareToStdNormal(const Point2 &sample)
Sample a point on a 2D standard normal distribution.
Float squareToUniformHemispherePdf()
Density of squareToUniformHemisphere() with respect to solid angles.
Definition: warp.h:49
Float squareToUniformConePdf(Float cosCutoff)
Uniformly sample a vector that lies within a given cone of angles around the Z axis.
Definition: warp.h:74
#define MTS_EXPORT_CORE
Definition: getopt.h:29
Point2 squareToUniformDisk(const Point2 &sample)
Uniformly sample a vector on a 2D disk.
#define MTS_NAMESPACE_BEGIN
Definition: platform.h:137
Float squareToUniformSpherePdf()
Density of squareToUniformSphere() with respect to solid angles.
Definition: warp.h:43
Float intervalToNonuniformTent(Float a, Float b, Float c, Float sample)
Warp a uniformly distributed sample on [0, 1] to a nonuniform tent distribution with nodes {a...
Float squareToStdNormalPdf(const Point2 &pos)
Density of squareToStdNormal per unit area.
#define INV_FOURPI
Definition: constants.h:93
Point2 squareToUniformTriangle(const Point2 &sample)
Convert an uniformly distributed square sample into barycentric coordinates.
#define INV_PI
Definition: constants.h:91
#define INV_TWOPI
Definition: constants.h:92
Float squareToCosineHemispherePdf(const Vector &d)
Density of squareToCosineHemisphere() with respect to solid angles.
Definition: warp.h:55
Vector squareToUniformHemisphere(const Point2 &sample)
Uniformly sample a vector on the unit hemisphere with respect to solid angles.
Definition: fwd.h:99
Float squareToUniformDiskPdf()
Density of squareToUniformDisk per unit area.
Definition: warp.h:89
Vector squareToCosineHemisphere(const Point2 &sample)
Sample a cosine-weighted vector on the unit hemisphere with respect to solid angles.
Definition: fwd.h:96
Vector squareToUniformSphere(const Point2 &sample)
Uniformly sample a vector on the unit sphere with respect to solid angles.
Point2 squareToTent(const Point2 &sample)
Warp a uniformly distributed square sample to a 2D tent distribution.
Vector squareToUniformCone(Float cosCutoff, const Point2 &sample)
Uniformly sample a vector that lies within a given cone of angles around the Z axis.
#define MTS_NAMESPACE_END
Definition: platform.h:138
Point2 squareToUniformDiskConcentric(const Point2 &sample)
Low-distortion concentric square to disk mapping by Peter Shirley (PDF: 1/PI)