opengl superbible 5 edition chapter 7——More Advanced Texture Topics

In Chapter 5, “Basic Texturing," u first learned the ropes 绳索 of texture mapping with opengl. primarily we were concerned with the basics: loading a 2D image file, using texture coordinates, the different wrap modes, and so on. now it is time to dig a little deeper and expand on that knowledge base. u soon see that texture data can take on the form of far more than just a 2D image file loaded from disk, and sometimes textures do not even contain visual data or a picture of any kind at all! finally, u see how sometimes textures do not even really exist, but are literally made up on the fly by the fragment program.

rectangle textures
first, we continue to build upon our experience with using image files for texture, images that we actually want to display in some way. chapter 5 was mostly about 2D image using the texture target GL_TEXTURE_2D, and we also showed how to use GL_TEXTURE_1D in the previous chapter as a color lookup table for cell shading. for one-, two-, and three-dimensional textures (remember GL_TEXTURE_3D, too), we typically mapped textures to geometry with normalized texture coordinates that ranged from 0.0 to 1.0. we could stray outside 超出 that range and use the various texture coordinate wrapping modes to determine whether the texture would repeat in different ways or be clamped down to the edges of the texture image.

another useful alternative to two-dimensional texture images is the texture target GL_TEXTURE_RECTANGLE. this texture target model work mostly like GL_TEXTRUE_2D, with a couple of exceptions. first, they can not be mipmapped, which means u can only load level zero with glTexImage2D. second, the texture coordinates are not normalized, which simply means rather than from 0.0 and 1.0 across the image, the texture coordinates actually address pixels. texture coodinate (5,19) is actually six pixels from the left, and 20 pixels up (remember, we programmers start couting at zero!) into the image. furthermore, texture coordinates can not repeat, and they do not support texture compression.

this is convenient for many applications where opengl is used to process and present image data rather than using textures for surface features of 3D models. hardware support for texture rectangles is also simpler than normal 2D texture mapping, making them fast and efficient as well.

cube maps
a cube map is treated as a single texture object but it is made up of six square (yes, they must be square!) 2D images that make up the six sides of a cube. applications of cube maps range from 3D light maps, reflections, and highly accurate environment maps.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值