Download presentation
Presentation is loading. Please wait.
Published byBennett Carson Modified over 6 years ago
1
Digital Image Synthesis Yung-Yu Chuang 10/4/2005
Shapes Digital Image Synthesis Yung-Yu Chuang 10/4/2005 with slides by Pat Hanrahan
2
Shapes Shape: raw geometry properties of the primitive
Primitive=Shape+Material Source code in core/shape.* and shapes/* pbrt provides the following shape plug-ins: quadrics: sphere, cone, cylinder, disk, hyperboloid, paraboloid (surface described by quadratic polynomials in x, y, z) triangle mesh height field NURBS Loop subdivision surface
3
Shape All shapes are defined in object coordinate space
class Shape : public ReferenceCounted { public: <Shape Interface> const Transform ObjectToWorld, WorldToObject; const bool reverseOrientation, transformSwapsHandedness; }
4
Shape interface BBox ObjectBound(;
BBox WorldBound() { (can be overridden) return ObjectToWorld(ObjectBound()); } bool CanIntersect() returns whether this shape can do intersection test; if not, the shape must provide void Refine(vector<Reference<Shape>>&refined) bool Intersect(const Ray &ray, float *tHit, DifferentialGeometry *dg) bool IntersectP(const Ray &ray)
5
Shape interface float Area() void GetShadingGeometry( const Transform &obj2world, const DifferentialGeometry &dg, DifferentialGeometry *dgShading) No back culling for that it doesn’t save much for ray tracing and it is not physically correct for object instancing
6
Surfaces Implicit: F(x,y,z)=0 you can check
Explicit: (x(u,v),y(u,v),z(u,v)) you can enumerate Quadric
7
Sphere A sphere of radius r at the origin Implicit: x2+y2+z2-r2=0
Parametric: f(θ,ψ) x=rsinθcosψ y=rsinθsinψ z=rcosθ mapping f(u,v) over [0,1]2 ψ=uψmax θ=θmax+v(θmax-θmax)
8
Sphere
9
Sphere (construction)
class Sphere: public Shape { …… private: float radius; float phiMax; float zmin, zmax; float thetaMin, thetaMax; } Sphere(const Transform &o2w, bool ro, float rad, float zmin, float zmax, float phiMax); Bounding box for sphere, only z clipping
10
Algebraic solution Perform in object space, WorldToObject(r, &ray)
Assume that ray is normalized for a while Step 1
11
Algebraic solution If (B2-4AC<0) then the ray misses the sphere
Step 2 If (B2-4AC<0) then the ray misses the sphere Step 3 Calculate t0 and test if t0<0 Step 4 Calculate t1 and test if t1<0
12
Geometric solution 1. Origin inside?
13
Geometric solution 2. find the closest point, t=-O‧D
if t<0 and O outside return false t t
14
Geometric solution 3. find the distance to the origin, d2=O2-t2
if s2=r2-d2<0 return false; t s d r r O
15
Geometric solution 4. calculate intersection distance,
if (origin outside) then t-s else t+s t t s O s r d r d O
16
Sphere intersection Use algebraic solution, why?
Consider numeric stability
17
Partial sphere Have to test sphere intersection against clipping parameters Partial derivatives Area
18
Cylinder
19
Cylinder
20
Cylinder (intersection)
21
Disk
22
Disk
23
Disk (intersection) h h-Oz t Dz D
24
Other quadrics
25
Triangle mesh The most commonly used shape. In pbrt, it can be supplied by users or tessellated from other shapes.
26
Triangle mesh class TriangleMesh : public Shape { … int ntris, nverts; int *vertexIndex; Point *p; Normal *n; Vector *s; float *uvs; } vi[3*i] vi[3*i+1] vi[3*i+2] p x,y,z … Note that p is stored in world space to save transformations. n and s are in object space.
27
Triangle mesh ObjectBound and WorldBound
Void TriangleMesh::Refine(vector<Reference<Shape>> &refined) { for (int i = 0; i < ntris; ++i) refined.push_back(new Triangle(ObjectToWorld, reverseOrientation, (TriangleMesh *)this, i)); }
28
Ray triangle intersection
Intersect ray with plane Check if point is inside triangle In order to implement this algorithm we had to address these six issues.
29
Ray plane intersection
Algebraic Method Substituting for P, we get: Solution: In order to implement this algorithm we had to address these six issues.
30
Ray triangle intersection I
Algebraic Method For each side of triangle: In order to implement this algorithm we had to address these six issues. end
31
Ray triangle intersection II
Parametric Method In order to implement this algorithm we had to address these six issues.
32
Ray triangle intersection III
In order to implement this algorithm we had to address these six issues.
33
Fast minimum storage intersection
34
Fast minimum storage intersection
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.