cgra 408 - victoria university of wellington · course schedule(cgra408 2020t1) week monday...
Post on 02-Aug-2020
0 Views
Preview:
TRANSCRIPT
CGRA 408
Shapes and Intersection
Week 2.3.
Course Schedule (CGRA408 2020T1)
Week Monday Wednesday Friday Note1 (Mar 2,4,6) Course Outline Ray Tracing Overview I Ray Tracing Overview II
Project 1 instruction
2 (Mar 9,11,13) PBRT Intro Shape Intersection P: Ray tracing (Robert)
3 (Mar 16,18,20) T: Blender/Maya (CO332, Graphics Lab)
Camera models P: Lens (Marc)
4 (Mar 23,25,27) Primitive Acceleration 1 Primitive Acceleration 2 P: Acceleration structure (Ruth)
5 (Mar/A. 30,1,3) Project 1 presentationProject 2 instruction
Texture I (Image Texture) P: Texture (Ruth) Project 1
6 (Apr 6,8,10) Texture II (Procedural Texture)
P: Lens (Anna) Good Friday 10 Apr
7 (Apr/M. 27,29,1) Anzac Day observed Radiometry 1 Radiometry 1
8 (May 4,6,8) Project 2 presentation Project 3 instruction
P: Composition (Henry) P: BRDF (Anna) Project 2
9 (May 11,13,15) Guest Lecture (TBC) Reflection Models 1 Reflection Models 2
10 (May 18,20,22) P: Rendering (Marc) Monte Carlo Integration 1 Monte Carlo Integration 2
11 (May 25,27,29) P: Rendering (Robert) Path tracing 1 Path tracing 2
12 (June 1,3,5)Queen's Birthday P: Participating Media
(Henry)Wrap up
13 (June 8) Project 3 presentation (CMIC)
Project 3
P: Student presentationT : TutorialG : Guest Lecture
This Friday
3Office hours: Fridays 2-4pm, CO330
CGRA 408 PresentationsRobert:13th of March, Yue et al, "Unbiased, Adaptive Stochastic Sampling for Rendering Inhomogeneous Participating Media",SIGGRAPHAsia (2010)25th of May, Dachsbacher et al, “Scalable Realistic Rendering with Many-Light Methods”, CGF2014
Ruth:27th of March, Wachter et al, “Instant Ray Tracing: The Bounding Interval Hierarchy”3rd of April, Van Horn et al,“Antialiasing Procedural Shaders with Reduction Maps”
Marc:20th of March, Hullin et al, “Physically-Based Real-Time Lens Flare Rendering”, SIGGRAPH 201118th of May, Dobashi et al, “A simple, efficient method for realistic animation of clouds”, SIGGRAPH 2000
Anna:8th of April, Lee et al, “Real-Time Lens Blur Effects and Focus Control”, SIGGRAPH 20109th of May, Matusik et al, “Efficient isotropic BRDF measurement”, Eurographics , Workshop on Rendering 2000
Henry:6th of May, Karsch et al., "Automatic Scene Inference for 3D Object Compositing”, SIGGRAPH 20143rd of June, Dobashi et al., "An inverse problem approach for automatically adjusting the parameters for renderingclouds using photographs”, SIGGRAPHAsia 2012
Recap: PBRT System Overview● Two phases of execution
● Phase 1 § Parse the scene description file§ File format described here:
https://pbrt.org/fileformat-v3.htmlüShape, material, light, camera, etc
● Phase 2§ Execute main rendering loop
5
Attributes● The transformation matrix can be saved
and restored independently usingTransformBegin and TransformEnd
Scale 2 2 2TransformBeginTranslate 1 0 1Shape "sphere"TransformEndShape "cone"
7
# Translate no longer applies here
Transformations
● Why use transformations ?§ Create object in convenient coordinates
ü object, world, camera, screen coordinates§ Reuse basic shape multiple times§ Hierarchical modeling§ Kinematics§ Rigid body animation§ Viewing
… 8
Transformations
9
● A series of directives modify the CTM§ Current Transformation Matrix§ CTM is reset to the identity when WorldBegin is
encountered
Transformations
10
Rotate 45 0 1 0Include “teapot.pbrt"
Translate 2 0 0Rotate 45 0 1 0Include “teapot.pbrt”
Rotate 45 0 1 0Translate 2 0 0Include “teapot.pbrt”
Transformation Composition
● PBRT transformation is right to left§ Transform T = A*B*C§ A(B(C(p))) = T(p)
11
Handedness● Left-handed coordinate system
§ PBRT
● Right-handed coordinate system§ OpenGL
12
X
Y
Z
X
YZ
Revisit:
13
● Basic types (scalar, vector, matrix) and operations
● Dot and cross product● Normals● 3D Homogeneous coordinates● Transformations and their properties
Read chapter 2 of PBRT book:http://www.pbr-book.org/3ed-2018/Geometry_and_Transformations.html
Implicit Geometry● Implicit or parametric description of
geometry such as lines, planes, curves, surfaces§ f(P) = f(x, y, z) = 0§ x = f(u, v)
§ Implicit form of sphere of radius rü x2 + y2 + z2 = r2
§ Parametric form of sphere in spherical coordinatesü x = r sinϕ cosθü y = -r cosϕü z = -r sinϕ cosθ
14
Lines● Lines
§ Given two 3D points P1 and P2, we can define the line that passes through this points as
§ A ray is a line having a single endpoint P0 and extending to infinity in a given direction v
15
P(t) = (1− t)P1 + tP2
P0
P(t)
v
P(t) = P0 + tV
Planes● Planes
§ Given a 3D point P0 and a normal vector N, the plane passing through the point P0 and perpendicular to the direction N can be defined as the set of points P such that
§ The plain equation is commonly written as
where A, B, C are the x, y, z component of the normal vector N and D = -N � P0
16
N•(P−P0 ) = 0
Ax +By+Cz+D = 0
A,B,C[ ]xyz
!
"
###
$
%
&&&− A,B,C[ ]
x0y0z0
!
"
###
$
%
&&&= 0, N•P+D = 0
Implicit Surfaces● Implicit functions implicitly define a set of points that are
on the surface§ f(x,y,z) = 0, f(p) = 0§ Implicit function f is zero if p=(x,y,z) is on the surface
● Ray intersection with an implicit surface (plane)§ For a ray p(t) = o + td and an implicit surface f(p) = 0 § The intersection occur : f(p(t)) = 0 à f(o+td) = 0§ Consider a plane through point a with surface normal n
ü (p-a)�n = 0 ; p is any unknown point satisfies the equation§ Plugging the ray p(t) = o +td into this
ü (o+td-a)�n = 0ü t = (a-o)�n / d�nü If denominator 0 àü If numerator and denominator 0 à
17
ray and plane are parallelray is in the plane
Implicit Surfaces Normal● Surface normal is perpendicular to the surface● Each point of the surface may have a different
normal vector● The surface normal is given by the gradient of
the implicit function
18
n =∇f (p) = ∂f (p)∂x
, ∂f (p)∂y
, ∂f (p)∂z
#
$%
&
'(
Parametric Surface● Another way to specify 3D surface is with 2D
parameters
● For example, a point on the surface of the earth is given by two parameters longitude and latitude§ Polar coordinate system on a unit sphere with center at
the origin
19
x = f (u,v) y = g(u,v) z = h(u,v)
x = cosφ sinθy = sinφ sinθz = cosθ
Parametric Surface● Intersection
§ Intersection is computed using a linear system with three equations and three unknown t, u, v
§ Normal vector of parametric surface is given by
20
ox + tdx = f (u,v) oy + tdy = g(u,v) oz + tdz = h(u,v)
n(u,v) = ∂f∂u, ∂g∂u, ∂h∂u
"
#$
%
&'×
∂f∂v, ∂g∂v, ∂h∂v
"
#$
%
&'
PBRT Shape Class● Shape class support
§ Geometry properties§ Bounding box, ray intersection, etc§ Core/shape§ If reference counter is zero the shape will be
deleted§ All shapes are in their object coordinates
üE.g center of sphere is in originüShape class store its transformation and inverse of it
21
Sphere● Special case of Quadrics
§ Quadrics are surfaces defined by quadric polynomials§ PBRT support 6 quadrics
ü sphere, cylinder, disk, cone, hyperboloids, paraboloids
● Implicit form of unit sphere§ x2 + y2 + z2 - 1 = 0
● Parametric form of sphere of radius r§ θ : 0 ~ π, ϕ : 0 ~ 2π
22
x = rcosφ sinθ
y = rsinφ sinθ
z = rcosθ
Sphere● Intersection in PBRT
§ Transform the ray into object space since sphere is centered at its object coordinates
§ If a sphere is centered at the origin and radius rü Implicit representation : x2 + y2 + z2 – r2 = 0
§ Substituting parametric representation of the ray
§ Expand the equation for general quadratic equation
23
(ox + tdx )2 + (oy + tdy )
2 + (oz + tdz )2 = r2
Cylinder
● Parametric form of cylinder
24
Cylinder● Compute ray vs cylinder intersection
§ The implicit equation for an infinitely long cylinder centered on the z axis with radius r is x2 + y2 – r2 = 0
§ Substituting the ray equation
§ Expand this to find coeff. of quadric At2 + Bt + C
● Surface area is just a rolled-up rectangle§ Height : zmax – zmin, width : rΦmax
25
(ox + tdx )2 + (oy + tdy )
2 = r2
Disk● Circular disk of
§ radius r, height h (z-axis), angle ϕ§ Generalize to annulus using ri
26
Disk● Intersection with ray
§ Intersection of the ray with z = h planeü h = oz + tdz à t =(h – oz)/dz
ü if the ray is parallel to the disk , no intersection§ Check if it lies inside the disk
üCompute the distance from hit point to centerüIf dist < ri or dist > r, no intersection
§ Check ϕ value of hit pointüIf ϕ > ϕmax, no intersection
27
Others
● Paraboloid, Hyperboloid, Cone
§ Read the PBR book28
Triangle Mesh● Why triangle ?
§ The minimum number of points to create a surfaceüEvery object can be split into triangles üThree points always define a unique plane, but four
points cannot
§ Efficient for rasterization§ Well-defined method (barycentric interpolation) for
interpolating values in the interior
29
Triangle Mesh● PBRT support triangle mesh
§ Argument to the TriangleMesh constructorünt : number of trianglesünv : number of verticesüvi : pointers to an array of vertex indices
– For ith triangle, P[vi[3*i]], P[vi[3*i+1]], P[vi[3*i+2]]
üP : array of nv vertex positionsüN : an optional array of normal vectors (for shading)üS : an optional array of tangent vectors (for shading)üuv : an optional array of parametric (u,v) valuesüatex: an optional alpha mask texture to cut off a part
of triangle surface (if masked, intersection is ignored)– Helpful for leaves
30
Triangle Mesh● The base element of shading
§ Need to parameterize the triangles for intersection and shadingüe.g. (u,v) can be interpolated for texture coordinates
§ Unlike other shapes, ray vs triangle intersection is done in world coordinates in PBRTüTriangle meshes transformed into world space once at
start upüWorld space bound
– computed in the world coordinates
üObject space bound – Computed in object coordinates after transforming objects
from world to object coordinates (expensive)
31
Barycentric coordinates● Barycentric coordinate system
§ is a coordinate in which the location is specified as the center of mass or barycenter of vertices of a simplex such as triangle, tetrahedron, etc
§ p = b0p0 + b1p1 + b2p2
§ b0, b1, b2 are the barycentriccoordinates ü It is also known as area coordinates
since the coordinates of p isproportional to the area of each trianglessuch that pp1p2, pp2p0 , pp0p1
§ Constraint b0+ b1+ b2 = 1ü b0 = 1 – b1 – b2
32
3D Bounding Box● To speed up the complex intersection tests, 3D
bounding boxes are used for ray tracing§ If a ray does not pass through a bounding box,
avoid all the processing of primitives inside of it§ Tightness to fit to the bounding box is important
ü A very loose BB is not helpful ü A very close fit BB may increase cost of processing
§ AABB (Axis Aligned Bounding Boxes)ü One point and three length spanning along x, y, z coorindatesü Alternatively two point:
pMin (front, bottom, left) pMax (back, top, right) in PBRT
§ Oriented Bounding Boxes (OBB)ü AABB arbitrary rotated
33
Reading● Reading
§ Shevtsov et al 2007 a paper ü “Ray-Triangle Intersection Algorithm for Modern CPU Architectures
” - Highly optimized ray-tri intersection. Good survey as well
§ Kensler and Shirley 2006 paperü “Optimizing Ray-Triangle Intersection via Automated Search”
- Efficient ray-tri intersection routine (one of the best)
34
http://www.pbr-book.org/3ed-2018/Shapes.html
Read chapter 3 of PBRT book:
top related