Skip to content
This repository has been archived by the owner on Aug 7, 2024. It is now read-only.

feat: ktx2 update #787

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
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
8 changes: 7 additions & 1 deletion docs/editor-publish.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ label: Editor-Interface
---

<figure style="float: right;position: relative; z-index: 2;">
<img alt="Hierarchy Pane" src="https://mdn.alipayobjects.com/huamei_fvsq9p/afts/img/A*oMBrSq53g1UAAAAAAAAAAAAADqiTAQ/original">
<img alt="Hierarchy Pane" src="https://mdn.alipayobjects.com/rms/afts/img/A*XXiMTbmWKg0AAAAAAAAAAAAAARQnAQ/original/image-20230914161439413.png" style="zoom:50%;">
<figcaption style="text-align:center; color: #889096;font-size:12px">项目导出导出配置面板</figcaption>
</figure>


Galacean Editor 项目导出功能可以将当前编辑器项目作为一个前端项目下载到本地。你可以在编辑器中配置项目导出的参数,如资产导出配置、渲染导出配置、物理导出配置等。基于这些配置,编辑器会生成出项目所需的代码、资产, 生成对应的 `package.json`,并最终打包成一个 zip 包供你下载。

## 导出配置
Expand All @@ -18,6 +19,11 @@ Galacean Editor 项目导出功能可以将当前编辑器项目作为一个前

资产导出配置可以用来控制导出的资源类型和质量等参数。在资产导出配置中,你可以选择导出的资源类型,例如模型、纹理、HDR 等等,以及选择每种类型的导出质量和格式等参数。在导出模型时,你可以选择是否导出模型的网格信息、骨骼信息、动画信息等。

#### KTX2
勾选 [KTX2](https://www.khronos.org/ktx/) 开启[纹理压缩](${docs}texture-compression-cn)优化选项。**压缩纹理**是一种优化图形性能的技术,它通过使用专门的算法将图形数据压缩为更小的大小。在游戏和其他图形密集型应用中,压缩纹理可以显著降低 GPU 的内存并提高帧率,从而改善用户体验。

默认的压缩配置是 UASTC,开启 MIPMAP 和 ZSTD 压缩。后续编辑器的迭代会逐步开放更多的配置选项。Galacean 采取的是 **KTX2(Khronos Texture Container version 2.0)** 方案。KTX2 会根据设备平台支持运行时转码到对应格式的压缩纹理。

### 渲染导出配置

渲染导出配置可以用来控制项目的渲染效果和性能等参数。在渲染导出配置中,你可以配置 WebGL 的版本, 是否为项目开启抗锯齿, 设备的像素比等.
Expand Down
33 changes: 31 additions & 2 deletions docs/texture-compression.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,38 @@ group: 纹理
label: Graphics/Texture
---

## KTX2
**KTX2**(Khronos Texture Container version 2.0) 是 Khronos 推出最新的纹理压缩方案,Galacean 在 1.1 版本中已经支持。KTX2 会根据设备平台支持运行时转码到对应格式的压缩纹理(BC/PVRTC/ETC/ASTC)。
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里是不是要讲一讲 KTX2 的格式怎么生成?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

下面讲了


在引擎中,直接使用 `resourceManager` 加载即可:

```typescript
engine.resourceManager.load("xxx.ktx2")
// 或
engine.resourceManager.load({
type: AssetType.KTX2,
url: "xxx.ktx2"
})
```

glTF 中使用 ktx2 需要包含 [KHR_texture_basisu](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_texture_basisu/README.md) 扩展。

KTX2 的生成可以使用:

- toktx
- basisu
- 编辑器打包,可以参考『[项目发布]((${docs}editor-publish-cn))』文档。

### 兼容性

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


## KTX1(不推荐)

Galacean 支持 **DXT/PVR/ETC/ASTC** 格式的压缩纹理,并且支持通过 [KTX1.0](https://registry.khronos.org/KTX/specs/1.0/ktxspec_v1.html) 容器格式加载。

## 使用
### 使用

因为各个硬件支持的压缩格式不一样,所以在使用前请先查询是否支持某种格式:

Expand Down Expand Up @@ -37,7 +66,7 @@ engine.resourceManager

<playground src="compressed-texture.ts"></playground>

## 机型适配
### 机型适配

引擎不能保证压缩纹理在所有设备上都能支持,为了保证兼容性,建议尝试以下步骤:

Expand Down