Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: improve texture compression doc #2231

Merged
merged 2 commits into from
Jul 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions docs/zh/graphics/texture/compression.md
Original file line number Diff line number Diff line change
@@ -31,14 +31,16 @@ KTX2 的生成可以使用:

- toktx
- basisu
- 编辑器打包,可以参考『[项目发布](/docs/assets-build)』文档。

## 兼容性
### 编辑器

KTX2 转码使用到了 WebAssembly 技术,需要使用 Chrome 57+,和 iOS 11.3+(11.0 ~ 11.2.以下的 WebAssembly 存在 [bug](https://bugs.webkit.org/show_bug.cgi?id=181781)
编辑器在项目打包时,可以配置选项生成 KTX2,可以参考『[项目发布](${docs}assets-build)』文档。项目导出是全局的配置,也可以独立给不同的纹理资源配置不同的压缩格式。在编辑器的纹理面板下勾选 overwrite 可以覆盖全局配置:

iOS 16 以下系统,在通过 worker 加载必要的 KTX2 解析 wasm 文件时会概率发生无返回的情况,尤其是在 wasm 首次加载时概率较大。可以通过 iOS 不走 worker 来绕过去:
<img src="https://mdn.alipayobjects.com/rms/afts/img/A*fmURSZ4HwKUAAAAAAAAAAAAAARQnAQ/original/image-20240705112419249.png" alt="image-20240705112419249" style="zoom:50%;" />

```typescript
WebGLEngine.create({ canvas: "canvas", ktx2Loader: { workerCount: 0 } });
```
- ETC1S 尺寸小,内存极小,但是质量较低,适合 albedo, specular 等贴图
- UASTC 尺寸大,质量高,适合 normal 这类贴图

## 兼容性

KTX2 转码使用到了 WebAssembly 技术,需要使用 Chrome 57+,和 iOS 11.3+(11.0 ~ 11.2.以下的 WebAssembly 存在 [bug](https://bugs.webkit.org/show_bug.cgi?id=181781)