17 views

Uploaded by Abhinav Tripathi

Attribution Non-Commercial (BY-NC)

- How to Draw Super-Powered Heroes Vol. 1
- Direct3D shaderX vertex and Pixel shader tips and tricks
- ToyShop-Eurographics_AnimationFestival
- Dash Dot Slash TOPSECRET ZbrushTipsAndTricks Wayne Robs On
- Neilsoft - Architectural BIM Services
- Jared Rosen Writing Portfolio
- Dev.Mag - 05
- 20131022-Additive Manufacturing & Allied Technologies, Pune
- 2009-Test07-Chap04-RP-Liquid-SLS-3DP-Appn-and-Issues.pdf
- Metal AM Spring 2016 Vol 2 No 1 Dp
- Pipeline Italiano según fabio pellacini •
- Hair Technique
- Sustainable Production Automation
- Graphene 3D Lab Investor Presentation
- StatisticalGames_ProductBacklog_Analysis
- Multiscale Texture Synthesis
- A New Industrial Revolution
- 2014 03 25 Cryengine Gdc Schultz
- Solid Texture
- Document

You are on page 1of 49

How to do it

How to do it right

Spilling the beans

A couple tricks

Difficulties with

texture mapping

Projective mapping

Shadow mapping

Environment

mapping

Leonard McMillan and Jovan Popovic

Lecture 15 Slide 1 6.837 Fall 2002

Administrative

Office hours

Durand & Teller by appointment

Ngan Thursday 4-7 in W20-575

Yu Friday 2-5 in NE43-256

Deadline for proposal: Friday Nov 1

Meeting with faculty & staff about proposal

Next week

Web page for appointment

The Quest for Visual Realism

see http://www.3drender.com/jbirn/productions.html

Photo-textures

The concept is very simple!

Texture Coordinates

Void EdgeRec::init() {

… //Note: here we use w=1/z

Specify a texture wstart=1./z1; wend=1./z2; dw=wend-wstart; wcurr=wstart;

coordinate at each vertex sstart=s1; send=s2; ds=sstart-send; scurr=sstart;

tstart=t1; tend=t2; dt=tstart-tend; tcurr=tstart;

(s, t) or (u, v) }

Void EdgeRec::update () {

Canonical coordinates ycurr+=1; xcurr+=dx; wcurr+=dw;

scurr+=ds; tcurr+=dt;

where u and v are }

…

Simple modifications to for (e1 = AEL->ToFront(); e1 != NULL; e1 = AEL->Next() ) {

e2=AEL->NextPolyEdge(e1->poly);

triangle rasterizer 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;

(0,1) 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])

}

}

}

(0,0) (1,0) raster->write(y);

}

The Result

What's going on here?

(simple texture)

Notice how the texture seems to bend and warp along the diagonal

triangle edges. Let's take a closer look at what is going on.

Looking at One Edge

First, 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:

Visualizing the Problem

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.

Linear Interpolation in Screen Space

Linear Interpolation in 3-Space

to interpolation in 3-space

How to Make Them Mesh

Still need to scan convert in screen space... so we need a mapping from t

values to s values.

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:

longer have z1 lingering around (Why?). However, we do have w1=

1/z1 and w2 = 1/z2 .

Interpolating Parameters

We can now use this expression for s to interpolate arbitrary parameters, such

as texture indices (u, v), over our 3-space triangle. This is accomplished by

substituting our solution for s given t into the parameter interpolation.

3-space by their corresponding w value and add a new plane equation to

interpolate the w values 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.

Modified 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);

}

Demonstration

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

interpolation

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

triangles

Reminds you something?

When we did Gouraud shading didn't we interpolate

illumination values, that we found at each vertex using screen-

space interpolation?

believe "inherently flawed" were my exact words)?

Gouraud is a big simplification

Gourand 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).

the errors in Gouraud shading

become obvious.

different levels-of-detail

representations

At "T" joints. Applet showing errors in

Gouraud shading

Texture Tiling

Often it is useful to repeat or tile a texture over the surface of a

polygon.

…

if (w<wbuffer[x]) {

wbuffer[x]=w;

raster.setPixel(x, texturemap[tile(correct_s, max), tile(correct_t, max)])

}

…

int tile(int val, int size) {

if (val >= size) {

do { val -= size; } while (val >= size);

} else {

while (val < 0) { val += size; }

}

return val;

} Tiling applet

Texture Transparency

There was also a little code snippet to handle texture transparency.

…

if (w<wbuffer[x]) {

Color4=raster.setPixel(x,

oldColor=raster.getPixel(x);

textureColor= texturemap[tile(correct_s, max), tile(correct_t, max)];

float t= textureColor.transparency()

newColor = t*textureColor+ (1-t)*oldColor;

raster.setPixel(x, newColor)

wbuffer[x]=w; //NOT SO SIMPLE.. BEYOND THE SCOPE OF THIS LECTURE

}

…

Applet showing

texture

transparency

Summary of Label Textures

Increases the apparent complexity of

simple geometry

Must specify texture coordinates for

each vertex

Projective correction (can't linearly

interpolate in screen space)

Specify variations in shading within a

primitive

Two aspects of shading

Illumination

Surface Reflectace

Label textures can handle both kinds

of shading effects but it gets tedious

Acquiring label textures is surprisingly

tough

Difficulties with Label Textures

Tedious to specfiy texture coordinates for

every triangle

Textures are attached to the geometry

Easier to model variations in reflectance than

illumination

Can't use just any image as a label texture

The "texture" can't have projective

distortions

Reminder: linear interploation in image space

is not equivalent to linear interpolation in 3-

space (This is why we need "perspective-

correct" texturing). The converse is also true.

Easier to model variations in reflectance than

illumination

Makes it hard to use pictures as textures

Projective Textures

No need to specify texture coordinates explicitly

A good model for shading variations due to illumination

A fair model for reflectance (can use pictures)

Projective Textures

The Mapping Process

During the Illumination process:

For each vertex of triangle

(in world or lighting space)

origin to point

Compute homogeneous texture coordinate,

[ti, tj, t]

(use projective matrix)

(in projected screen space)

in 3-space

(premultiply by w of vertex)

i=ti/t j=tj/t

Access projected texture

Projective Texture Examples

Modeling from photograph

Using input photos as textures

[Debevec et al. 1996]

Adding Texture Mapping to Illumination

Texture mapping can be used to alter some or all of the constants in the

illumination equation. We can simply use the texture as the final color for the pixel,

or we can just use it as diffuse color, or we can use the texture to alter the normal,

or... the possibilities are endless!

Constant Diffuse Color Diffuse Texture Color Texture used as Label Texture used as Diffuse Color

Texture-Mapping Tricks

Combining Textures

Bump Mapping

Solid Textures

Shadow Maps

Textures can also be used to generate shadows.

Projective Will be discussed in a later lecture

Textures with

Depth

Environment Maps

If, instead of using the ray from the surface point to the projected

texture's center, we used the direction of the reflected ray to index a

texture map. We can simulate reflections. This approach is not completely

accurate. It assumes that all reflected rays begin from the same point.

What's the Best Chart?

Reflection Mapping

Questions?

Image computed using the Dali

ray tracer by Henrik Wann

jensen

Environment map by Paul

Debevec

Lecture 15 Slide 32 6.837 Fall 2002

Texture Mapping Modes

Label textures

Projective textures

Environment maps

Shadow maps

…

The Best of All Worlds

All these texture mapping modes are great!

The problem is, no one of them does everything well.

Suppose we allowed several textures to be applied to each primitive

during rasterization.

Multipass vs. Multitexture

Multipass (the old way) - Render the image in multiple passes, and "add"

the results.

Multitexture - Make multiple texture accesses within the rasterizing loop

and "blend" results.

Blending approaches:

Texture modulation

Alpha Attenuation

Additive textures

Weird modes

Texture Mapping in Quake

Quake uses light maps in addition to texture maps. Texture maps are used

to add detail to surfaces, and light maps are used to store pre-computed

illumination. The two are multiplied together at run-time, and cached for

efficiency.

Maps

Instanced Yes No

by Nick Chirkov

Bump Mapping

Textures can be used to alter the surface normal of an object. This does not change the actual

shape of the surface -- we are only shading it as if it were a different shape! This technique is

called bump mapping. The texture map is treated as a single-valued height function. The

value of the function is not actually used, just its partial derivatives. The partial derivatives tell

how to alter the true surface normal at each point on the surface to make the object appear

as if it were deformed by the height function.

Since the actual shape of the object does not change, the silhouette edge of the object will

not change. Bump Mapping also assumes that the Illumination model is applied at every pixel

(as in Phong Shading or ray tracing).

Sphere w/Diffuse Texture

v

Bump mapping v D

If Pu and Pv are orthogonal and N is normalized:

v N v

P = [ x(u , v), y (u , v), z (u , v)]T Initial point r N′ v

v v v

N = Pu × Pv Normal Pr' v

Pv

v v v

P D

P′ = P + B (u, v ) N Simulated elevated point after bump v

Pu

Variation of normal in u direction

v v v v B ( s − ∆, t ) − B ( s + ∆, t )

Bu =

N ′ ≈ N + Bu Pu + Bv Pv 2∆

142 v

43 B ( s, t − ∆ ) − B ( s, t + ∆ )

D Bv =

2∆

Variation of normal in v direction

by numerical differentiation

Bump mapping v

N

v General case

P = [ x(u , v), y (u , v), z (u , v)]T Initial point

v

N′ v

Pv

v v v

N = Pu × Pv Normal

v v

v − N ×P

u

v

v v B(u , v) N v Pu

P′ = P + v Simulated elevated point after bump D v v

N × Pv

N

v v v v

v Bu (N × Pv ) − Bv (N × Pu )

Variation of normal in u direction

v Bu =

B ( s − ∆, t ) − B ( s + ∆, t )

N′ ≈ N + v 2∆

N B ( s, t − ∆ ) − B ( s, t + ∆ )

1444 42 4444 3 Bv =

v 2∆

D Variation of normal in v direction

by numerical differentiation

Bump mapping derivation ≈0

v v v

v v B(u , v) N v v Bu N BN u

P′ = P + v Pu′ = Pu + v + v

N N N

≈0

v v

Assume B is very small... v v Bv N BN v

v v v Pv

′ = Pv + v + v

N ′ = Pu′ × Pv′ N N

v v v v v v

v v v Bu ( N × Pv ) Bv ( Pu × N ) Bu Bv ( N × N )

N ′ ≈ Pu × Pv + v + v + v 2

N N N

v v v v v v v v v

But Pu × Pv = N , Pu × N = − N × Pu and N × N = 0 so

v v v v

v v Bu ( N × Pv ) Bv ( N × Pu )

N′ ≈ N + v − v

N N

Lecture 15 Slide 40 6.837 Fall 2002

More Bump Map Examples

Bump Map

Cylinder w/Diffuse Texture Map Cylinder w/Texture Map & Bump Map

One More Bump Map Example

Displacement Mapping

We use the texture map to actually move the surface point. This is called

displacement mapping. How is this fundamentally different than bump

mapping?

easily done in the graphics pipeline? In a ray-tracer?

Displacement Mapping Example

It is possible to use displacement maps

when ray tracing.

Image from

Geometry Caching for

Ray-Tracing Displacement Maps

by Matt Pharr and Pat Hanrahan.

Another Displacement Mapping Example

Three Dimensional or Solid Textures

The textures that we have discussed to this

point are two-dimensional functions mapped

onto two-dimensional surfaces. Another

approach is to consider a texture as a

function defined over a three-dimensional

surface. Textures of this type are called solid

textures.

Solid textures are very effective at

representing some types of materials such as

marble and wood. Generally, solid textures

are defined procedural functionsrather than

tabularized or sampled functions as used in

2-D (Any guesses why?)

on An Image Synthesizer, by Ken Perlin,

SIGGRAPH '85.

Noise and Turbulence

When we say we want to create an "interesting" texture, we usually don't

care exactly what it looks like -- we're only concerned with the overall

appearance. We want to add random variations to our texture, but in a

controlled way. Noise and turbulence are very useful tools for doing just

that.

a uniform frequency. To create a simple noise function, consider a 3D

lattice, with a random value assigned to each triple of integer

coordinates:

Turbulence

Noise is a good start, but it looks pretty ugly all by itself. We can use noise

to make a more interesting function called turbulence. A simple turbulence

function can be computed by summing many different frequencies of noise

functions:

Now we're getting somewhere. But even turbulence is rarely used all

by itself. We can use turbulence to build even more fancy 3D

textures...

Marble Example

marble textures, such as the marble vase created by

Ken Perlin. The idea is simple. We fill space with

black and white stripes, using a sine wave function.

Then we use turbulence at each point to distort those

planes.

By varying the frequency of the sin function,

you get a few thick veins, or many thin veins. Varying

the amplitude of the turbulence function controls how

distorted the veins will be.

- How to Draw Super-Powered Heroes Vol. 1Uploaded byLuisFernandoRocaMejia
- Direct3D shaderX vertex and Pixel shader tips and tricksUploaded byDiego Ponciano
- ToyShop-Eurographics_AnimationFestivalUploaded byWagner de Souza
- Dash Dot Slash TOPSECRET ZbrushTipsAndTricks Wayne Robs OnUploaded byapi-3836673
- Neilsoft - Architectural BIM ServicesUploaded byNeilsoft
- Jared Rosen Writing PortfolioUploaded byJared Marc
- Dev.Mag - 05Uploaded bygeorgpiorczynski
- 20131022-Additive Manufacturing & Allied Technologies, PuneUploaded byprakush_prakush
- 2009-Test07-Chap04-RP-Liquid-SLS-3DP-Appn-and-Issues.pdfUploaded byRutuj Shah
- Metal AM Spring 2016 Vol 2 No 1 DpUploaded bysymkimon
- Pipeline Italiano según fabio pellacini •Uploaded byjuanloprada
- Hair TechniqueUploaded byWagner de Souza
- Sustainable Production AutomationUploaded byCharleneKronstedt
- StatisticalGames_ProductBacklog_AnalysisUploaded byLuiz C. Parzianello
- Multiscale Texture SynthesisUploaded byDan Hauer
- 2014 03 25 Cryengine Gdc SchultzUploaded byWagner de Souza
- Graphene 3D Lab Investor PresentationUploaded byfhsjkdfhldsfl
- A New Industrial RevolutionUploaded byrobertohigashi8071
- Solid TextureUploaded byGiorgos
- DocumentUploaded byAnonymous TjcSGVU
- Graficacion Para DummiesUploaded byEmexto
- CG & v LabmanualUploaded bysri kbs
- archmodels_vol_163 copaci.pdfUploaded byDemy
- archmodels_vol_128.pdfUploaded byFabioCasaburiMonteiro
- baselightUploaded bysantu_2121
- The Innovation of 3D MovementUploaded byBrain point
- ggplot2Uploaded byHiromn Nagata
- Drillplan_Map_DATIN AREA.pdfUploaded byDadan
- Vishnu ReportUploaded bysubru10
- 1-50Uploaded byjaumett

- 11_3_YM_Wire_PracUploaded byaby251188
- Noise Reduction Technique using Bilateral Based FilterUploaded byIRJET Journal
- Texture segmentationUploaded byG.m. Raja
- Drying ReviewerUploaded byConrad Monterola
- Mukherjee09Uploaded bySaber Rezgui
- 07286635Uploaded byZahid Yousaf
- DNV-OS-C101Uploaded byDennyza
- 13_Roll Assembly User ManualUploaded bySankaran Swaminathan
- Aimee WorkUploaded byaimeeaun
- Texture control by thermomechanical processing of AA6xxx (word).docxUploaded byAnonymous 7tKrrpSPsU
- C-External Lab Questions 2012Uploaded byVeda Samhitha
- Fs2 Isolation Barrier ValveUploaded byhamed66652
- Maths 3 syllabusUploaded byShashwat Tripathi
- PUAHistChemFormulate by DudleyUploaded bypuja_14
- 1Uploaded byArgie Adduru
- Edexcel A Level Chemistry Unit 6 - January 2015Uploaded byfarahgrace
- Palm-9-rUploaded byBayu Khalifa Muttaqin
- InUploaded bySilokshan Balasingam
- Method Validation on Drug SubstancesUploaded bySrikanth Nagabiru
- Moment Connection - Flush End Plate-19.01.06Uploaded bykalpanaadhi
- Wave Characteristics and Periodic Motion Test w. SolutionsUploaded byNatalie Gukasyan
- Seismic performance of concrete-shear-wall buildings in IndiaUploaded byMohamed
- One-dimensional Consolidation - OpenSeesWikiUploaded bysipil123
- LDM Y LCUploaded byGloria Mejia
- 2006-7 Module 113 - lecture 7Uploaded byapi-19928045
- Thermo RefrigerationUploaded byKailash Nair
- ANSI API RECOMMENDED PRACTICE 2EQUploaded byshimataxo
- Stress Analysis DiskUploaded byGusnaedi Rachmanas
- CH2 Rig Components (Calculation) 6 JuneUploaded byk yong
- 1- Dimension MotionUploaded bySarvesh Kumar Singh