Title: Importance Sampling of Environment Maps
1Importance Sampling of Environment Maps
- Huamin Wang, Dave Lillethun
- whmin, davel_at_cc.gatech.edu
- Georgia Institute of Technology
2Overview
- Problem Definition
- An Importance Metric for Environment Maps
- Structured Sampling
- Hierarchical Stratification1
- A Penrose tiling2
- Centroid Voronoi3
- Result and Conclusion
- Sameer Agarwal, Ravi Ramamoorthi, Serge Belongie
and Henrik Wann Jensen, Structured Importance
Sampling of Environment Maps, SIGGRAPH 2003. - Victor Ostromoukhov, Charles Donohue,
Pierre-Marc Jodoin, Fast Hierarchical Importance
Sampling with Blue Noise Properties, Proceedings
of ACM SIGGRAPH 2004, ACM Transactions on
Graphics, 23(3), 488-495, 2004. - DU, Q., FABER, V., AND GUNZBURGER, M. 1999.
Centroidal Voronoi tessellations Applications
and algorithms. SIAM Review 41, 4 (Dec.), 637.676.
3Problem Definition
- Whats an environment map?
- An image describing the background radiance
distribution according to the incident direction.
Angular mapping
Spherical mapping (used in Paul Debevecs Light
Probe Image Gallery)
4Problem Definition
- The old usage of the environment map is to treat
it as a simple background image. - ray tracing if a ray does not intersect
anything local, then use the ray direction to
acquire the background intensity. - Objects are illuminated by some fake light
sources. - Only use when the material is purely specular.
5Problem Definition
- Here we treat the environment map as a real
illumination map - It represents a continuous light source
distribution over the whole angular space. - Advantage 1 realistic illumination effects
- Advantage 2 soft shadows
Similar to an area light source, we use a series
of distant/point light sources to approximate
the Environment light source.
6Problem Definition
- Problem
- We wish to use the traditional rendering
pipeline by discretizing the continuous
illumination create a series of distant light
sources. - However, a naïve implementation will quickly
lead us to the efficiency problem - Let each pixel be a light source. If rendering a
scene with a single light source takes 1 minute,
for a 640640 image, we need 640640 minutes
284 days!!!
7Problem Definition
- Instead of using all pixels, we would like to
choose only a few light sources (samples). - Using those samples will not cause large error
compared with using the whole environment
illumination. - Two factors determine the quality of this choice
- The area (solid angle)
- The intensity
8The Importance Metric
- We need a metric to balance between the area and
intensity factors. Agarwal 2003 suggested the
following equation - According to the paper, this equation is based on
observation and experiments. There is no
theoretical base.
? solid angle L luminance
Sameer Agarwal, Ravi Ramamoorthi, Serge Belongie
and Henrik Wann Jensen, Structured Importance
Sampling of Environment Maps, SIGGRAPH 2003.
9The Importance Metric
- To calculate the solid angle for each sample, we
need a Voronoi diagram
2
1
1
3
10 Structured Sampling Hierarchical Stratification
- 1. Segmentation using intensity
- 2. The sample number in each patch is calculated
- 2. Hochbaum-Shmoys Algorithm to select samples in
each patch
11 Structured Sampling A Penrose Tiling
- A Penrose tiling
- Subdivide, subdivide
- They claim that using such a tiling technique can
produce a nearly optimistic solution.
12 Structured Sampling A Penrose Tiling
- 5,000 samples in 0.064 seconds on a 2.6 GHz P4.
Similar results using in Agarwal et al. 2003
took 1393 seconds.
13Structured Sampling Centroid Voronoi
- Why would we like to try a different method?
- Though a Penrose tiling is fast, the sampling
time is not a bottleneck. - The main issue is how to use as few samples as
possible, without greatly affect the rendering
quality.
14Structured Sampling Centroid Voronoi
- Our method starts with a set of initial random
samples, each sample has a Voronoi polygon. - In each iteration, we update each samples
position using the weighted centroid of the
original Voronoi polygon. - Eventually, it will converge to the desired
sampling pattern result.
C1
C2
2
1
Polygon 2
Polygon 1
Polygon 3
3
C3
15Structured Sampling Centroid Voronoi
- Our algorithm can be divided into two components
- Maintain the Voronoi diagram (Huamin)
- Calculate the Centroid using the importance
metric (Dave)
16Structured Sampling Centroid Voronoi
- Maintain the Voronoi diagram? Hard
- Maintain the Delaunay triangulation? Not that
hard. ? - First, create an initial Delaunay triangulation.
- Second, flip those edges if it doesnt satisfy
the Delaunay condition. (whether D is in the
circle defined by A, B, and C.)
17Structured Sampling Centroid Voronoi
- Given a triangulation, can to get the diagram
again? - Well This is hard again, even though they are
dual to each other. - What I did is a simple approximation.
1
2
3
18(No Transcript)
19Structured Sampling Centroid Voronoi
- Let the total sample number be N, the initial
triangulation takes O(NlogN). Maintaining the
triangulation in each iteration only needs a
constant time O(1) in most cases. Converting the
triangulation to the diagram takes O(T) O(N). - T is the total triangle number.
20Calculate the Centroid of aVoronoi Polygon
- Used as a weighting factor to compute new sample
points - Sample points are used as the centers for Voronoi
polygons in the next iteration
? solid angle L luminance
p Voronoi polygon (u,v) pixels in
polygon p
21Importance Metric using Scan Conversion - Concept
- Render the texture (applied to polygons) using
scan conversion
We can sample the intensity of each texel by
reading values from the frame buffer.
22Importance Metric using Scan Conversion - Concept
- Suppose we have a set of triangles that define a
single Voronoi polygon
23Importance Metric using Scan Conversion - Concept
Now we can sample the intensity for this polygon
only.
24Importance Metric using Scan Conversion -
Algorithm
- Inputs
- A list of vertices
- A list of triangles (each has 3 vertices)
- A list of polygons (each is made of n triangles)
- Output
- A list of new polygon centers (sample points)
25Importance Metric using Scan Conversion -
Algorithm
Function position camera so frame buffer is
same size as environment map for each polygon
clear the frame buffer for each
triangle in the polygon map texture
coordinates to the triangle as a 2-D texture map
draw the triangle in 2-D space for
each pixel in the frame buffer
read pixel intensity, L, from the frame buffer
calculate the pixel solid angle, w
calculate importance metric, Gamma(L, w),
increment Gamma sum calculate Gamma v, increment weighted position sum
calculate new polygon center sum(Gamma v) / sum(Gamma) return list of new polygon
centers
26Importance Metric using the GPU
- The scan conversion algorithm is accurate but
slow - Using the GPU has speed advantages
- All polygons may be rendered at once
- Per pixel importance metric (Gamma) calculation
is parallelized in the GPU
27Importance Metric using the GPU - Concept
- Render all polygons at the same time
Label the triangles with the polygons they belong
to So the polygon each pixel belongs to is
known.
28Importance Metric using the GPU - Algorithm
struct vertexOutput float4 Position
POSITION float3 TexCoord
TEXCOORD0 vertexOutput find_samples_vertex(f
loat4 Position POSITION,
float3 TexCoord TEXCOORD0,
uniform float4x4 ModelViewPr
oj) vertexOutput Out Out.Position
mul(ModelViewProj, Position) Out.TexCoord
TexCoord return Out
29Importance Metric using the GPU - Algorithm
float3 find_samples_fragment (float3 TexCoord
TEXCOORD0, uniform
float InvTexHeight,
uniform float InvTexWidth,
uniform float PixelAngleRatio,
uniform float SolidAngleMax,
uniform
float SolidAngleExp,
uniform sampler2D EnvironmentMap)
COLOR float3 OutputData float4
TextureData float Luminosity, SolidAngle,
Importance float V TexCoord.y/InvTexHeight -
0.5 TextureData tex2D(EnvironmentMap,
TexCoord.xy) Luminosity (TextureData.r
TextureData.g TextureData.b) / 3.0 SolidAngle
(cos(V PixelAngleRatio) -
cos((V 1.0) PixelAngleRatio))
InvTexWidth Importance Luminosity
pow(min(SolidAngle, SolidAngleMax),
SolidAngleExp) OutputData.r
Importance OutputData.g TexCoord.z //
Polygon ID OutputData.b 0.0 return
OutputData
30Importance Metric using the GPU - Algorithm
Function position camera so frame buffer is
same size as environment map clear the frame
buffer for each polygon for each triangle
in the polygon map texture coordinates to
the triangle as a 2-D texture map draw the
triangle in 2-D space // fragment
shaders do their thing for each pixel in
the frame buffer read the Gamma and polygon
ID from the frame buffer increment Gamma sum
for this polygon calculate Gamma
increment weighted position sum for this polygon
for each polygon calculate new polygon
center sum(Gamma ) / sum(Gamma)
return list of new polygon centers
31Results
- Due to the time limit, we only generated one
result 500 samples
32(No Transcript)
33Conclusions
- Here is some thoughts about environment
illumination sampling - The convergence time depends on the initial
state. - Rendering takes much, much more than sampling.
- All those techniques only consider sampling in
the plane. However, the real environment image
should be mapped to the angular space.
34