当前位置:网站首页>[TA frost wolf \u may - "hundred people plan"] Figure 3.6 texture compression - inclusion slimming
[TA frost wolf \u may - "hundred people plan"] Figure 3.6 texture compression - inclusion slimming
2022-07-28 23:58:00 【zczplus】
【TA- Frost Wolf _may-《 Hundred people plan 》】 graphics 3.6 Texture compression —— Inclusion slimming
【TA- Frost Wolf _may-《 Hundred people plan 》】 graphics 3.6 Texture compression —— Inclusion slimming
3.6.1 Texture compression
Texture compression is to solve the problem of memory 、 Bandwidth issues , Image compression technology specially used for storing textures in computer graphics rendering system ;
Image format
Picture format is the storage format of picture file , Usually on disk 、 Used when storing and transferring files in memory ;
Texture format
Texture format is the texture data format that the graphics card can sample directly , Usually used when loading textures into a graphics card ;
Texture pipeline

Difference :
- The texture compression format is based on block compression , It can read the byte block of the pixel faster and decompress it to support random access ;
- The image compression format is based on the whole image , The resolution of a single pixel cannot be realized directly ; also , The image compression format cannot be GPU distinguish , Also need to CPU Decompress it into an uncompressed liberal arts format to be recognized ;
3.6.2 Common texture formats

Uncompressed format

DXTC
DXTC Texture compression format comes from S3 The company put forward S3TC Algorithm , The basic idea is to put 4x4 The pixel blocks are compressed into a 64 or 128 Bit data block , The advantage is that a fixed size and independent coding fragment is created , No shared lookup tables or other dependencies , The decoding process is simplified ;
DXT 1
Each block has 2 individual 16 position RGB Color value (RGB565 565 The number of digits representing three channels ), Represents this 4x4 Extreme value of color in pixel block , Then two intermediate color values are calculated by linear interpolation ,16 individual 2 The bit index value represents the color value index of each pixel ;
For having Alpha Mapping of information , Then the interpolation only generates an intermediate color , When two bits are indexed to the fourth color, it means that the pixel is transparent ;
The reference object is :RGB24
16 Pixels share 64 Bit data , Then a single pixel is used 4 Bit data ;
DXT2/3
And DXT1 be similar , In the original 64 Bit basis , newly added 64 Bit data is used to represent Alpha value , The whole data block becomes 128 position ; Thus, the occupation of each pixel 8 Bit data ,0-3 Bits represent transparent information ,4-7 Bits represent color information ;
DXT4/5
And DXT2/3 The difference is that Alpha The information is obtained by linear interpolation , Representing color information 64 The bit data block remains unchanged , and Alpha Information is provided by 2 individual 8 position Alpha Extreme values and 16 individual 3 Bit index values ;
expand
If in Unity The inner map type is normal , Will use DXTnm Compressed format , This format will map normals R Channel deposit A passageway , then RB The channel is cleared to 1, In this way, we can find XY The information is stored in RGB/A Respectively compress , So as to obtain higher accuracy , And then based on XY build Z Channel data ;
Compression ratio reference object RGBA 32 position
DXT2/3/4/5 The number of digits is 128 position , Can correspond to 16 Pixel , So the number of bits occupied by each pixel is 8 position , So the compression ratio is 32/8 = 4
ATI1/2
ATI1 Also known as BC4, Each data block stores a single color data channel , Coding and DXT5 Medium Alpha Same data , It is often used to store height map 、 Smoothness map , The effect is basically the same as the original image ;
If the comparison object is a single channel 8 position , use 64 Who said 16 Pixel , Then the compression ratio is 8/ (64/16) = 2:1
ATI2 Also known as BC5, Each block stores the data of two color channels , Ditto with DXT5 in Alpha Data is encoded in the same way , It's equivalent to storing two BC4 block ;
If yes, store the discovery in XY ... is used in the dual channel BC5 Format compression , Because each channel has its own index , So normal mapping XY Information can be compared to BC1 Keep more fidelity in , The disadvantage is that you need to use twice as much memory , More bandwidth is also required to pass textures to shaders ;
If the comparison object is two channels 16 position , use 128 Who said 16 Pixel , Then the compression ratio is 16/(128/16) = 2:1
BC6/7
Only in D3D11 And above are supported in graphics hardware , Each block occupies 16 byte ,BC7 in the light of 8 position RGB or RGBA data , and BC6 in the light of RGB Half precision floating point data , therefore BC6 Is the only one that can be stored natively HDR Of BC Format ;
BC6 It's specifically for HDR( High dynamic range ) Compression algorithm of image design , The compression ratio is 6:1;
BC7 It's specifically for LDR( Low dynamic range ) Compression algorithm of image design , The compression ratio is 3:1, This format is used for high quality RGBA Compress , It can significantly reduce the error effect caused by compressing normals ;
ETC
ETC Widely used on Android platform :

First select the column horizontally through the brightness index , Then use the pixel index to select which row in the corresponding column , Finally, adjust on the basis of the original color , obtain 16 A different color ;
ETC1
The comparison object is RGB, common 24 position
Compression ratio :24 / (64 /16) = 6:1
ETC2
Yes ETC1 An extension of , Support Alpha Channel compression , Hardware requirements OpenGL ES 3.0 and OpenGL4.3 above ;
ETC1 The required length and width is 2 The power of
ETC2 It is required that the length and width can be 4 to be divisible by
ASTC
from AMD and ARM Jointly developed texture compression format ,ASTC All the indicators are very good , The advantage is that algorithms with different compression rates can be selected according to different pictures , The picture does not need to be 2 The power of , Support at the same time LDR and HDR, The disadvantage is that the compatibility is not perfect and the decoding time is long ;
ASTC It is also a block based compression algorithm , And BC7 similar , Its data block size is fixed to 128 position , But the number of pixels is variable , from 4x4 To 12x12 Pixels have ;
Two interpolation endpoints are stored in each data block , But it doesn't necessarily store color information , It could be Layer Information , This can be used to Normal or Alpha Better compression ; Different forms of compression can be performed according to the map type ;
For each texture element in the block , Store the weight of its corresponding interpolation endpoint , The number of stored weights can be less than the number of texture elements , The weight value of each texture element can be obtained by interpolation , Then calculate the color ;
PVRTC
Support only Iphone、Ipad And some Android phones ;
PVRTC Divide the image into low frequency signal and high frequency signal , The low frequency signal consists of two low resolution images AB form , High frequency signals are low precision modulated images , The weight of each pixel blend is recorded , When decoding AB The image is magnified by bilinear interpolation , Then the mixture is carried out according to the weight of the modulated image ;
PVRTC 4-bpp(4 bit per pixel) Put one 4x4 The pixel unit is pressed into a 64 Bit data block , One... Is stored in each block 32 Bit modulation data ( Then each pixel is divided into 2 Bit modulation data , Expressed as 00,01,10,11), One 1 Bit modulation flag ( Used to control modulation data ),15 Bit color A,1 Bit color A Opaque logo ,14 Bit color B,1 Bit color B Opaque logo ( Used to decide according to RGBA The storage is still RGB For storage , If different , Then judge according to the figure with high digits );
If the result corresponds to RGB Then the compression ratio is 6:1, If the corresponding RGBA Then the compression ratio is 8:1;
3.6.3 summary
The picture quality is better :RGBA>ASTC4x4 > ASTC 6x6 > ETC2 ≈ ETC1
Compression ratio :
DXT1 6:1
DXT2/3 4:1
DXT4/5 4:1
ATI1 4:1
ATI2 4:1
BC6 6:1
BC7 3:1
PVRTC 6:1
ASTC 4:1 ~ 35.95:1
Format summary
PC:
- Low quality use DXT1 Format ( I won't support it A passageway ), Use DXT5 Format support A passageway ;
- High quality use BC7 Format , Support A passageway ;
Android :
- Low quality use ETC1 Format , But does not support A passageway ;
- Low quality use ETC2 Format , Support A passageway , Need to be in OpenGL ES 3.0 / OpenGL 4.3 Above version ;
- High quality use ASTC Format , Need to be in Android 5.0/ OpenGL ES 3.1 Above version ;
IOS:
- High quality use ASTC Format , need IPhone6 above ;
- Low quality use PVRTC2 Format , Support IPhone6 The following versions ;
Homework ( Mistake , See the supplement )
Experimental scenario :
The texture format is compressed to ASTC, The size of a single texture is 0.6MB, The memory usage is as follows :

The texture format is compressed to ETC2, You can see that the size of the compressed texture is 0.7MB The memory usage is as follows :

The texture is compressed to ETC Format , The compressed texture size is 0.7MB, The memory usage is as follows :
It was found that , When the picture of the whole scene is reduced to a picture , Memory usage has not changed ; The following two images use different texture compression methods to get a more obvious contrast in texture size ;

Add
The previous modification of the image compression format in the system settings has no effect , After searching, it is found that it needs to be modified in a single texture image , After modification, there is a difference , Or use URP Perform performance analysis , give the result as follows :( And closed here Mipmap Compare )
You can see ASTC Compressed picture ratio RGBA The original picture of is in Texture2D The sampling process consumes less memory space .
Another experiment , Turn on MIPMAP It will slightly increase the memory consumption , But it is still less than uncompressed , It should still be related to the test scenario .
In addition, there are many compressed formats ,ASTC6x6 The compression result of may be less than ETC2 Of .
边栏推荐
- 商家对积分体系运营的两个误解
- 小程序editor富文本编辑使用及rich-text解析富文本
- Websocket heartbeat mechanism (keep alive mechanism)
- Pycharm configuring the running environment
- The computer doesn't know what to uninstall, can't open the calculator, can't edit screenshots, can't open txt files, and so on
- Eight performance analysis indicators of effective supply chain management (Part 1)
- Inspur clusterenginev4.0 remote command execution vulnerability cve-2020-21224
- Learn browser decoding from XSS payload
- 1-7 解决类中方法的this指向问题
- Exchange 2013 SSL证书安装文档
猜你喜欢

酪氨酸脱羧酶丨Worthington粪链球菌酪氨酸脱羧酶的特征

Use pytoch to quickly train the network model

After SAP Oracle replicates a new instance, the remote connection of the database reports an error ora-01031

EN 1873 assembly accessories for roofing - plastic single roof lamps - CE certification

Wildcard ssl/tls certificate

解决:Direct local .aar file dependencies are not supported when building an AAR.

PowerCL 批量创建及管理虚拟交换机

Leetcode59. 螺旋矩阵 II

迅为IMX6开发板QT系统创建AP热点基于RTL8723-交叉编译iptables

使用Pytorch快速训练网络模型
随机推荐
Explanation of history and chemical properties of Worthington ribonuclease B
电商数据模型设计
Exchange 2013 SSL证书安装文档
Worthington RNA determination detailed introduction
Worthington丨Worthington胰蛋白酶化学性质及相关研究
The computer doesn't know what to uninstall, can't open the calculator, can't edit screenshots, can't open txt files, and so on
1-7 解决类中方法的this指向问题
Urease -- Characteristics and determination scheme of Worthington jack bean urease
Those "experiences and traps" in the data center
连接池-归还连接详解(下)
DoIP测试开发实践
1-5 类式组件
Yolov5 learning notes (I) -- principle overview
pip镜像下载
PHP 海报二维码合成
SQL left connection, internal connection writing method "recommended collection"
Powercli VMware vCenter deploys conventional new VMS in batch through self built PXE server with one click
leetcode 763. Partition Labels 划分字母区间(中等)
添加构建依赖项报错
剑指 Offer 55 - I. 二叉树的深度