320 likes | 488 Views
Last Time. B-splines Recall a property of B-spline surfaces – the control point grid must be rectangular Clarification: For non-uniform B-splines, there is one control point for every n-d knots, regardless of whether the knot values are equal
E N D
Last Time • B-splines • Recall a property of B-spline surfaces – the control point grid must be rectangular • Clarification: For non-uniform B-splines, there is one control point for every n-d knots, regardless of whether the knot values are equal • 0,0,0,1,2,2,2 requires 7 – 3 = 4 control points for a cubic B-spline (c) University of Wisconsin
Today • Subdivision schemes • Introduction to Global Illumination (c) University of Wisconsin
B-splines as Approximation • B-splines were developed as approximation functions • Given a set of points – the control points – the B-spline approximates them with a smooth curve or surface • Ideally, we would like to be able to provide a polygonal mesh, and then smooth it out with a B-spline surface • The 3D equivalent of smoothing a 2D poly-line with a B-spline • But we can’t do this in general, because B-spline control meshes must be rectangular • Can’t even do simple cases like a sphere: You can’t wrap a sphere is a rectangular sheet without singularities (c) University of Wisconsin
Subdivision Schemes • Basic idea: Start with something coarse, and refine it into smaller pieces, smoothing along the way • We have seen how subdivision may be used to render parametric curves and Bezier surfaces • We will see how it can be used for modeling specific objects, and as a modeling scheme in itself • In this lecture: • Subdivision for tessellating a sphere • Subdivision for fractal surfaces • Subdivision for B-spline patches • General subdivision surfaces (c) University of Wisconsin
Tessellating a Sphere • Spheres are best parameterized in polar coordinates: • Note the singularity at the poles • Tessellation: The process of approximating a surface with a polygon mesh • One option for tessellating a sphere: • Step around and up the sphere in constant steps of and • Problem: Polygons are of wildly different sizes, and some vertices have very high degree (c) University of Wisconsin
Subdivision Method • Begin with a course approximation to the sphere, that uses only triangles • Two good candidates are platonic solids with triangular faces: Octahedron, Isosahedron • They have uniformly sized faces and uniform vertex degree • Repeat the following process: • Insert a new vertex in the middle of each edge • Push the vertices out to the surface of the sphere • Break each triangular face into 4 triangles using the new vertices Octahedron Isosahedron (c) University of Wisconsin
The First Stage Each new vertex is degree 6, original vertices are degree 4 Each face gets split into 4: (c) University of Wisconsin
Sphere Subdivision Advantages • All the triangles at any given level are the same size • Relies on the initial mesh having equal sized faces, and properties of the sphere • The new vertices all have the same degree • Mesh is uniform in newly generated areas • This is a property we will see later in subdivision surfaces • Makes it easier to analyze what happens to the surface • The location and degree of existing vertices does not change • The only extraordinary points lie on the initial mesh • Extraordinary points are those with degree different to the uniform areas (c) University of Wisconsin
Fractal Surfaces • Fractals are objects that show self similarity • The word is overloaded – it can also mean other things • Landscapes and coastlines are considered fractal in nature • Mountains have hills on them that have rocks on them and so on • Continents have gulfs that have harbors that have bays and so on • Subdivision is the natural way of building fractal surfaces • Start with coarse features, Subdivide to finer features • Different types of fractals come from different subdivision schemes and different parameters to those schemes (c) University of Wisconsin
Fractal Terrain (1) • Start with a coarse mesh • Vertices on this mesh won’t move, so they can be used to set mountain peaks and valleys • Also defines the boundary • Mesh must not have dangling edges or vertices • Every edge and every vertex must be part of a face • Also define an “up” direction • Then repeatedly: • Add new vertices at the midpoint of each edge, and randomly push them up or down • Split each face into four, as for the sphere (c) University of Wisconsin
Fractal Terrain Example A mountainside (c) University of Wisconsin
Fractal Terrain Details • There are options for choosing where to move the new vertices • Uniform random offset • Normally distributed offset – small motions more likely • Procedural rule – eg Perlin noise • Scaling the offset of new points according to the subdivision level is essential • For the subdivision to converge to a smooth surface, the offset must be reduced for each level • Colors are frequently chosen based on “altitude” (c) University of Wisconsin
Fractal Terrains http://members.aol.com/maksoy/vistfrac/sunset.htm (c) University of Wisconsin
Terrain, clouds generated using procedural textures and Perlin noise http://www.planetside.co.uk/ -- tool is called Terragen (c) University of Wisconsin
Terrain, clouds generated using procedural textures and Perlin noise http://www.planetside.co.uk/ -- tool is called Terragen (c) University of Wisconsin
Fractal Terrain Algorithm • The hard part is keeping track of all the indices and other data • Same algorithm works for subdividing sphere Split_One_Level(struct Mesh terrain) Copy old vertices for all edges Create and store new vertex Create and store new edges for all faces Create new edges interior to face Create new faces Replace old vertices, edges and faces (c) University of Wisconsin
Subdivision Operations • Split an edge, create a new vertex and two new edges • Each edge must be split exactly once • Need to know endpoints of edge to create new vertex • Split a face, creating new edges and new faces based on the old edges and the old and new vertices • Require knowledge of which new edges to use • Require knowledge of new vertex locations (c) University of Wisconsin
Data Structure Issues • We must represent a polygon mesh so that the subdivision operations are easy to perform • Questions influencing the data structures: • What information about faces, edges and vertices must we have, and how do we get at it? • Should we store edges explicitly? • Should faces know about their edges? (c) University of Wisconsin
General Subdivision Schemes • Subdivision schemes can also be used where there is no “target” surface • They aim to replace a polygonal mesh with a smooth surface that approximates the coarse mesh • There are many schemes: • Butterfly scheme (for triangular meshes) • Catmull-Clark subdivision (for mostly rectangular meshes, converges to B-splines in uniform regions) • Loop’s scheme (for triangular meshes) • Modified butterfly scheme (for triangular meshes) • Many more… (c) University of Wisconsin
Butterfly Scheme • Subdivides the same way we have been discussing • Each edge is split • Each face is split into four • Rules are defined for computing the splitting vertex of each edge • Basic rule for a uniform region • Splitting an edge with endpoints that have degree 6 • As before, all new interior vertices will have degree 6 • Take a weighted sum of the neighboring vertices • Weights define rules • http://www.gamasutra.com/features/20000411/sharp_01.htm (c) University of Wisconsin
Butterfly Scheme (1) c b c a a d d c b c • Multiply each vertex by its weight and sum them up • w is a control parameter – determines how closely the shape conforms to the original mesh (c) University of Wisconsin
Modified Butterfly Scheme • The butterfly scheme must be modified to deal with edges with an endpoint of degree 6 • In that case, compute new vertex based only the neighbors of the extraordinary vertex • If an edge has two extraordinary endpoints, average the results from each endpoint to get the new endpoint • The modified butterfly scheme is provably continuous about extraordinary vertices • Proof formulates subdivision as a matrix operator and does eigen-analysis of subdivision matrix (c) University of Wisconsin
Modified Butterfly Scheme e3 e2 e1 e0 v eN-1 eN-3 eN-2 (c) University of Wisconsin
Modified Butterfly Example • Notes: • The mesh is uniform everywhere except the original vertices • It interpolates the original vertices • It has smoothed out the underlying mesh (c) University of Wisconsin
Shading Revisited • Some applications are intended to produce pictures that look photorealistic, or close to it • The image should look like a photograph • A better metric is perceptual: the image should generate a target set of perceptions • Applications include: Film special effects, Training simulations, Computer games, Architectural visualizations, Psychology experiments, … • To achieve the goal of photorealism, we must think carefully about light and how it interacts with surfaces • What you should take away: The various aspects of light interaction and how algorithms capture or ignore them (c) University of Wisconsin
Light Transport • Light transport problems are concerned with how much light arrives at any surface, and from what direction • The physical quantity of interest is radiance: How much light (power) is traveling along a line in space per unit foreshortened area per unit solid angle • We will not go into the theory - it takes 3 hours just to give the definitions and equations • CS779 will cover this material in detail • Similar problems arise in radiated heat transport (i.e. satellites), where some of the technology was originally developed (c) University of Wisconsin
Light Transport Which surface gets more light? Why? • How much light reaches point “a”? • If the walls are black? • If the walls are mirrors? a a b (c) University of Wisconsin
Reflectance Modeling • Reflectance modeling is concerned with the way in which light reflects off surfaces • Clearly important to deciding what surfaces look like • Also important in solving the light transport problem • Physical quantity is BRDF: Bidirectional Reflectance Distribution Function • A function of a point on the surface, an incoming light direction, and an outgoing light direction • Tells you how much of the light that comes in from one direction goes out in another direction • General BRDFs are difficult to work with, so simplifications are made (c) University of Wisconsin
Simple BRDFs • Diffuse surfaces: • Uniformly reflect all the light they receive • Sum up all the light that is arriving: Irradiance • Send it back out in all directions • A reasonable approximation for matte paints, soot, carpet • Perfectly specular surfaces: • Reflect incoming light only in the mirror direction • Rough specular surfaces: • Reflect incoming light around the mirror direction • Diffuse + Specular: • A diffuse component and a specular component (c) University of Wisconsin
Light Sources • Sources emit light: exitance • Different light sources are defined by how they emit light: • How much they emit in each direction from each point on their surface • For some algorithms, “point” lights cannot exist • For other algorithms, only “point” light can exist (c) University of Wisconsin
Global Illumination Equation • The total light leaving a point is given by the sum of two major terms: • Exitance from the point • Incoming light from other sources reflected at the point Exitance Sum BRDF Incoming light Light leaving Incoming light reflected at the point (c) University of Wisconsin
Photorealistic Lighting • Photorealistic lighting requires solving the equation! • Not possible in the general case with today’s technology • Light transport is concerned with the “incoming light” part of the equation • Notice the chicken and egg problem • To know how much light leaves a point, you need to know how much light reaches it • To know how much light reaches a point, you need to know light leaves every other point • Reflectance modeling is concerned with the BRDF • Hard because BRDFs are high dimensional functions that tend to change as surfaces change over time (c) University of Wisconsin