![大三05计算机图形学texture mapping_第1页](http://file4.renrendoc.com/view/c1fdbd7ad139144a03308c72f06abde8/c1fdbd7ad139144a03308c72f06abde81.gif)
![大三05计算机图形学texture mapping_第2页](http://file4.renrendoc.com/view/c1fdbd7ad139144a03308c72f06abde8/c1fdbd7ad139144a03308c72f06abde82.gif)
![大三05计算机图形学texture mapping_第3页](http://file4.renrendoc.com/view/c1fdbd7ad139144a03308c72f06abde8/c1fdbd7ad139144a03308c72f06abde83.gif)
![大三05计算机图形学texture mapping_第4页](http://file4.renrendoc.com/view/c1fdbd7ad139144a03308c72f06abde8/c1fdbd7ad139144a03308c72f06abde84.gif)
![大三05计算机图形学texture mapping_第5页](http://file4.renrendoc.com/view/c1fdbd7ad139144a03308c72f06abde8/c1fdbd7ad139144a03308c72f06abde85.gif)
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、OpenGL Texture MappingOpenGL中的纹理映射原著Ed AngelProfessor of Computer Science, Electrical and Computer Engineering, and Media ArtsUniversity of New Mexico编辑 武汉大学计算机学院图形学课程组2ObjectivesIntroduce the OpenGL texture functions and options3Basic Strategy基本策略Three steps to applying a texture应用纹理需要下面三个步骤specify
2、 the texture指定纹理read or generate image读入或生成图像assign to texture赋给纹理enable texturing激活纹理映射功能assign texture coordinates to vertices给每个顶点赋纹理坐标Proper mapping function is left to application由应用程序建立适当的映射函数specify texture parameters指定纹理参数wrapping环绕filtering滤波4Texture Mappingstxyzimagegeometrydisplay5Texture
3、 ExampleThe texture (below) is a 256 x 256 image that has been mapped to a rectangular polygon which is viewed in perspective6Texture Mapping and the OpenGL Pipelinegeometry pipelineverticespixel pipelineimagefragmentprocessorImages and geometry flow through separate pipelines that join during fragm
4、ent processing“complex” textures do not affect geometric complexity7Define a texture image from an array of texels (texture elements) in CPU memory Glubyte my_texels512512;Define as any other pixel mapScanned imageGenerate by application codeEnable texture mappingglEnable(GL_TEXTURE_2D)OpenGL suppor
5、ts 1-4 dimensional texture mapsSpecifying a Texture Image8Define Image as a TextureglTexImage2D( target, level, components, w, h, border, format, type, texels );target: type of texture, e.g. GL_TEXTURE_2Dlevel: used for mipmapping (discussed later)components: elements per texelw, h: width and height
6、 of texels in pixelsborder: used for smoothing (discussed later)format and type: describe texelstexels: pointer to texel arrayglTexImage2D(GL_TEXTURE_2D, 0, 3, 512, 512, 0, GL_RGB, GL_UNSIGNED_BYTE, my_texels);9Converting A Texture ImageOpenGL requires texture dimensions to be powers of 2If dimensio
7、ns of image are not powers of 2gluScaleImage( format, w_in, h_in, type_in, *data_in, w_out, h_out, type_out, *data_out );data_in is source imagedata_out is for destination imageImage interpolated and filtered during scaling10Based on parametric texture coordinatesglTexCoord*() specified at each vert
8、exst1, 10, 10, 01, 0(s, t) = (0.2, 0.8)(0.4, 0.2)(0.8, 0.4)ABCabcTexture SpaceObject SpaceMapping a Texture11Typical CodeglBegin(GL_POLYGON);glColor3f(r0, g0, b0); /if no shading usedglNormal3f(u0, v0, w0); / if shading usedglTexCoord2f(s0, t0);glVertex3f(x0, y0, z0);glColor3f(r1, g1, b1);glNormal3f
9、(u1, v1, w1);glTexCoord2f(s1, t1);glVertex3f(x1, y1, z1);.glEnd();Note that we can use vertex arrays to increase efficiency12InterpolationOpenGL uses interpolation to find proper texels from specified texture coordinatesCan be distortionsgood selectionof tex coordinatespoor selectionof tex coordinat
10、estexture stretchedover trapezoid showing effects of bilinear interpolation13Texture ParametersOpenGL has a variety of parameters that determine how texture is appliedWrapping parameters determine what happens if s and t are outside the (0,1) rangeFilter modes allow us to use area averaging instead
11、of point samplesMipmapping allows us to use textures at multiple resolutionsEnvironment parameters determine how texture mapping interacts with shading14Wrapping ModeClamping: if s,t 1 use 1, if s,t 0 use 0Wrapping: use s,t modulo 1glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP )glTexPa
12、rameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT )texturestGL_CLAMPwrappingGL_REPEATwrapping15Magnification and MinificationTexturePolygonMagnificationMinificationPolygonTextureMore than one texel can cover a pixel (minification) ormore than one pixel can cover a texel (magnification)Can use po
13、int sampling (nearest texel) or linear filtering( 2 x 2 filter) to obtain texture values16Filter ModesModes determined byglTexParameteri( target, type, mode ) glTexParameteri(GL_TEXTURE_2D, GL_TEXURE_MAG_FILTER, GL_NEAREST);glTexParameteri(GL_TEXTURE_2D, GL_TEXURE_MIN_FILTER, GL_LINEAR);Note that li
14、near filtering requires a border of an extra texel for filtering at edges (border = 1)17Mipmapped TexturesMipmapping allows for prefiltered texture maps of decreasing resolutionsLessens interpolation errors for smaller textured objectsDeclare mipmap level during texture definitionglTexImage2D( GL_TE
15、XTURE_*D, level, )GLU mipmap builder routines will build all the textures from a given imagegluBuild*DMipmaps( )18Example pointsamplingmipmapped pointsamplingmipmapped linear filtering linear filtering19Texture FunctionsControls how texture is appliedglTexEnvfiv( GL_TEXTURE_ENV, prop, param ) GL_TEX
16、TURE_ENV_MODE modesGL_MODULATE: modulates with computed shadeGL_BLEND: blends with an environmental colorGL_REPLACE: use only texture colorGL(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);Set blend color with GL_TEXTURE_ENV_COLOR20Perspective Correction HintTexture coordinate and color interpola
17、tioneither linearly in screen spaceor using depth/perspective values (slower)Noticeable for polygons “on edge”glHint( GL_PERSPECTIVE_CORRECTION_HINT, hint )where hint is one of GL_DONT_CAREGL_NICESTGL_FASTEST21Generating Texture CoordinatesOpenGL can generate texture coordinates automaticallyglTexGe
18、nifdv()specify a planegenerate texture coordinates based upon distance from the planegeneration modesGL_OBJECT_LINEARGL_EYE_LINEAR GL_SPHERE_MAP (used for environmental maps)22Angel: Interactive Computer Graphics 45E Addison-Wesley 2009Texture ObjectsTexture is part of the OpenGL state If we have different textures for different objects, OpenGL will be moving large amounts data from processor memory to texture memoryRecent versions of OpenGL have texture objectsone image per texture objectTexture memo
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025届甘肃省庆阳市第六中学高一数学第二学期期末监测模拟试题含解析
- 南平市重点中学2025届数学高一下期末学业水平测试试题含解析
- 广西壮族自治区来宾市2025届高一数学第二学期期末统考模拟试题含解析
- 湖南省湘潭县凤凰中学2025届高一下生物期末综合测试试题含解析
- 2025届广西示范初中高一化学第二学期期末预测试题含解析
- 2025届贵港市重点中学高一下化学期末综合测试试题含解析
- 全球与中国鲜花订阅服务市场现状分析及前景战略研究报告2024-2030年
- 2023年天然提取物调味料项目安全评价报告
- 奢侈品行业的品牌个性塑造途径与策略分析研究 工商管理专业开题报告
- 2023年网络特性测试仪器资金申请报告
- 贵州茶叶产区和主要产茶县
- 销售代理的开发与中断
- 预检分诊登记表(完整版)
- 农村小学家校沟通问题研究的中期报告
- 羟苯磺酸钙对慢性移植肾肾病的作用及机制
- 数字化智慧病理科建设白皮书
- 食品贮藏保鲜技术(第2版)高职PPT完整全套教学课件
- 人教版高中地理必修二第三章第一节农业区位因素及变化说课课件
- 北京版五年级全一册《羽毛球》评课稿
- 个人寿险业务人员基本管理办法
- 按摩场所治安防范应急预案
评论
0/150
提交评论