DOC PREVIEW
UNC-Chapel Hill COMP 770 - Advanced texture mapping

This preview shows page 1-2-3-21-22-23-42-43-44 out of 44 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 44 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 44 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 44 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 44 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 44 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 44 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 44 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 44 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 44 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 44 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Advanced texture mappingFrom last time…Today’s topicsUses of texture mapsSpecifying texture coordinatesPlanar mappingCylindrical mappingSpherical mappingCube mapping“Unwrapping” the modelModelling surface propertiesModelling lightingLight maps in QuakeProjective texturesOpenGL TexGenOpenGL TexGenOpenGL TexGenTexture spaceOpenGL exampleWhat about that r coordinate?Shadow mapsShadow mapsEnvironment mapsSphere mapping basicsSphere mappingOpenGL exampleWhat’s the best map?Problems with environment mapsModelling geometryBump mappingMore bump map examplesOne more bump map exampleNormal mappingNormal mappingDisplacement mappingOpacity mapsBillboards3D or solid texturesNoise and turbulenceInterpolating noiseEvaluating noiseTurbulenceMarble exampleNext time2/21/071Advanced texture mappingComputer GraphicsCOMP 770 (236)Spring 2007Instructor: Brandon Lloyd2/21/072From last time…■ Physically based illumination models■ Cook-Torrance illumination model° Microfacets° Geometry term° Fresnel reflection■ Radiance and irradiance■ BRDFs2/21/073Today’s topics■ Texture coordinates■ Uses of texture maps° reflectance and other surface parameters° lighting° geometry■ Solid textures2/21/074Uses of texture maps■ Texture maps are used to add complexity to a scene■ Easier to paint or capture an image than geometry■ model reflectance° attach a texture map to a parameter■ model light° environment maps° light maps■ model geometry° bump maps° normal maps° displacement maps° opacity maps and billboards2/21/075Specifying texture coordinates■ Texture coordinates needed at every vertex■ Hard to specify by hand■ Difficult to wrap a 2D texture around a 3D objectfrom Physically-based Rendering2/21/076Planar mapping■ Compute texture coordinates at each vertex by projecting the map coordinates onto the model2/21/077Cylindrical mapping2/21/078Spherical mapping2/21/079Cube mapping2/21/0710“Unwrapping” the modelimages from www.eurecom.fr/~image/Clonage/geometric2.html2/21/0711Modelling surface properties■ Can use a texture to supply any parameter of the illumination model° ambient, diffuse, and specular color° specular exponent° roughnessfrom www.ronfrazier.net2/21/0712Modelling lighting■ Light maps° supply the lighting directly° good for static environments■ Projective textures° can be used to simulate a spot light° shadow maps■ Environment maps° A representation of the scene around an object° Good for reflection and refraction2/21/0713Light maps in Quake■ Light maps are used to store pre-computed illumination■ Texture maps add detail to surfacesTextures Only Textures & Light MapsTexture MapsLight MapsData RGB IntensityInstanced Yes NoResolution High LowLight map image by Nick Chirkov2/21/0714Projective textures■ Treat the texture as a slide in a projector ■ No need to specify texture coordinates explicitly ■ A good model for shading variations due to illumination (cool spotlights) ■ Projectors work like cameras in reverse° camera: color of point in scene → color of corresponding pixel° projector: color of pixel → color of corresponding point in the scene2/21/0715OpenGL TexGen■ OpenGL can generate texture coordinates directly from the vertices■ Each component of a texture coordinate is generated by taking the dot product of the corresponding vertex with a specified plane■ In EYE-LINEAR mode, the planes are multiplied by the inverse of the current modelview matrix when they are specified1ssxttyrrzqqw−⎛⎞⎡⎤⎡⎤⎡⎤⎜⎟⎢⎥⎢⎥⎢⎥⎜⎟⎢⎥⎢⎥⎢⎥=⎜⎟⎢⎥⎢⎥⎢⎥⎜⎟⎢⎥⎢⎥⎢⎥⎣⎦⎣⎦⎣⎦⎝⎠MV2/21/0716OpenGL TexGen■ Setting the texgen planes to the identity matrix while the view matrix sits on the top of the stack results in texture coordinates that correspond to world coordinatesglTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR)glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR)glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR)glTexGeni(GL_Q, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR)# Assumes that view matrix is on the stackeyePlaneS = [ 1.0, 0.0, 0.0, 0.0 ]eyePlaneT = [ 0.0, 1.0, 0.0, 0.0 ]eyePlaneR = [ 0.0, 0.0, 1.0, 0.0 ]eyePlaneQ = [ 0.0, 0.0, 0.0, 1.0 ]glTexGenfv(GL_S, GL_EYE_PLANE, eyePlaneS)glTexGenfv(GL_T, GL_EYE_PLANE, eyePlaneT)glTexGenfv(GL_R, GL_EYE_PLANE, eyePlaneR)glTexGenfv(GL_Q, GL_EYE_PLANE, eyePlaneQ)2/21/0717OpenGL TexGen■ TexGen must be enabled/disabledif (projTexture): glEnable(GL_TEXTURE_GEN_S)glEnable(GL_TEXTURE_GEN_T)glEnable(GL_TEXTURE_GEN_R)glEnable(GL_TEXTURE_GEN_Q)...# draw sceneif (projTexture):glDisable(GL_TEXTURE_GEN_S)glDisable(GL_TEXTURE_GEN_T)glDisable(GL_TEXTURE_GEN_R)glDisable(GL_TEXTURE_GEN_Q)...2/21/0718Texture space■ Texture coordinates can be modified by the GL_TEXTURE matrix■ The transform we want to apply to world coordinates is:■ We multiply by the projection and view matrices of the projector just as we do with a camera■ Then we multiply by a matrix that goes from NDC to the [0,1) range used by texture coordinates11221122pr pr11220000T00000 1⎡⎤⎢⎥⎢⎥=⎢⎥⎢⎥⎣⎦PV2/21/0719OpenGL example■ The following piece of code sets up the desired texture matrixglMatrixMode(GL_TEXTURE);glLoadIdentity();glTranslated(0.5, 0.5, 0.5); // Scale and bias the [-1,1] NDC valuesglScaled(0.5, 0.5, 0.5); // to the [0,1] range of the texture mapgluPerspective(15, 1, 5, 7); // projector’s "projection" and view matricesgluLookAt(lightPosition[0],lightPosition[1],lightPosition[2], 0,0,0, 0,1,0);glMatrixMode(GL_MODELVIEW);2/21/0720What about that r coordinate?■ Texture coordinates are homogeneous 4-tuples■ The q coordinate is the homogeneous coordinate° the texture coordinate is divided by q before the texture lookup■ The r coordinate as we are using it represents depth■ Can be used to compute shadows2/21/0721Shadow mapsEye LightPoint in shadow visible to the eye by not visible to the lightUse the depth map in the light view to determine if sample point is visible2/21/0722Shadow maps■ Algorithm:° Render scene from the light’s view° Save depth buffer in a texture° Set up texgen for projective texturing° glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_R_TO_TEXTURE )° Bind the depth texture° Render the scene2/21/0723Environment maps■ Can use transformed surface normal to compute texture coordinates■ This kind of mapping can be used to simulate reflections, and other


View Full Document

UNC-Chapel Hill COMP 770 - Advanced texture mapping

Download Advanced 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 Advanced 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 Advanced 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?