Advanced Texture-Mapping Curves and Curved Surfaces. Pre-Lecture Business. Texture Modes. Texture Modes. Review quiz

Similar documents
Splines. Connecting the Dots

2D Spline Curves. CS 4620 Lecture 13

Curves. Computer Graphics CSE 167 Lecture 11

Shape Representation Basic problem We make pictures of things How do we describe those things? Many of those things are shapes Other things include

CSE 167: Introduction to Computer Graphics Lecture 12: Bézier Curves. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2013

CSE 167: Introduction to Computer Graphics Lecture #13: Curves. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2017

Hidden Surface Elimination Raytracing. Pre-lecture business. Outline for today. Review Quiz. Image-Space vs. Object-Space

Computer Graphics CS 543 Lecture 13a Curves, Tesselation/Geometry Shaders & Level of Detail

Lecture IV Bézier Curves

2D Spline Curves. CS 4620 Lecture 18

Central issues in modelling

Spline Morphing. CG software practical course in the IWR. Carl Friedrich Bolz. Carl Friedrich Bolz

Pipeline Operations. CS 4620 Lecture 10

For each question, indicate whether the statement is true or false by circling T or F, respectively.

Parametric curves. Brian Curless CSE 457 Spring 2016

Sung-Eui Yoon ( 윤성의 )

CSE 167: Introduction to Computer Graphics Lecture #11: Bezier Curves. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2016

Bezier Curves, B-Splines, NURBS

Intro to Modeling Modeling in 3D

CS 4620 Program 3: Pipeline

Pipeline Operations. CS 4620 Lecture 14

Intro to Curves Week 4, Lecture 7

Curves & Surfaces. MIT EECS 6.837, Durand and Cutler

Curves and Surfaces. Computer Graphics COMP 770 (236) Spring Instructor: Brandon Lloyd

Drawing in 3D (viewing, projection, and the rest of the pipeline)

CS 354R: Computer Game Technology

Intro to Curves Week 1, Lecture 2

Pipeline Operations. CS 4620 Lecture Steve Marschner. Cornell CS4620 Spring 2018 Lecture 11

Design considerations

Curves and Surfaces 1

Computer Graphics I Lecture 11

Shadows in the graphics pipeline

Objects 2: Curves & Splines Christian Miller CS Fall 2011

CS 536 Computer Graphics Intro to Curves Week 1, Lecture 2

3D Modeling Parametric Curves & Surfaces. Shandong University Spring 2013

Drawing in 3D (viewing, projection, and the rest of the pipeline)

Topics and things to know about them:

Scan Conversion. CMP 477 Computer Graphics S. A. Arekete

Homework #2. Shading, Projections, Texture Mapping, Ray Tracing, and Bezier Curves

CHAPTER 1 Graphics Systems and Models 3

Parametric curves. Reading. Curves before computers. Mathematical curve representation. CSE 457 Winter Required:

Graphics Pipeline 2D Geometric Transformations

Drawing Fast The Graphics Pipeline

Parametric Curves. University of Texas at Austin CS384G - Computer Graphics

Fall CSCI 420: Computer Graphics. 4.2 Splines. Hao Li.

Computergrafik. Matthias Zwicker Universität Bern Herbst 2016

COMP3421. Global Lighting Part 2: Radiosity

Curves and Surfaces Computer Graphics I Lecture 9

3D Modeling Parametric Curves & Surfaces

Curves and Surfaces Computer Graphics I Lecture 10

Computer Graphics Curves and Surfaces. Matthias Teschner

An introduction to interpolation and splines

Drawing in 3D (viewing, projection, and the rest of the pipeline)

Module Contact: Dr Stephen Laycock, CMP Copyright of the University of East Anglia Version 1

Curves D.A. Forsyth, with slides from John Hart

Computergrafik. Matthias Zwicker. Herbst 2010

EF432. Introduction to spagetti and meatballs

Need for Parametric Equations

From curves to surfaces. Parametric surfaces and solid modeling. Extrusions. Surfaces of revolution. So far have discussed spline curves in 2D

Bézier Splines. B-Splines. B-Splines. CS 475 / CS 675 Computer Graphics. Lecture 14 : Modelling Curves 3 B-Splines. n i t i 1 t n i. J n,i.

Computer Graphics 1. Chapter 2 (May 19th, 2011, 2-4pm): 3D Modeling. LMU München Medieninformatik Andreas Butz Computergraphik 1 SS2011

graphics pipeline computer graphics graphics pipeline 2009 fabio pellacini 1

Introduction to Computer Graphics

Splines. Parameterization of a Curve. Curve Representations. Roller coaster. What Do We Need From Curves in Computer Graphics? Modeling Complex Shapes

graphics pipeline computer graphics graphics pipeline 2009 fabio pellacini 1

Computer Graphics Introduction. Taku Komura

GL9: Engineering Communications. GL9: CAD techniques. Curves Surfaces Solids Techniques

CS 381 Computer Graphics, Fall 2008 Midterm Exam Solutions. The Midterm Exam was given in class on Thursday, October 23, 2008.

(Refer Slide Time: 00:02:24 min)

Information Coding / Computer Graphics, ISY, LiTH. Splines

Parametric Curves. University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell

Models and Architectures

Models and Architectures. Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico

CS4620/5620: Lecture 14 Pipeline

Drawing Fast The Graphics Pipeline

CS130 : Computer Graphics Curves (cont.) Tamar Shinar Computer Science & Engineering UC Riverside

Outline. Properties of Piecewise Linear Interpolations. The de Casteljau Algorithm. Recall: Linear Interpolation

CS 475 / CS Computer Graphics. Modelling Curves 3 - B-Splines

CSE528 Computer Graphics: Theory, Algorithms, and Applications

Introduction to Computer Graphics with WebGL

Homework #2. Hidden Surfaces, Projections, Shading and Texture, Ray Tracing, and Parametric Curves

Curves & Surfaces. Last Time? Progressive Meshes. Selective Refinement. Adjacency Data Structures. Mesh Simplification. Mesh Simplification

NURBS: Non-Uniform Rational B-Splines AUI Course Denbigh Starkey

Textures and normals in ray tracing

Properties of Blending Functions

Until now we have worked with flat entities such as lines and flat polygons. Fit well with graphics hardware Mathematically simple

Review of Tuesday. ECS 175 Chapter 3: Object Representation

Chapter 4-3D Modeling

Computer Graphics Fundamentals. Jon Macey

Texture. Texture Mapping. Texture Mapping. CS 475 / CS 675 Computer Graphics. Lecture 11 : Texture

Introduction to Geometry. Computer Graphics CMU /15-662

CS 475 / CS 675 Computer Graphics. Lecture 11 : Texture

Representing Curves Part II. Foley & Van Dam, Chapter 11

TSBK03 Screen-Space Ambient Occlusion

6.837 Introduction to Computer Graphics Quiz 2 Thursday November 20, :40-4pm One hand-written sheet of notes allowed

Direct Rendering of Trimmed NURBS Surfaces

CS 4620 Final Exam. (a) Is a circle C 0 continuous?

LECTURE #6. Geometric Modelling for Engineering Applications. Geometric modeling for engineering applications

CPSC / Texture Mapping

Drawing Fast The Graphics Pipeline

Transcription:

Advanced Texture-Mapping Curves and Curved Surfaces Pre-ecture Business loadtexture example midterm handed bac, code posted (still) get going on pp3! more on texturing review quiz CS148: Intro to CG Instructor: Dan Morris TA: Sean Waler July 26, 2005 Texture Modes gltexenvi(g_texture_env, G_TEXTURE_ENV_MODE, mode); Tell G what to do with my textures Useless parameter always G_TEXTURE_ENV Tell G I m changing the texture mode untextured G_DECA G_MODUATE Texture Modes What happened to lego man s face? Holy crap I have no face! What does a texture map for a complex model loo lie? Review quiz What is shading? What is lighting? What is the difference between smooth shading and flat shading? Why do we interpolate texture coordinates in 3D instead of in 2D? 1

Outline for today Advanced texture mapping Texture coordinate generation Curves and curved surfaces The OpenG pipeline revisited Advanced Texture Mapping Billboarding (easiest) Bump Mapping (in between) Environment Mapping (hardest) Some form of any of these would be great extra credit for your pp s Billboarding Sometimes I can really get away with letting entire objects be 2D Objects that are far-away Objects that loo the same from everywhere, lie particles of dust An easy way to render 2D objects that loo nice is to just use a textured quad Billboarding So a good tric is to mae sure billboard objects always face the camera Assume we now the camera is at (cx,cy,cz) and my tree is at (tx,ty,tz) Assume we now how to render a quad facing +z How can I do this in OpenG? When does this approach brea down, even if I m still far away? I.e., when will my tree not loo right? tree camera Billboarding Examples Bump mapping (aa normal mapping) Instead of modulating the color at each pixel, what if we modulated the normal at each pixel? ots more detail without more vertices just texture texture + bump map 2 dumay.info

Bump mapping examples What does a bump map loo lie? Bump mapping in OpenG (overview) Store all the surface normals in one texture Store a vector from each vertex to our light in the other texture Using an OpenG extension, tell OpenG to dot these two textures, i.e. perform the diffuse lighting computation at each pixel gltexenvi(g_texture_env, G_TEXTURE_ENV_MODE, G_COMBINE_ARB); gltexenvi(g_texture_env, G_SOURCE0_RGB_ARB, G_TEXTURE); gltexenvi(g_texture_env, G_COMBINE_RGB_ARB, G_DOT3_RGB_ARB); gltexenvi(g_texture_env, G_SOURCE1_RGB_ARB, G_PREVIOUS_ARB); Why does bump mapping come with a big performance penalty? Environment Mapping Shiny objects should reflect light from the objects around them and act lie mini-mirrors OpenG lighting can t do this In fact OpenG lighting ignores all other objects in the scene when it lights each vertex But we can approximate this with textures Environment Mapping: Building a Texture Imagine putting my OpenG camera at the position of an object and taing a panoramic picture of the world, then storing the result in a texture This really means rendering a few times with the camera pointed in different directions 1D environment map of a 2D scene 2D environment map of a 3D scene Environment Mapping: Generating Texture Coordinates Now imagine that I assign texture coordinates to my object by just subtracting the object center from each vertex position I.e., each texture coordinate tells me which way this vertex loos my object my object texture coordinates 3 dumay.info

Environment Mapping: The Result If I get the mapping right, this will let me paste a picture of the environment on my object Environment Mapping: imitations Why is it hard to do this in realtime? In practice, static environment maps are often used and loo pretty good Environment Mapping: Relighting Can also capture real panoramic pictures of the world and use them to re-light virtual objects Often done by photographing a mirrored ball Outline for today Advanced texture mapping Texture coordinate generation Curves and curved surfaces The OpenG pipeline revisited Texture Coordinate Generation Where did all these texture coordinates come from? Generally part of the modeling process: textures are built to line up with the texcoords on one specific object Texture Coordinate Generation In general, mapping a flat surface to a 3-D object is difficult Some objects lie cylinders have a natural mapping, because you can wrap a flat sheet around them I.e. if I gave you a piece of wrapping paper and told you to paste it onto a cylinder it would be pretty straightforward What tools are available to modelers to assign texture coordinates to an object? 4 dumay.info

Texture Coordinate Generation Some objects lie spheres will always cause distortion when wrapped with a texture I.e. if I gave you a piece of wrapping paper and told you to paste it onto a bowling ball, you would run into problems Texture Coordinate Generation In general, modeling programs now how to generate textures in small patches that fit well Texture Coordinate Generation Modeling programs usually offer various tools for generating texture coordinates: planar cylindrical spherical shrin-wrap box face TexGen in OpenG Usually your texture coordinates come from a model file or are generated explicitly But OpenG can also generate texture coordinates on-the-fly glenable(g_texture_gen_t); gltexgenf(g_t, G_TEXTURE_GEN_MODE, G_SPHERE_MAP); glenable(g_texture_gen_s); gltexgenf(g_s, G_TEXTURE_GEN_MODE, G_SPHERE_MAP); now whenever I send vertices to OpenG, it will generate sphere map coordinates for me. When might I want to do this (something we taled about earlier today)? Projective Textures A real strength of using OpenG s texture generation is that it can generate planar texture coordinates on a plane that faces the eye or faces some point This lets us do projective texturing: Outline for today Advanced texture mapping Texture coordinate generation Curves and curved surfaces The OpenG pipeline revisited 5 dumay.info

Curves and Curved Surfaces Bezier Curves B-Splines Bezier Surfaces Why do we need more curves? We taled about ruled surfaces, surfaces of revolution, quadrics, etc. Most real curved objects can t be built from these simple primitives Control Points The most common approach to defining curves is to specify a set of control points: my curve should go somewhere near these points A mathematical function or algorithm can automatically generate the curve based on the control points Tae One: inear Interpolation et s generate a line segment between p0 and p1, parameterized by t on the interval [0,1] p(t) = (1-t)p 0 + (t)p 1 p0 p(0.5) We could use this to interpolate lots of points if we wanted to p1 Why do we need fancier methods? de Casteljau s Algorithm I want to generate a curve controlled by three points. We ll parameterize on t = [0,1] To find p(t), interpolate between p0 and p1, and interpolate between p1 and p2 Then interpolate between those two points to find p(t) Bezier Curves If we do this for lots of t values, we get a smooth curve: p 0 (0.3) p0 p(0.0) p1 p(0.3) p 1 (0.3) p2 p(1.0) This is called a Bezier curve, because Monsieur Bezier developed the algebraic form of the same curve that de Casteljau generated 6

Bezier Curves: Closed Form What s the closed-form expression for p(t)? For our curve with only three points: p 0 (t) = (1-t)p 0 + (t)p 1 p 1 (t) = (1-t)p 1 + (t)p 2 p(t) = (1-t)*p 0 (t) + t*p 1 (t) p(t) = (1-t) 2 * p 0 + 2t(1-t) * p 1 + t 2 * p 2 This curve is of degree 2 (a parabola) We could do the same math for any degree (any number of control points) Bezier Curves: Bernstein Form Fortunately someone else already did that math for us For a Bezier curve with control points p 0, p 1, p 2, p, the Bezier curve is: p( t) = = 0 B (t) is a Bernstein polynomial: p B ( t) B ( t) = (1 t) * t B-polynomials are blending functions The closed form expression again: p( t) = = 0 p B The Bezier curve is a blend of the control points Bernstein polynomials control how much weight each control point gets; we call them blending functions There are lots of different blending functions out there how did the Bernstein functions get to be so popular? ( t) Nice properties of Bezier curves Endpoint interpolation: A Bezier curve always passes through the first and last control points Transformation invariance: I can transform the control points and the curve will transform correctly Convex hull preservation: Bezier curves stay within the convex hull of the control points Smoothness at endpoints: The slope of the curve at an endpoint is the same as the slope of the last control segment Cubic Bezier functions are particularly popular Bezier curves in OpenG [bezcurve.cpp] OpenG evaluators tae t values and control points and generate vertices for you: // G, when I tell you to, evaluate a Bezier curve // with order N and these control points glmap1f(g_map1_vertex_3, 0, 1, 3, N, controlpoints); // G, please generate a vertex for the value t, using // the Bezier curve I told you about previously glevalcoord1f(t); // G, please generate 30 points on my curve from // t = 0 to t = 1 and draw them glmapgrid1f(30, 0.0, 1.0); glevalmesh1(g_ine_strip, 0, 30); ess-than-nice properties of Bezier curves Global control: Moving any point has an effect on the entire curve Complexity: Typical curves may have hundreds of control points, and evaluating high-degree Bezier curves is impractical How can we get all the nice properties of Bezier curves with local control and low complexity if I have lots of control points? 7

An aside: curve continuity Cubic B-splines A curve or surface is said to be C n continuous at a point t if its n th derivative at that point is continuous not c 0 continuous Piecewise approximations of cubic polynomial functions with C 0, C 1, and C 2 continuity Translation: stitch together a bunch of cubics without weird artifacts at the joints c 0 continuous not c 1 continuous c 1 continuous hard to tell about higher orders Cubic B-splines: The Big Picture Segments of the curve are influenced by four control points p0 p1 p2 p3 p4 First segment: cubic curve using p0, p1, p2, p3 Next segment: cubic curve using p1, p2, p3, p4 etc p5 p6 Cubic B-splines: The Math [bspline.cpp] Represent each segment as a standard cubic: x(t) = a 3 t 3 + a 2 t 2 + a 1 t + a 0 y(t) = b 3 t 3 + b 2 t 2 + b 1 t + b 0 What are the coefficients? They should represent the control points somehow... After much derivation, we would get a common formula that gives nice cubics: a 3 = (-x i-1 + 3x i -3x i+1 + x i+2 ) / 6 a 2 = (x i-1-2x i + x i+1 ) / 2 a 1 = (-x i-1 + x i+1 ) / 2 a 0 = (x i-1 + 4x i + x i+1 ) / 6 x i-1 x i+2 are the four points that control this segment Cubic B-splines: Nice Properties ocal Control Moving or adding a control point doesn t affect the whole curve ow degree Cubics are easy to compute and are used to describe many complex curves All the nice properties of Bezier curves B-splines: imitations Not guaranteed to pass through any of the control points (even the first and the last) Still can t express all shapes (e.g. circles) We ve only taled about uniform B splines If there are 5 control cubics, each cubic determines 1/5 of the overall curve We ve only taled about non-rational B-splines If we put these in Bernstein form, our blending functions would loo a lot lie the Bezier blending functions We can fix the above problems with non-uniform B-splines: arbitrary influence regions for each point rational B-splines: blending functions are ratios of polynomials The state of the art in OpenG curves is NURBS (an important buzzword): non-uniform rational B-splines See your textboo for more information 8

Review Quiz (candy for correctness and brevity) What is texture mapping? What is billboarding? What is bump mapping? Why not use bump mapping all the time? What is environment mapping? Why not use environment mapping all the time? Why do we usually define curves with control points instead of with lots of vertices? What s a Bezier curve? What s a B-spline? What advantages do B-splines have over Bezier curves? Going from curves to surfaces Everything we ve learned in 1D scales nicely to 2D (from lines to surfaces) A Bezier patch is the 2D cousin of a Bezier curve For a Bezier patch, we specify a grid of control points that we want the surface to loo lie Going from curves to surfaces To find a point p(s,t) on a Bezier patch: Generate the points p(s) for each of the four curves along one axis Use the four resulting points to as a new Bezier curve, and generate the point p(t) along that curve Going from curves to surfaces This was our Bezier curve: p( t) = p B ( t) = 0 Now let the control points themselves be functions of another variable: p( s, t) = = 0 p ( s) B ( t) Specifically, let those functions be Bezier curves: p ( s) = M j= 0 p M j, B j ( s) This gives us the function for a Bezier patch: If I just new how to evaluate p(u,v), how could I render a Bezier patch in OpenG? p( s, t) = M j= 0 = 0 p j, B M j ( s) B ( t) Connecting Bezier patches Bezier and B-spline surfaces: Examples Just as we did with curves, we ll often build complex surfaces by piecing together Bezier patches or B-spline patches Continuity is not guaranteed with Bezier patches it s often up to the designer or the modeling software to mae sure that corresponding points have the same positions and derivatives 9

Bezier surfaces in OpenG [bezmesh.cpp] OpenG evaluators tae u and v values and control points and generate vertices for you: // G, when I tell you to, evaluate a Bezier surface // with order N and these control points glmap2f(g_map2_vertex_3, 0, 1, 3, 4, 0, 1, 12, 4, controlpoints); // G, please generate a vertex for the value t, using // the Bezier curve I told you about previously glevalcoord2f(s,t); Outline for today Advanced texture mapping Texture coordinate generation Curves and curved surfaces The OpenG pipeline revisited // G, please generate 400 points on my surface from // u = 0 to u = 1 and v = 0 to v = 1 and draw them glmapgrid2f(20, 0.0, 1.0, 20, 0.0, 1.0); glevalmesh2(g_fi, 0, 20, 0, 20); Terminology: fragment The OpenG Pipeline Revisited A fragment is an lie a baby pixel that might or might not grow up to be a pixel (appear in the framebuffer) vertex data evaluators per-vertex operations Fragments are the output of the rasterizer display lists vertex buffers clipping primitive type Why might a fragment generated by the rasterizer not appear in the framebuffer? rasterization What data does OpenG store with each fragment? pixel data texture memory per-fragment operations framebuffer Next Time Selection Transparency 10