Attention: Here be dragons

This is the latest (unstable) version of this documentation, which may document features not available in or compatible with released stable versions of Godot.

CompressedTexture2D

繼承: Texture2D < Texture < Resource < RefCounted < Object

二維紋理,可選擇壓縮。

說明

一種從 .ctex 檔載入的紋理。這種檔案格式是 Godot 內部使用的;它是通過匯入系統匯入其他圖像格式建立的。CompressedTexture2D 可以使用 4 種壓縮方法中的一種(包括沒有任何壓縮):

  • 無損(WebP 或 PNG,在 GPU 上不壓縮)

  • 有損(WebP,在 GPU 上不壓縮)

  • VRAM 壓縮(在 GPU 上壓縮)

  • VRAM 未壓縮(在 GPU 上不壓縮)

  • Basis Universal(在 GPU 上壓縮。與 VRAM 壓縮相比,檔更小,但壓縮速度更慢、品質更低)

只有 VRAM 壓縮實際上減少了 GPU 上的記憶體使用。無損有損壓縮方法將減少磁片上所需的儲存空間,但它們不會減少 GPU 上的記憶體使用,因為紋理未經壓縮地被發送到 GPU。

使用 VRAM 壓縮還可以縮短載入時間,因為與使用無損或失真壓縮的紋理相比,VRAM 壓縮的紋理載入速度更快。VRAM 壓縮會表現出明顯的偽影,並且它旨在用於 3D 算繪,而不是 2D。

屬性

String

load_path

""

bool

resource_local_to_scene

false (overrides Resource)

方法

Error

load(path: String)


屬性說明

String load_path = "" 🔗

CompressedTexture2D 的檔路徑,指向 .ctex 檔案。


方法說明

Error load(path: String) 🔗

從指定的路徑 path 載入紋理。