27
CS361 Week 11 - Thursday

Week 11 - Thursday. What did we talk about last time? Image processing Blurring Edge detection Color correction Tone mapping Lens flare

Embed Size (px)

Citation preview

Page 1: Week 11 - Thursday.  What did we talk about last time?  Image processing  Blurring  Edge detection  Color correction  Tone mapping  Lens flare

CS361Week 11 - Thursday

Page 2: Week 11 - Thursday.  What did we talk about last time?  Image processing  Blurring  Edge detection  Color correction  Tone mapping  Lens flare

Last time

What did we talk about last time? Image processing

Blurring Edge detection Color correction Tone mapping Lens flare Bloom

Depth of field Motion blur Fog

Page 3: Week 11 - Thursday.  What did we talk about last time?  Image processing  Blurring  Edge detection  Color correction  Tone mapping  Lens flare

Questions?

Page 4: Week 11 - Thursday.  What did we talk about last time?  Image processing  Blurring  Edge detection  Color correction  Tone mapping  Lens flare

Project 3

Page 5: Week 11 - Thursday.  What did we talk about last time?  Image processing  Blurring  Edge detection  Color correction  Tone mapping  Lens flare

Polygonal Techniques

Page 6: Week 11 - Thursday.  What did we talk about last time?  Image processing  Blurring  Edge detection  Color correction  Tone mapping  Lens flare

Sources of 3D data

As you know, just getting 3D data into a program is tricky

There are a few standard ways Type in the data (cube examples) Generate the data procedurally Visualization of scientific (or

other) data as spheres, cubes, or other primitives

Modeling programs Sampling or scanning the real

world Reconstruction from photographs Combinations!

Page 7: Week 11 - Thursday.  What did we talk about last time?  Image processing  Blurring  Edge detection  Color correction  Tone mapping  Lens flare

Video of Scanning Michelangelo's DavidAnd ScanView tool to view the data

Page 8: Week 11 - Thursday.  What did we talk about last time?  Image processing  Blurring  Edge detection  Color correction  Tone mapping  Lens flare

Motion capture is huge now Models created by artists Moving based on motion capture

http://science.discovery.com/video-topics/sci-fi-supernatural/james-cameron.htm

Page 9: Week 11 - Thursday.  What did we talk about last time?  Image processing  Blurring  Edge detection  Color correction  Tone mapping  Lens flare

Tessellation

Surfaces often need to be tessellated, broken down into polygons

The surfaces can be Convex polygons More complicated polygons 3D surfaces made out of complicated

polygons

Page 10: Week 11 - Thursday.  What did we talk about last time?  Image processing  Blurring  Edge detection  Color correction  Tone mapping  Lens flare

Triangulation

For most graphics hardware, polygons must be triangulated into component triangles

"Bowties" have to be converted into triangles, perhaps making a guess about what the modeler meant

The literature contains many triangulation algorithms including the O(n2) ear clipping algorithm

Page 11: Week 11 - Thursday.  What did we talk about last time?  Image processing  Blurring  Edge detection  Color correction  Tone mapping  Lens flare

Shading problems

Data often arrives as quadrilateral meshes How we break those into triangles can make a big

visual difference, depending on vertex colors and texture mapping

Sometimes no triangulation works for texture mapping It may be necessary to distort the texture to make it work

Page 12: Week 11 - Thursday.  What did we talk about last time?  Image processing  Blurring  Edge detection  Color correction  Tone mapping  Lens flare

Splines

A spline is a curve in space that is defined as a piecewise function

Each piece of the curve is often a cubic function

Usually the first and second derivatives of the functions are the same at points where they meet to keep them smooth

Splines are a common tool for defining shapes in 2D and 3D

Artists add control points with handles to change the slope of the curves

Page 13: Week 11 - Thursday.  What did we talk about last time?  Image processing  Blurring  Edge detection  Color correction  Tone mapping  Lens flare

NURBS

Non-uniform rational basis splines (NURBS) are a very general form of splines

Many 3D modeling program represent surfaces as patches between these splines

Rendering NURBS usually means turning these mathematically precise surfaces into triangles

Page 14: Week 11 - Thursday.  What did we talk about last time?  Image processing  Blurring  Edge detection  Color correction  Tone mapping  Lens flare

Edge cracking and T-vertices Turning the splines into

polygons can cause two surfaces to have cracks between them, called edge cracking

Edge stitching makes sure all vertices on a shared edge between surfaces are shared as well

Shading is also an issue for T-vertices Triangles that share edges

should share all the same vertices too

Page 15: Week 11 - Thursday.  What did we talk about last time?  Image processing  Blurring  Edge detection  Color correction  Tone mapping  Lens flare

Consolidation

After generating a polygon mesh, we may want to consolidate it in a few ways

Merging finds shared vertices among faces Orientation makes sure that all polygons face

the same direction This way, neighboring polygons would not be facing

opposite ways from the perspective of culling operations

It may be necessary to generate normals for each vertex based on the surface normals All the same as the surface for flat surfaces Interpolated normals on vertices for curving surfaces

Page 16: Week 11 - Thursday.  What did we talk about last time?  Image processing  Blurring  Edge detection  Color correction  Tone mapping  Lens flare

Triangle fans

In order to reuse data, we can break groups of triangles into fans, strips, and meshes

A triangle fan has a center vertex shared by all triangles

The data sent to the GPU is the center vertex, the second vertex of the first triangle, the third vertex of the first triangle, and then just one additional vertex per triangle

Page 17: Week 11 - Thursday.  What did we talk about last time?  Image processing  Blurring  Edge detection  Color correction  Tone mapping  Lens flare

Triangle strips

A triangle strip is similar to a triangle fan except that the triangles do not all share a common vertex

As before, only a single new vertex is needed for each triangle after the first one

Note that the clockwiseness of vertex order reverses for each triangle

DirectX (and SharpDX) and OpenGL automatically render the vertices of every other triangle in opposite order to perform backface culling properly

Page 18: Week 11 - Thursday.  What did we talk about last time?  Image processing  Blurring  Edge detection  Color correction  Tone mapping  Lens flare

Optimizing triangle strips The previous example showed a sequential triangle strip Generalized triangle strips are more flexible, but we may need to send a

vertex more than once or use some other special command, as in the following example

There are algorithms designed to generate the smallest number of strips possible (though reaching the true optimal is NP-hard)

Page 19: Week 11 - Thursday.  What did we talk about last time?  Image processing  Blurring  Edge detection  Color correction  Tone mapping  Lens flare

Triangle meshes

For a closed surface, a mesh can be more efficient than either fans or strips

For large closed meshes, on average, each vertex is connected to six triangles

Consequently, we may only need to store as little as 0.5 vertices per triangle

More importantly, we only have to do lighting calculations once for each vertex

To get these advantages, our system has to have a good caching algorithm (and cache size) so that a lit, transformed vertex is still in cache the next time we need it

Page 20: Week 11 - Thursday.  What did we talk about last time?  Image processing  Blurring  Edge detection  Color correction  Tone mapping  Lens flare

Vertex buffers

By now, you're used to vertex buffers They are a generic way to store model data in a

contiguous chunk of memory The memory could be:

A list of points A list of line segments A polyline A triangle list A triangle fan A triangle strip

The size of a vertex is called the stride If you do not want to repeat information in the vertex

buffer, you can use an index buffer to specify which vertices from the vertex buffer to use

Page 21: Week 11 - Thursday.  What did we talk about last time?  Image processing  Blurring  Edge detection  Color correction  Tone mapping  Lens flare

Simplification

Mesh simplification is a way of reducing polygon count while preserving appearance

Three common kinds: Static – make several models of different complexity

and choose the right one Dynamic – generate models on the fly, allowing for a

continuous spectrum of level of detail (LOD) View-dependent – change based on the particular

view

Page 22: Week 11 - Thursday.  What did we talk about last time?  Image processing  Blurring  Edge detection  Color correction  Tone mapping  Lens flare

Dynamic simplification

Use edge collapses Merge two vertices into one

There are different strategies for determining which edge to collapse, but we usually look for a "low cost" edge There are different strategies for determining cost…

Some edges should not be collapsed If it causes a surface's normal to flip If it causes edges to cross

Page 23: Week 11 - Thursday.  What did we talk about last time?  Image processing  Blurring  Edge detection  Color correction  Tone mapping  Lens flare

View dependent simplification Terrain is highly view dependent

Close things need a lot of detail Distant mountains may not

Some techniques are just dynamic simplification applied based on distance from the viewer

Others break the terrain into tiles or other divisions Some features of a terrain heightfield require more detail

to look realistic Special edges may be added in after the fact to connect

low detail tiles to high detail tiles

Page 24: Week 11 - Thursday.  What did we talk about last time?  Image processing  Blurring  Edge detection  Color correction  Tone mapping  Lens flare

Subdivision

We're mostly skipping Chapter 13 It's about curves and curved surfaces One of its focuses is subdividing simple meshes into

more complex ones There are many techniques to do so Shapes get smoother and blobbier There are ways to specify that some edges should

remain

Page 25: Week 11 - Thursday.  What did we talk about last time?  Image processing  Blurring  Edge detection  Color correction  Tone mapping  Lens flare

Upcoming

Page 26: Week 11 - Thursday.  What did we talk about last time?  Image processing  Blurring  Edge detection  Color correction  Tone mapping  Lens flare

Next time…

Review for Exam 2

Page 27: Week 11 - Thursday.  What did we talk about last time?  Image processing  Blurring  Edge detection  Color correction  Tone mapping  Lens flare

Reminders

"Normal" office hours canceled today Finish Project 3

Due tonight by midnight! Review Chapters 5-10