Top Banner
CS361 Week 7 - Wednesday
28

CS361

Feb 24, 2016

Download

Documents

Wes

Week 7 - Wednesday. CS361. Last time. What did we talk about last time? Transparency Gamma correction Texturing. Questions?. Project 2. Student Lecture: Mipmapping and Anisotropic filtering of Textures. Image Texturing. Image texturing. Usually, texturing is image texturing: - PowerPoint PPT Presentation
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: CS361

CS361Week 7 - Wednesday

Page 2: CS361

Last time

What did we talk about last time? Transparency Gamma correction Started texturing

Page 3: CS361

Questions?

Page 4: CS361

Project 2

Page 5: CS361

Texturing

Page 6: CS361

Texturing We've got polygons, but they are all one

color At most, we could have different colors at each

vertex We want to "paint" a picture on the polygon

Because the surface is supposed to be colorful To appear as if there is greater complexity than

there is (a texture of bricks rather than a complex geometry of bricks)

To apply other effects to the surface such as changes in material or normal

Page 7: CS361

Texture pipeline We never get tired of

pipelines Go from object space to

parameter space Go from parameter space

to texture space Get the texture value Transform the texture value

Projector function

Object

spaceCorresponder function

Parameter

spaceObtain value

Texture

space

Value transform function

Texture

valueTransform

ed value

Page 8: CS361

Projector function The projector function goes from the model space (a 3D

location on a surface) to a 2D (u,v) coordinate on a texture Usually, this is based on a map from the model to the

texture, made by an artist Tools exist to help artists "unwrap" the model Different kinds of mapping make this easier

In other scenarios, a mapping could be determined at run time

Page 9: CS361

Corresponder function

From (u,v) coordinates we have to find a corresponding texture pixel (or texel)

Often this just maps directly from u,v [0,1] to a pixel in the full width, height range

But matrix transformations can be applied

Also, values outside of [0,1] can be given, with different choices of interpretation

Page 10: CS361

Texture values

Usually the texture value is just an RGB triple (or an RGBα value)

But, it could be procedurally generated

It could be a bump mapping or other surface data

It might need some transformation after retrieval

Page 11: CS361

Student Lecture: Mipmapping and Anisotropic filtering of Textures

Page 12: CS361

Image Texturing

Page 13: CS361

Image texturing

Usually, texturing is image texturing: Gluing a 2D image onto a polygon

Recall that textures have certain limitations Usually 2m x 2n texels Some old cards require square textures Most new cards don't have to do powers

of 2 Maximum sizes vary:▪ 2048 x 2048 might be all your laptop can do▪ 8192 x 8192 is required by DirectX 10

Page 14: CS361

Resizing

Sometimes a small texture will cover a much larger area on screen This effect is called magnification

Sometimes a large texture will cover very little area on the screen This effect is called minification

Different techniques exist to overcome these problems

Page 15: CS361

Magnification Magnification is often done by filtering the source

texture in one of several ways: Nearest neighbor (the worst) takes the closest texel to the

one needed Bilinear interpolation linearly interpolates between the four

neighbors Bicubic interpolation probably gives the best visual quality

at greater computational expense (and is generally not directly supported)

Page 16: CS361

Bilinear interpolation (with apologies) Perhaps unsurprisingly, the book

gives a pretty good explanation of bilinear interpolation on p. 159

I guess I should direct people there in the future

Page 17: CS361

Blurring issues Bilinear interpolation tends to blur sharp edges,

but you can interpolate non-linearly, remapping bright colors to a bright value and dark to a dark value

Another alternative is detail textures Overlay higher resolution textures (representing

details like scratches) onto a magnified texture

Page 18: CS361

Minification Minification is just as big of a problem (if not

bigger) Bilinear interpolation can work

But an onscreen pixel might be influenced by many more than just its four neighbors

We want to, if possible, have only a single texel per pixel

Main techniques: Mipmapping Summed-area tables Anisotropic filtering

Page 19: CS361

MipmappingMipmapping is the most popular texture

antialiasing solution Mip = "multum in parvo," meaning "many

things in a small place" The trouble with minification is that a single

pixel needs to be colored by lots of texels The solution: when loading the texture,

create many smaller filtered versions of the texture, then use the appropriate one for rendering

Page 20: CS361

Mipmapping in action Typically a chain of mipmaps is created, each half

the size of the previous That's why cards like square power of 2 textures Often the filtered version is made with a box filter,

but better filters exist The trick is figuring out which mipmap level to use The level d can be computed based on the change

in u relative to a change in x

Page 21: CS361

Trilinear filtering One way to improve quality

is to interpolate between u and v texels from the nearest two d levels

Picking d can be affected by a level of detail bias term which may vary for the kind of texture being used

Page 22: CS361

Summed-area table Sometimes we are magnifying in one axis of the

texture and minifying in the other Summed area tables are another method to reduce

the resulting overblurring It sums up the relevant pixels values in the texture It works by precomputing all possible rectangles

Page 23: CS361

Anisotropic filtering Summed area tables work poorly for non-rectangular

projections into texture space Modern hardware uses unconstrained anisotropic

filtering The shorter side of the projected area determines d, the

mipmap index The longer side of the projected area is a line of anisotropy Multiple samples are taken along this line Memory requirements are no greater than regular

mipmapping

Page 24: CS361

SharpDX Examples

Page 25: CS361

Quiz

Page 26: CS361

Upcoming

Page 27: CS361

Next time…

SharpDX examples Textures in shader code

Project 2 and Assignment 3 work day?

Page 28: CS361

Reminders

Keep working on Project 2 Finish Assignment 3 Keep reading Chapter 6 Internship opportunity:

Naval Supply Systems Command Student Trainee Position as Information

Technology Specialist For more information: ▪ https://www.usajobs.gov/GetJob/ViewDetails/

395513700