asset-optimization

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Asset Optimization

资源优化

Asset Pipeline Overview

资源管线概览

┌─────────────────────────────────────────────────────────────┐
│                    ASSET PIPELINE FLOW                       │
├─────────────────────────────────────────────────────────────┤
│  SOURCE ASSETS (Large, Editable):                            │
│  .psd, .fbx, .blend, .wav, .tga                             │
│                              ↓                               │
│  IMPORT SETTINGS:                                            │
│  Compression, Format, Quality, Platform overrides           │
│                              ↓                               │
│  PROCESSING:                                                 │
│  Compression, Mipmaps, LOD generation, Format conversion    │
│                              ↓                               │
│  RUNTIME ASSETS (Optimized):                                 │
│  .dds, .ktx, .ogg, engine-specific formats                  │
│                              ↓                               │
│  PACKAGING:                                                  │
│  Asset bundles, streaming chunks, platform builds           │
└─────────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────┐
│                    资源管线流程                               │
├─────────────────────────────────────────────────────────────┤
│  源资源(大体积、可编辑):                            │
│  .psd, .fbx, .blend, .wav, .tga                             │
│                              ↓                               │
│  导入设置:                                            │
│  压缩、格式、质量、平台覆盖配置           │
│                              ↓                               │
│  处理流程:                                                 │
│  压缩、Mipmap生成、LOD生成、格式转换    │
│                              ↓                               │
│  运行时资源(已优化):                                 │
│  .dds, .ktx, .ogg, 引擎专属格式                  │
│                              ↓                               │
│  打包处理:                                                  │
│  资源包、流式分块、平台构建版本           │
└─────────────────────────────────────────────────────────────┘

Texture Optimization

纹理优化

TEXTURE COMPRESSION FORMATS:
┌─────────────────────────────────────────────────────────────┐
│  PLATFORM   │ FORMAT      │ QUALITY  │ SIZE/PIXEL         │
├─────────────┼─────────────┼──────────┼────────────────────┤
│  PC/Console │ BC7         │ Best     │ 1 byte             │
│  PC/Console │ BC1 (DXT1)  │ Good     │ 0.5 byte           │
│  iOS        │ ASTC 6x6    │ Great    │ 0.89 byte          │
│  Android    │ ETC2        │ Good     │ 0.5-1 byte         │
│  Mobile     │ ASTC 8x8    │ Good     │ 0.5 byte           │
│  Uncompressed│ RGBA32     │ Perfect  │ 4 bytes            │
└─────────────┴─────────────┴──────────┴────────────────────┘

TEXTURE SIZE GUIDELINES:
┌─────────────────────────────────────────────────────────────┐
│  Character (main):    2048x2048                             │
│  Character (NPC):     1024x1024                             │
│  Props (large):       1024x1024                             │
│  Props (small):       512x512 or 256x256                    │
│  UI elements:         Power of 2, vary by size             │
│  Environment:         2048x2048 (tiling)                   │
│  Mobile maximum:      1024x1024 (prefer 512)               │
└─────────────────────────────────────────────────────────────┘
纹理压缩格式:
┌─────────────────────────────────────────────────────────────┐
│  平台   │ 格式      │ 质量  │ 每像素占用空间         │
├─────────────┼─────────────┼──────────┼────────────────────┤
│  PC/主机 │ BC7         │ 最佳     │ 1 字节             │
│  PC/主机 │ BC1 (DXT1)  │ 良好     │ 0.5 字节           │
│  iOS        │ ASTC 6x6    │ 优秀    │ 0.89 字节          │
│  Android    │ ETC2        │ 良好     │ 0.5-1 字节         │
│  移动设备     │ ASTC 8x8    │ 良好     │ 0.5 字节           │
│  未压缩│ RGBA32     │ 完美  │ 4 字节            │
└─────────────┴─────────────┴──────────┴────────────────────┘

纹理尺寸指南:
┌─────────────────────────────────────────────────────────────┐
│  主角模型:    2048x2048                             │
│  NPC模型:     1024x1024                             │
│  大型道具:       1024x1024                             │
│  小型道具:       512x512 或 256x256                    │
│  UI元素:         2的幂次方,根据尺寸调整             │
│  环境资源:         2048x2048(可平铺)                   │
│  移动设备上限:      1024x1024(优先512)               │
└─────────────────────────────────────────────────────────────┘

Mesh Optimization

网格优化

POLYGON BUDGET GUIDELINES:
┌─────────────────────────────────────────────────────────────┐
│  PLATFORM   │ HERO CHAR │ NPC      │ PROP     │ SCENE     │
├─────────────┼───────────┼──────────┼──────────┼───────────┤
│  PC High    │ 100K      │ 30K      │ 10K      │ 10M       │
│  PC Med     │ 50K       │ 15K      │ 5K       │ 5M        │
│  Console    │ 80K       │ 25K      │ 8K       │ 8M        │
│  Mobile     │ 10K       │ 3K       │ 500      │ 500K      │
│  VR         │ 30K       │ 10K      │ 2K       │ 2M        │
└─────────────┴───────────┴──────────┴──────────┴───────────┘

LOD CONFIGURATION:
┌─────────────────────────────────────────────────────────────┐
│  LOD0: 100% triangles  │  0-10m   │ Full detail           │
│  LOD1: 50% triangles   │  10-30m  │ Reduced               │
│  LOD2: 25% triangles   │  30-60m  │ Low detail            │
│  LOD3: 10% triangles   │  60m+    │ Billboard/Impostor    │
└─────────────────────────────────────────────────────────────┘
多边形数量预算指南:
┌─────────────────────────────────────────────────────────────┐
│  平台   │ 主角 │ NPC      │ 道具     │ 场景     │
├─────────────┼───────────┼──────────┼──────────┼───────────┤
│  PC 高配置    │ 100K      │ 30K      │ 10K      │ 10M       │
│  PC 中配置     │ 50K       │ 15K      │ 5K       │ 5M        │
│  主机    │ 80K       │ 25K      │ 8K       │ 8M        │
│  移动设备     │ 10K       │ 3K       │ 500      │ 500K      │
│  VR         │ 30K       │ 10K      │ 2K       │ 2M        │
└─────────────┴───────────┴──────────┴──────────┴───────────┘

LOD配置:
┌─────────────────────────────────────────────────────────────┐
│  LOD0: 100% 三角形  │  0-10米   │ 完整细节           │
│  LOD1: 50% 三角形   │  10-30米  │ 简化细节               │
│  LOD2: 25% 三角形   │  30-60米  │ 低细节            │
│  LOD3: 10% 三角形   │  60米以上    │ 公告板/Impostor    │
└─────────────────────────────────────────────────────────────┘

Audio Optimization

音频优化

AUDIO COMPRESSION:
┌─────────────────────────────────────────────────────────────┐
│  TYPE        │ FORMAT  │ QUALITY   │ STREAMING            │
├─────────────┼─────────┼───────────┼──────────────────────┤
│  Music       │ Vorbis  │ 128-192   │ Always stream        │
│  SFX (short) │ ADPCM   │ High      │ Decompress on load   │
│  SFX (long)  │ Vorbis  │ 128       │ Stream if > 1MB      │
│  Voice       │ Vorbis  │ 96-128    │ Stream               │
│  Ambient     │ Vorbis  │ 96        │ Stream               │
└─────────────┴─────────┴───────────┴──────────────────────┘

AUDIO MEMORY BUDGET:
• Mobile: 20-50 MB
• Console: 100-200 MB
• PC: 200-500 MB
音频压缩:
┌─────────────────────────────────────────────────────────────┐
│  类型        │ 格式  │ 质量   │ 流式传输设置            │
├─────────────┼─────────┼───────────┼──────────────────────┤
│  背景音乐       │ Vorbis  │ 128-192   │ 始终启用流式传输        │
│  短音效 │ ADPCM   │ 高      │ 加载时解压   │
│  长音效  │ Vorbis  │ 128       │ 大于1MB时启用流式传输      │
│  语音       │ Vorbis  │ 96-128    │ 启用流式传输               │
│  环境音     │ Vorbis  │ 96        │ 启用流式传输               │
└─────────────┴─────────┴───────────┴──────────────────────┘

音频内存预算:
• 移动设备: 20-50 MB
• 主机: 100-200 MB
• PC: 200-500 MB

Batch Processing Script

批量处理脚本

python
undefined
python
undefined

✅ Production-Ready: Asset Batch Processor

✅ Production-Ready: Asset Batch Processor

import subprocess from pathlib import Path from concurrent.futures import ThreadPoolExecutor
def process_textures(input_dir: Path, output_dir: Path, platform: str): """Batch process textures for target platform."""
settings = {
    'pc': {'format': 'bc7', 'max_size': 4096},
    'mobile': {'format': 'astc', 'max_size': 1024},
    'console': {'format': 'bc7', 'max_size': 2048},
}

config = settings.get(platform, settings['pc'])

textures = list(input_dir.glob('**/*.png')) + list(input_dir.glob('**/*.tga'))

def process_single(texture: Path):
    output_path = output_dir / texture.relative_to(input_dir)
    output_path = output_path.with_suffix('.dds')
    output_path.parent.mkdir(parents=True, exist_ok=True)

    subprocess.run([
        'texconv',
        '-f', config['format'],
        '-w', str(config['max_size']),
        '-h', str(config['max_size']),
        '-m', '0',  # Generate all mipmaps
        '-o', str(output_path.parent),
        str(texture)
    ])

with ThreadPoolExecutor(max_workers=8) as executor:
    executor.map(process_single, textures)
undefined
import subprocess from pathlib import Path from concurrent.futures import ThreadPoolExecutor
def process_textures(input_dir: Path, output_dir: Path, platform: str): """Batch process textures for target platform."""
settings = {
    'pc': {'format': 'bc7', 'max_size': 4096},
    'mobile': {'format': 'astc', 'max_size': 1024},
    'console': {'format': 'bc7', 'max_size': 2048},
}

config = settings.get(platform, settings['pc'])

textures = list(input_dir.glob('**/*.png')) + list(input_dir.glob('**/*.tga'))

def process_single(texture: Path):
    output_path = output_dir / texture.relative_to(input_dir)
    output_path = output_path.with_suffix('.dds')
    output_path.parent.mkdir(parents=True, exist_ok=True)

    subprocess.run([
        'texconv',
        '-f', config['format'],
        '-w', str(config['max_size']),
        '-h', str(config['max_size']),
        '-m', '0',  # Generate all mipmaps
        '-o', str(output_path.parent),
        str(texture)
    ])

with ThreadPoolExecutor(max_workers=8) as executor:
    executor.map(process_single, textures)
undefined

🔧 Troubleshooting

🔧 故障排查

┌─────────────────────────────────────────────────────────────┐
│ PROBLEM: Build size too large                               │
├─────────────────────────────────────────────────────────────┤
│ SOLUTIONS:                                                   │
│ → Audit unused assets                                       │
│ → Increase texture compression                              │
│ → Enable mesh compression                                   │
│ → Split into downloadable content                           │
│ → Use texture atlases                                       │
└─────────────────────────────────────────────────────────────┘

┌─────────────────────────────────────────────────────────────┐
│ PROBLEM: Long import times                                  │
├─────────────────────────────────────────────────────────────┤
│ SOLUTIONS:                                                   │
│ → Use asset database caching                                │
│ → Import in batches                                         │
│ → Use faster SSD storage                                    │
│ → Pre-process assets in CI/CD                               │
└─────────────────────────────────────────────────────────────┘

┌─────────────────────────────────────────────────────────────┐
│ PROBLEM: Assets look blurry                                 │
├─────────────────────────────────────────────────────────────┤
│ SOLUTIONS:                                                   │
│ → Reduce compression for important assets                   │
│ → Increase texture resolution                               │
│ → Check mipmap settings                                     │
│ → Use appropriate filtering mode                            │
└─────────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────┐
│ 问题:构建包体积过大                               │
├─────────────────────────────────────────────────────────────┤
│ 解决方案:                                                   │
│ → 审计未使用的资源                                       │
│ → 提升纹理压缩级别                              │
│ → 启用网格压缩                                   │
│ → 拆分为可下载内容                           │
│ → 使用纹理图集                                       │
└─────────────────────────────────────────────────────────────┘

┌─────────────────────────────────────────────────────────────┐
│ 问题:导入时间过长                                  │
├─────────────────────────────────────────────────────────────┤
│ 解决方案:                                                   │
│ → 使用资源数据库缓存                                │
│ → 批量导入                                         │
│ → 使用更快的SSD存储                                    │
│ → 在CI/CD中预处理资源                               │
└─────────────────────────────────────────────────────────────┘

┌─────────────────────────────────────────────────────────────┐
│ 问题:资源显示模糊                                 │
├─────────────────────────────────────────────────────────────┤
│ 解决方案:                                                   │
│ → 降低重要资源的压缩比例                   │
│ → 提升纹理分辨率                               │
│ → 检查Mipmap设置                                     │
│ → 使用合适的过滤模式                            │
└─────────────────────────────────────────────────────────────┘

Memory Budgets

内存预算

PlatformTexturesMeshesAudioTotal
Mobile Low100 MB50 MB30 MB200 MB
Mobile High500 MB200 MB100 MB1 GB
Console2 GB1 GB200 MB4 GB
PC4 GB2 GB500 MB8 GB

Use this skill: When optimizing assets, managing memory, or streamlining pipelines.
平台纹理网格音频总计
低配移动设备100 MB50 MB30 MB200 MB
高配移动设备500 MB200 MB100 MB1 GB
主机2 GB1 GB200 MB4 GB
PC4 GB2 GB500 MB8 GB

使用本技巧场景:优化资源、管理内存或精简管线时。