DOC PREVIEW
MIT 6 837 - Texture Mapping

This preview shows page 1-2-3-23-24-25-26-47-48-49 out of 49 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 49 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 49 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 49 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 49 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 49 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 49 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 49 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 49 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 49 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 49 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 49 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Lecture 15 Slide 1 6.837 Fall 2002Texture Mapping Why texture map? How to do it How to do it right Spilling the beans  A couple tricks Difficulties with texture mapping Projective mapping Shadow mapping Environment mappingMost slides courtesy of Leonard McMillan and Jovan PopovicLecture 15 Slide 2 6.837 Fall 2002AdministrativeOffice hoursDurand & Teller by appointmentNgan Thursday 4-7 in W20-575Yu Friday 2-5 in NE43-256Deadline for proposal: Friday Nov 1Meeting with faculty & staff about proposal Next weekWeb page for appointmentLecture 15 Slide 3 6.837 Fall 2002The Quest for Visual Realism For more info on the computer artwork of Jeremy Birnsee http://www.3drender.com/jbirn/productions.htmlLecture 15 Slide 4 6.837 Fall 2002Photo-texturesThe concept is very simple!Lecture 15 Slide 5 6.837 Fall 2002Texture Coordinates Specify a texture coordinate at each vertex (s, t) or (u, v) Canonical coordinates where u and v are between 0 and 1  Simple modifications to triangle rasterizerVoid EdgeRec::init() {…wstart=1./z1; wend=1./z2; dw=wend-wstart; wcurr=wstart;sstart=s1; send=s2; ds=sstart-send; scurr=sstart;tstart=t1; tend=t2; dt=tstart-tend; tcurr=tstart;}Void EdgeRec::update () {ycurr+=1; xcurr+=dx; wcurr+=dw;scurr+=ds; tcurr+=dt;}static void RenderScanLine ( … ) {…for (e1 = AEL->ToFront(); e1 != NULL; e1 = AEL->Next() ) {e2=AEL->NextPolyEdge(e1->poly);x1=[e1->xcurr]; x2=[e2->xcurr]; dx=x2-x1;w1=e1->wcurr; w2=e2->wcurr; dw=(w2-w1)/dx;s1=e1->scurr; s2=e2->scurr; ds=(s2-s1)/dx;t1=e1->tcurr; t2=e2->tcurr; dt=(t2-t1)/dx;for (int x=x1; x<x2; x++) {w+=dw;s+=ds; t+=dt;if (w<wbuffer[x]) {wbuffer[x]=w;raster.setPixel(x, texturemap[s,t])}}}raster->write(y); }(0,0) (1,0)(0,1)//Note: here we use w=1/zLecture 15 Slide 6 6.837 Fall 2002The ResultWait a minute... that doesn't look right.What's going on here?Let's try that out ... Texture mapping applet (image)Notice how the texture seems to bend and warp along the diagonaltriangle edges. Let's take a closer look at what is going on. Let's try again with a simpler texture... Texture mapping applet (simple texture)Lecture 15 Slide 7 6.837 Fall 2002Looking at One EdgeFirst, let's consider one edge from a given triangle. This edge and its projection onto our viewport lie in a single common plane. For the moment, let's look only at that plane, which is illustrated below:Lecture 15 Slide 8 6.837 Fall 2002Visualizing the ProblemNotice that uniform steps on the image plane do not correspond to uniform steps along the edge.Let's assume that the viewport is located 1 unit away from the center of projection.Lecture 15 Slide 9 6.837 Fall 2002Linear Interpolation in Screen SpaceCompare linear interpolation in screen spaceLecture 15 Slide 10 6.837 Fall 2002Linear Interpolation in 3-Space to interpolation in 3-spaceLecture 15 Slide 11 6.837 Fall 2002How to Make Them Mesh Still need to scan convert in screen space... so we need a mapping from tvalues to svalues. We know that the all points on the 3-space edge project onto our screen-space line. Thus we can set up the following equality:and solve for sin terms of tgiving:Unfortunately, at this point in the pipeline (after projection) we no longer have z1 lingering around (Why?). However, we do have w1= 1/z1and w2= 1/z2 .Lecture 15 Slide 12 6.837 Fall 2002Interpolating Parameters We can now use this expression for sto interpolate arbitrary parameters, such as texture indices (u, v), over our 3-space triangle. This is accomplished by substituting our solution for sgiven tinto the parameter interpolation. Therefore, if we premultiply all parameters that we wish to interpolate in 3-space by their corresponding wvalue and add a new plane equation to interpolate the wvalues themselves, we can interpolate the numerators and denominator in screen-space.We then need to perform a divide a each step to get to map the screen-space interpolants to their corresponding 3-space values.Once more, this is a simple modification to our existing triangle rasterizer.Lecture 15 Slide 13 6.837 Fall 2002Modified Rasterizer Void EdgeRec::init() {…wstart=1./z1; wend=1./z2; dw=wend-wstart; wcurr=wstart;swstart=s1*w1; swend=s2*w2; dsw=swstart-swend; swcurr=swstart;twstart=t1*w1; twend=t2*w2; dtw=twstart-twend; twcurr=twstart;}Void EdgeRec::update () {ycurr+=1; xcurr+=dx; wcurr+=dw;swcurr+=dsw; twcurr+=dtw;}static void RenderScanLine ( … ) {…for (e1 = AEL->ToFront(); e1 != NULL; e1 = AEL->Next() ) {e2=AEL->NextPolyEdge(e1->poly);x1=[e1->xcurr]; x2=[e2->xcurr]; dx=x2-x1;w1=e1->wcurr; w2=e2->wcurr; dw=(w2-w1)/dx;sw1=e1->swcurr; sw2=e2->swcurr; dsw=(sw2-sw1)/dx;tw1=e1->twcurr; tw2=e2->twcurr; dtw=(tw2-tw1)/dx;for (int x=x1; x<x2; x++) {w+=dw;float denom = 1.0f / w;sw+=dsw; tw+=dtw;correct_s=sw*denom; correct_t=tw*denom;if (w<wbuffer[x]) {wbuffer[x]=w;raster.setPixel(x, texturemap[correct_s, correct_t])}}}raster->write(y); }Lecture 15 Slide 14 6.837 Fall 2002Demonstration For obvious reasons this method of interpolation is called perspective-correct interpolation. The fact is, the name could be shortened to simply correct interpolation. You should be aware that not all 3-D graphics APIs implement perspective-correct interpolation.Applet with correct interpolationYou can reduce the perceived artifacts of non-perspective correct interpolation by subdividing the texture-mapped triangles into smaller triangles (why does this work?). But, fundamentally the screen-space interpolation of projected parameters is inherently flawed. Applet with subdivided trianglesLecture 15 Slide 15 6.837 Fall 2002Reminds you something?When we did Gouraud shading didn't we interpolate illumination values, that we found at each vertex using screen-space interpolation?Didn't I just say that screen-space interpolation is wrong (I believe "inherently flawed" were my exact words)?Does that mean that Gouraud shading is wrong?Lecture 15 Slide 16 6.837 Fall 2002Gouraud is a big simplificationGourand shading is wrong. However, you usually will not notice because the transition in colors is very smooth (And we don't know what the right color should be anyway, all we care about is a pretty picture).There are some cases where the errors in Gouraud shadingbecome obvious. When switching between different levels-of-detail representations At "T" joints.Applet showing errors in Gouraud shadingLecture 15 Slide 17 6.837 Fall 2002Texture TilingOften it is useful to repeator tilea texture over the surface of a polygon. …if


View Full Document

MIT 6 837 - Texture Mapping

Documents in this Course
Shadows

Shadows

64 pages

Animation

Animation

37 pages

Radiosity

Radiosity

25 pages

Color

Color

86 pages

InterArch

InterArch

14 pages

Color

Color

15 pages

Animation

Animation

61 pages

Luxo Jr

Luxo Jr

14 pages

Animation

Animation

52 pages

Radiosity

Radiosity

37 pages

Load more
Download Texture Mapping
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Texture Mapping and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Texture Mapping 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?