Nori  24
warp.h
1 /*
2  This file is part of Nori, a simple educational ray tracer
3 
4  Copyright (c) 2015 by Wenzel Jakob
5 
6  Nori 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  Nori 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 #if !defined(__NORI_WARP_H)
20 #define __NORI_WARP_H
21 
22 #include <nori/common.h>
23 #include <nori/sampler.h>
24 
25 NORI_NAMESPACE_BEGIN
26 
28 class Warp {
29 public:
31  static Vector3f sampleUniformHemisphere(Sampler *sampler, const Normal3f &northPole);
32 
34  static Point2f squareToUniformSquare(const Point2f &sample);
35 
37  static float squareToUniformSquarePdf(const Point2f &p);
38 
40  static Point2f squareToUniformDisk(const Point2f &sample);
41 
43  static float squareToUniformDiskPdf(const Point2f &p);
44 
46  static Vector3f squareToUniformSphere(const Point2f &sample);
47 
49  static float squareToUniformSpherePdf(const Vector3f &v);
50 
58  static Vector3f squareToUniformSphereCap(const Point2f &sample, float cosThetaMax);
59 
61  static float squareToUniformSphereCapPdf(const Vector3f &v, float cosThetaMax);
62 
64  static Vector3f squareToUniformHemisphere(const Point2f &sample);
65 
67  static float squareToUniformHemispherePdf(const Vector3f &v);
68 
70  static Vector3f squareToCosineHemisphere(const Point2f &sample);
71 
73  static float squareToCosineHemispherePdf(const Vector3f &v);
74 
76  static Vector3f squareToBeckmann(const Point2f &sample, float alpha);
77 
79  static float squareToBeckmannPdf(const Vector3f &m, float alpha);
80 
81 
82  static Vector3f squareToUniformTriangle(const Point2f &sample);
83 
84 };
85 
86 NORI_NAMESPACE_END
87 
88 #endif /* __NORI_WARP_H */
Abstract sample generator.
Definition: sampler.h:63
A collection of useful warping functions for importance sampling.
Definition: warp.h:28
static float squareToUniformDiskPdf(const Point2f &p)
Probability density of squareToUniformDisk()
Definition: warp.cpp:53
static Vector3f sampleUniformHemisphere(Sampler *sampler, const Normal3f &northPole)
Uniformly sample a vector on the unit hemisphere with respect to solid angles (naive implementation)
Definition: warp.cpp:25
static float squareToUniformHemispherePdf(const Vector3f &v)
Probability density of squareToUniformHemisphere()
Definition: warp.cpp:77
static float squareToUniformSphereCapPdf(const Vector3f &v, float cosThetaMax)
Probability density of squareToUniformSphereCap()
Definition: warp.cpp:61
static Point2f squareToUniformSquare(const Point2f &sample)
Dummy warping function: takes uniformly distributed points in a square and just returns them.
Definition: warp.cpp:41
static Vector3f squareToCosineHemisphere(const Point2f &sample)
Uniformly sample a vector on the unit hemisphere around the pole (0,0,1) with respect to projected so...
Definition: warp.cpp:81
static Vector3f squareToBeckmann(const Point2f &sample, float alpha)
Warp a uniformly distributed square sample to a Beckmann distribution * cosine for the given 'alpha' ...
Definition: warp.cpp:89
static Vector3f squareToUniformSphere(const Point2f &sample)
Uniformly sample a vector on the unit sphere with respect to solid angles.
Definition: warp.cpp:65
static float squareToCosineHemispherePdf(const Vector3f &v)
Probability density of squareToCosineHemisphere()
Definition: warp.cpp:85
static Vector3f squareToUniformHemisphere(const Point2f &sample)
Uniformly sample a vector on the unit hemisphere around the pole (0,0,1) with respect to solid angles...
Definition: warp.cpp:73
static Point2f squareToUniformDisk(const Point2f &sample)
Uniformly sample a vector on a 2D disk with radius 1, centered around the origin.
Definition: warp.cpp:49
static float squareToBeckmannPdf(const Vector3f &m, float alpha)
Probability density of squareToBeckmann()
Definition: warp.cpp:93
static Vector3f squareToUniformSphereCap(const Point2f &sample, float cosThetaMax)
Uniformly sample a vector on a spherical cap around (0, 0, 1)
Definition: warp.cpp:57
static float squareToUniformSpherePdf(const Vector3f &v)
Probability density of squareToUniformSphere()
Definition: warp.cpp:69
static float squareToUniformSquarePdf(const Point2f &p)
Probability density of squareToUniformSquare()
Definition: warp.cpp:45
3-dimensional surface normal representation
Definition: vector.h:133