Unformatted text preview:

Wrap the Texture onto the Model Sample model from www cyberware com Framework for Texture Mapping The texture itself is just a 2 D raster image acquired from reality hand painted or procedurally generated Establish a correspondence between surface points texture When shading a particular surface point look up the corresponding pixel in the texture image final color of point will be a function of this pixel 1 Texturing and Rasterization During rasterization we traverse the pixels of a triangle at each pixel we interpolate the correct texture coordinate and we retrieve the corresponding texel texture element What do we do with the contents of the texel color use it to fill in the current pixel reflectance coefficient for illumination equation e g kd transparency an alpha value and many others some of which we ll discuss next time Minification Magnification Minification 1 pixel covers multiple texels Magnification 1 texel covers multiple pixels Texture Screen Surface 2 OpenGL Texture Modes Determines how the contents of the texture are interpreted For RGB images GL MODULATE multiply together with surface color GL BLEND use as a t value to blend surface color and a predetermined color GL DECAL and GL REPLACE use texture color directly Texturing with OpenGL First turn on texturing glEnable GL TEXTURE 2D Next pass the actual texture image to OpenGL glTexImage2D GL TEXTURE 2D level channels width height border format type image for now level 0 and border 0 channels is usually 3 RGB with format GL RGB and type GL UNSIGNED BYTE Have lots of options to control texturing behavior see glTexEnvf and glTexParameterf for details texture coordinates clamped to 0 1 or do they wrap around how is the color of the texture applied to the surface 3 Texturing with OpenGL Here s an example setup glEnable GL TEXTURE 2D glTexEnvf GL TEXTURE ENV GL TEXTURE ENV MODE GL MODULATE glTexParameterf GL TEXTURE 2D GL TEXTURE WRAP S GL REPEAT glTexParameterf GL TEXTURE 2D GL TEXTURE WRAP T GL REPEAT glTexParameterf GL TEXTURE 2D GL TEXTURE MAG FILTER GL LINEAR glTexParameterf GL TEXTURE 2D GL TEXTURE MIN FILTER GL LINEAR glTexImage2D GL TEXTURE 2D 0 3 width height 0 GL RGB GL UNSIGNED BYTE image This configures the texturing system to combine modulate the texture color with the surface color wrap texture coordinates around outside unit square linearly average texels when magnifying and minifying Texturing with OpenGL When drawing just assign texture coordinates to vertices glBegin GL TRIANGLES glNormal3fv n1 glTexCoord2f s1 t1 glVertex3fv v1 glNormal3fv n2 glTexCoord2f s2 t2 glVertex3f v2 glNormal3fv n3 glTexCoord2f s3 t3 glVertex3fv v3 glEnd 4 What Do We Still Need How is it that we see the world Observation Reflection Illumination Absorption 5 Modeling the Flow of Light in the World Light has a dual nature a form of EM radiation waves propagate from light source stream of particles called photons move along straight rays tracing straight rays is computationally more convenient Light is emitted from light sources and interacts with surfaces on impact with an object some is reflected and some is absorbed distribution of reflected light determines finish matte glossy composition of light reflected into eye determines color we see Incident light Some reaches eye Reflected light Some light is absorbed The Simplest Camera Pinhole Camera Mount a piece of film in a lightproof box with a single pinhole in it Pinhole focuses light on the film only select light rays make it through the hole note that image on film is flipped everything will be in perfect focus infinite depth of field You can try this at home film plate pinhole opaque box 6 Camera Model Will typically use pinhole camera model much easier to simulate than lenses simpler geometry of light rays But reverse the sense of image plane real pinholes cameras place pinhole between object and film plate we ll place the image plane in front of the focal point instead generally easier to deal with doesn t flip the image ray geometry is equivalent Physical Pinhole Model d Graphics Pinhole Model d Viewing Transform Mapping 3 D to 2 D The scene we started with was modeled in 3 D the image we want to end up with is 2 D We need to project 3 D space down to 2 D just like actual cameras do For now let s assume a very simple transform orthographic projection x y z x y later on we ll want to consider perspective projections 7 2 D Transformations Transformations are functions applied to points in space p f p Provide a mechanism for manipulating geometric models Transformations are essential pieces of graphics systems OpenGL and PostScript for instance use them extensively Why Do We Need Transformations Makes modeling more convenient for example often easier to generate models around origin gluSphere draws a sphere of radius r about the origin can then move them to final position with transformations Model viewing process via transformations projecting 3 D to 2 D will be done this way Animation transformations as a function of time creates motion 8 Linear Algebra in 30 Seconds We represent points as vectors p x y z vectors add according to parallelogram rule a linear combination of two vectors is p q p p q q set of vectors is linearly independent if none is a linear combination of the others a basis for a space is a linearly independent set of vectors whose linear combinations include all vectors in the space 1 0 standard basis for 2 D plane e1 e 2 0 1 but there are infinitely many possible bases Linear Affine Transformations We ll be specifically interested in linear transformations f p q f p f q transformation of shape determined by effect on vertices a crucial property that allows for efficient implementation And the related class of affine transformations f p q p f p f q p preserves affine combinations e g they map lines to lines another view a linear transformation a translation this is a more general class of functions 9 Translation Offset all points by constant amount x x x y y y Written as more concise vector equation x x x y y y or p p d Scaling Scale all points by constant amount x sx y ty And written as a vector equation x s 0 x y 0 t y or p Sp Squash stretch along x y axes 10 Rotation of Points About Origin x y First write points in polar coordinates x cos y sin x cos y sin x y And solve for the new positions x x cos y sin y x sin y cos Can write this as a vector equation as well x cos sin x y sin cos y or p Rp The Three Fundamental Transformations Translation Scaling


View Full Document

U of I CS 418 - Wrap the Texture onto the Model

Loading Unlocking...
Login

Join to view Wrap the Texture onto the Model 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 Wrap the Texture onto the Model 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?