starling教程-纹理(Texture)(五)

本文详细介绍了纹理在游戏开发中的应用,包括Texture类的各种APIs及其使用方法,支持的图片格式,如PNG、JPEG、JPEG-XR、ATF等,并深入探讨了MIP映射的工作原理及在GPU中的作用。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

texture是被创建来填充Image对象的,Texture和Image的关系就好像是本地的BitmapData和Bitmap的关系一样。Texture类包含如下的apis:

•  base : The Stage3D texture object the texture is based on. •  dispose : Disposes the underlying texture data. •  empty : Returns a Texture object out of dimensions (width and height). •  frame : The texture frame (see class description). •  fromBitmap : Returns a Texture object out of a Bitmap object. This Bitmap object can be embedded or loaded dynamically. •  fromBitmapData : Returns a Texture object out of a BitmapData object. •  fromAtfData : Allows the use of a compressed texture using the ATF (Adobe Texture Format). Compressed textures allows you to save a lot of memory especially on constrained environments like mobile devices. •  fromTexture : Allows the use of a texture and returns a new texture. •  height : The height of the texture in pixels. •  mipmapping : Indicates if the texture contains mip maps. •  premultipliedAlpha : Indicates if the alpha values are premultiplied into the RGB values. •  repeat : Indicates if the texture should repeat like a wallpaper or stretch the outermost pixels. •  width : The width of the texture in pixels.

你的纹理可以使用不同的图片格式,下面是它支持的文件格式列表:

•  PNG : As alpha channel is often required, PNG is one of the most common file format used for textures. •  JPEG : The classic JPEG format can also be used. Remember that on the GPU the image will be decompressed, so using JPEG will not limit the memory usage and you will not be able to use transparency in your textures. •  JPEG-XR : JPEG XR (abbr. for JPEG extended range[4]) is a still-image compression standard and file format for continuous tone photographic images, based on technology originally developed and patented by Microsoft under the name HD Photo (formerly Windows Media Photo). It supports both lossy and lossless compression, and is the preferred image format for Ecma-388 Open XML Paper Specification documents. •  ATF : Adobe Texture Format. This is the best file format for the best compression. ATF files are primarily a file container to store lossy texture data. It achieves its lossy compression through to the use of two common techniques: JPEG-XR1 compression and block based compression. JPEG-XR compression provide a competitive method to save storage space and network bandwidth. Block based compression provides a way to reduce texture memory usage on the client, at a fixed ratio of 1:8 compared to RGBA textures. ATF supports three types of block based compression: DXT12, ETC13 and PVRTC4.

下面让我们来更深入的了解一下纹理的概念,并揭开gpu处理图片的本质-mip映射(什么是mip映射呢?)

纹理大小是固定的,但虚拟世界的物体没有一定形状,要找到一个尺寸和多边形大小完全符合的物体很难。为此,软件商提供同一纹理的不同分辨率版本,比如一个256X256X256纹理,通常会有一个64X64X64和一个128X128X128的纹理版本,这是纹理版本就叫MIP映射,意即一个纹理映射出不同大小的多个纹理。在渲染之前,程序选出匹配的版本,描绘在多边形上。因为多边形每一面的大小都有差异,往往每面采用的纹理都不相同,高、低分辨率纹理的连接处会出现一边清晰一边模糊的问题,必须进行过滤处理,使两者之间的过滤变得平滑,才会让画质得以提升。Radeon仅有3D纹理,没有3D MIP映射和过滤的补充,毫无实用意义,也许只是作为Radeon 8500/7500的试验。

转载于:https://www.cnblogs.com/huangxiaoyi/p/4442305.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值