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.

ResourceImporterTexture

繼承: ResourceImporter < RefCounted < Object

匯入影像以用於 2D 或 3D 算繪。

說明

此匯入器匯入CompressedTexture2D 資源。如果您需要以更方便的方式在腳本中處理映像,請改用ResourceImporterImage。另請參閱ResourceImporterLayeredTexture

教學

屬性

int

compress/channel_pack

0

int

compress/hdr_compression

1

bool

compress/high_quality

false

float

compress/lossy_quality

0.7

int

compress/mode

0

int

compress/normal_map

0

float

compress/rdo_quality_loss

0.0

int

compress/uastc_level

0

int

detect_3d/compress_to

1

bool

editor/convert_colors_with_editor_theme

false

bool

editor/scale_with_editor_scale

false

bool

mipmaps/generate

false

int

mipmaps/limit

-1

int

process/channel_remap/alpha

3

int

process/channel_remap/blue

2

int

process/channel_remap/green

1

int

process/channel_remap/red

0

bool

process/fix_alpha_border

true

bool

process/hdr_as_srgb

false

bool

process/hdr_clamp_exposure

false

bool

process/normal_map_invert_y

false

bool

process/premult_alpha

false

int

process/size_limit

0

int

roughness/mode

0

String

roughness/src_normal

""

float

svg/scale

1.0


屬性說明

int compress/channel_pack = 0 🔗

Controls how color channels should be used in the imported texture.

sRGB Friendly: Prevents the R and RG color formats from being used, as they do not support nonlinear sRGB encoding.

Optimized: Allows the RG color format to be used if the texture does not use the blue channel. This reduces memory usage if the texture's blue channel can be discarded (all pixels must have a blue value of 0).


int compress/hdr_compression = 1 🔗

控制如何對 HDR 影像執行 VRAM 壓縮。

停用:切勿對 HDR 紋理使用 VRAM 壓縮,無論它們是不透明還是透明。相反,紋理會轉換為 RGBE9995(每通道 9 位元 + 5 位元指數 = 每像素 32 位元),以減少與半浮點或單精確度浮點影像格式相比的記憶體使用量。

僅不透明: 僅對不透明 HDR 紋理使用 VRAM 壓縮。這是由於 HDR 格式的限制,因為沒有同時支援透明度的 VRAM 壓縮 HDR 格式。

總是: 強制 VRAM 壓縮,即使對於具有 Alpha 通道的 HDR 紋理也是如此。為此,在匯入時將丟棄 Alpha 通道。

注意: 僅對 Radiance HDR (.hdr) 和 OpenEXR (.exr) 影像有效。


bool compress/high_quality = false 🔗

如果true,在桌面平台上使用BPTC 壓縮,在行動平台上使用ASTC 壓縮。使用BPTC 時,BC7 用於SDR 紋理,BC6H 用於HDR紋理。

如果 false,則在桌面平台上使用速度更快但品質較低的 S3TC 壓縮,在行動裝置/Web 平台上使用 ETC2。使用 S3TC 時,DXT1 (BC1) 用於不透明紋理,DXT5 (BC3) 用於透明或法線貼圖 (RGTC) 紋理。

BPTC 和 ASTC 支援 HDR 紋理的 VRAM 壓縮,但 S3TC 和 ETC2 不支援(請參閱compress/hdr_compression)。


float compress/lossy_quality = 0.7 🔗

使用有損壓縮模式時使用的品質。值越高,品質越好,但檔案大小越大。有損品質不會影響記憶體匯入紋理的使用,僅其在磁碟上的檔案大小。


int compress/mode = 0 🔗

要使用的壓縮模式。每個壓縮模式都提供不同的權衡:

無損:原始品質、高記憶體佔用、高磁碟空間、快速匯入。

有損: 品質降低、記憶體使用率高、磁碟空間小、匯入速度快。

VRAM 壓縮: 品質下降、記憶體使用率低、磁碟空間小、匯入速度最慢。僅用於 3D 場景中的紋理,不適用於 2D 元素。

VRAM 未壓縮: 原始品質、高記憶體使用率、磁碟大小最大、匯入速度最快。

Basis Universal: 品質降低、記憶體使用率低、磁碟大小最小、匯入速度慢。僅用於 3D 場景中的紋理,不適用於 2D 元素。

有關詳細信息,請參閱手冊中的壓縮模式


int compress/normal_map = 0 🔗

當使用紋理作為法線貼圖時,只需要紅色和綠色通道。鑑於常規紋理壓縮演算法會產生在法線貼圖中看起來不太好的偽像,因此RGTC壓縮格式是最適合此資料的。強制此選項啟用將使 Godot 將影像匯入為 RGTC 壓縮。預設情況下,它設定為「偵測」。這表示如果偵測到紋理被用作法線貼圖,它將變更為啟用並自動重新匯入。

請注意,RGTC 壓縮會影響產生的法線貼圖影像。您必須調整使用法線貼圖的藍色通道的自訂著色器才能考慮到這一點。內建材質著色器已經忽略法線貼圖中的藍色通道(無論實際法線貼圖的內容如何)。


float compress/rdo_quality_loss = 0.0 🔗

If greater than or equal to 0.01, enables Rate-Distortion Optimization (RDO) to reduce file size. Higher values result in smaller file sizes but lower quality.

Note: Enabling RDO makes encoding times significantly longer, especially when the image is large.

See also ProjectSettings.rendering/textures/basis_universal/rdo_dict_size and ProjectSettings.rendering/textures/basis_universal/zstd_supercompression_level if you want to reduce the file size further.


int compress/uastc_level = 0 🔗

The UASTC encoding level. Higher values result in better quality but make encoding times longer.


int detect_3d/compress_to = 1 🔗

這會變更偵測到紋理在 3D 中使用時所使用的 compress/mode 選項。

只有當偵測到紋理正在 3D 中使用時,變更此匯入選項才會生效。將其變更為停用,然後重新匯入不會變更紋理上的現有壓縮模式(如果偵測到在3D 中使用),但選擇VRAM 壓縮Basis Universal將。


bool editor/convert_colors_with_editor_theme = false 🔗

If true, converts the imported image's colors to match EditorSettings.interface/theme/icon_and_font_color. This assumes the image uses the exact same colors as Godot's own color palette for editor icons, with the source file designed for a dark editor theme. This should be enabled for editor plugin icons and custom class icons, but should be left disabled otherwise.

Note: Only available for SVG images.


bool editor/scale_with_editor_scale = false 🔗

If true, scales the imported image to match EditorSettings.interface/editor/appearance/custom_display_scale. This should be enabled for editor plugin icons and custom class icons, but should be left disabled otherwise.

Note: Only available for SVG images.


bool mipmaps/generate = false 🔗

如果true,匯入時會產生較小版本的紋理。例如,64×64 紋理將產生 6 個 mipmap(32×32、16× 16 、8×8、4×4、2×2、1×1)。這有幾個優點:

  • 紋理在遠處(3D 中)或由於 Camera2D 縮放或 CanvasItem 縮放(2D)而縮小時不會變得顆粒狀。

  • 如果紋理顯示在遠處,效能將會提高,因為對原始紋理的較小版本進行取樣速度更快並且需要更少的記憶體頻寬。

mipmap 的缺點是它們會增加約 33% 的記憶體使用量。

建議在 3D 中啟用 mipmap。但是,在 2D 中,僅當您的專案明顯受益於啟用 mipmap 時才應啟用此功能。如果相機永遠不會顯著縮小,啟用 mipmap 不會有任何好處,但記憶體使用量會增加。"


int mipmaps/limit = -1 🔗

未實作。目前變更後無效。


int process/channel_remap/alpha = 3 🔗

Specifies the data source of the output image's alpha channel.

Red: Use the values from the source image's red channel.

Green: Use the values from the source image's green channel.

Blue: Use the values from the source image's blue channel.

Alpha: Use the values from the source image's alpha channel.

Red Inverted: Use inverted values from the source image's red channel (1.0 - R).

Green Inverted: Use inverted values from the source image's green channel (1.0 - G).

Blue Inverted: Use inverted values from the source image's blue channel (1.0 - B).

Alpha Inverted: Use inverted values from the source image's alpha channel (1.0 - A).

Unused: Set the color channel's value to the default (1.0 for alpha, 0.0 for red, green or blue).

Zero: Set the color channel's value to 0.0.

One: Set the color channel's value to 1.0.


int process/channel_remap/blue = 2 🔗

Specifies the data source of the output image's blue channel.

Red: Use the values from the source image's red channel.

Green: Use the values from the source image's green channel.

Blue: Use the values from the source image's blue channel.

Alpha: Use the values from the source image's alpha channel.

Red Inverted: Use inverted values from the source image's red channel (1.0 - R).

Green Inverted: Use inverted values from the source image's green channel (1.0 - G).

Blue Inverted: Use inverted values from the source image's blue channel (1.0 - B).

Alpha Inverted: Use inverted values from the source image's alpha channel (1.0 - A).

Unused: Set the color channel's value to the default (1.0 for alpha, 0.0 for red, green or blue).

Zero: Set the color channel's value to 0.0.

One: Set the color channel's value to 1.0.


int process/channel_remap/green = 1 🔗

Specifies the data source of the output image's green channel.

Red: Use the values from the source image's red channel.

Green: Use the values from the source image's green channel.

Blue: Use the values from the source image's blue channel.

Alpha: Use the values from the source image's alpha channel.

Red Inverted: Use inverted values from the source image's red channel (1.0 - R).

Green Inverted: Use inverted values from the source image's green channel (1.0 - G).

Blue Inverted: Use inverted values from the source image's blue channel (1.0 - B).

Alpha Inverted: Use inverted values from the source image's alpha channel (1.0 - A).

Unused: Set the color channel's value to the default (1.0 for alpha, 0.0 for red, green or blue).

Zero: Set the color channel's value to 0.0.

One: Set the color channel's value to 1.0.


int process/channel_remap/red = 0 🔗

Specifies the data source of the output image's red channel.

Red: Use the values from the source image's red channel.

Green: Use the values from the source image's green channel.

Blue: Use the values from the source image's blue channel.

Alpha: Use the values from the source image's alpha channel.

Red Inverted: Use inverted values from the source image's red channel (1.0 - R).

Green Inverted: Use inverted values from the source image's green channel (1.0 - G).

Blue Inverted: Use inverted values from the source image's blue channel (1.0 - B).

Alpha Inverted: Use inverted values from the source image's alpha channel (1.0 - A).

Unused: Set the color channel's value to the default (1.0 for alpha, 0.0 for red, green or blue).

Zero: Set the color channel's value to 0.0.

One: Set the color channel's value to 1.0.


bool process/fix_alpha_border = true 🔗

If true, puts pixels of the same surrounding color in transition from transparent to opaque areas. For textures displayed with bilinear filtering, this helps to reduce the outline effect when exporting images from an image editor.

It's recommended to leave this enabled (as it is by default), unless this causes issues for a particular image.


bool process/hdr_as_srgb = false 🔗

Some HDR images you can find online may be broken and contain data that is encoded using the nonlinear sRGB transfer function (instead of using linear encoding). It is advised not to use those files. If you absolutely have to, enabling process/hdr_as_srgb will make them look correct.

Warning: Enabling process/hdr_as_srgb on well-formatted HDR images will cause the resulting image to look too dark, so leave this on false if unsure.


bool process/hdr_clamp_exposure = false 🔗

如果true,則使用智慧型夾緊公式夾緊匯入的高動態範圍影像中的曝光(不引入visible 剪切)。

您可以在網路上找到的一些 HDR 全景影像可能包含極其明亮的像素,因為這些影像取自現實生活來源,沒有任何剪輯。

雖然這些 HDR 全景影像準確反映現實生活,但這可能會導致 Godot 產生的輻射圖在用作背景天空時包含閃光。這可以在材料反射中看到(即使在極端情況下在粗糙材料上)。啟用process/hdr_clamp_exposure可以解決此問題。


bool process/normal_map_invert_y = false 🔗

已棄用: The same result can be achieved by setting process/channel_remap/green to Green Inverted.

如果 true,則透過反轉其綠色通道將法線貼圖從 Y-(DirectX 樣式)轉換為 Y+(OpenGL 樣式)。這是Godot所期望的法線貼圖約定。

此處找到。


bool process/premult_alpha = false 🔗

An alternative to fixing darkened borders with process/fix_alpha_border is to use premultiplied alpha. By enabling this option, the texture will be converted to this format. A premultiplied alpha texture requires specific materials to be displayed correctly:


int process/size_limit = 0 🔗

If set to a value greater than 0, the size of the texture is limited on import to a value smaller than or equal to the value specified here. For non-square textures, the size limit affects the longer dimension, with the shorter dimension scaled to preserve aspect ratio. Resizing is performed using cubic interpolation.

This can be used to reduce memory usage without affecting the source images, or avoid issues with textures not displaying on mobile/web platforms (as these usually can't display textures larger than 4096×4096).

Note: Even if this is set to 0, import size is limited to the following dimensions for technical reasons. Depending on compress/mode, textures will be downsampled on import if necessary:

  • Lossy: 16383 pixels width or height, whichever is larger;

  • Basis Universal: 16384 pixels width or height, whichever is larger;

  • All other modes: 32768 pixels width or height, whichever is larger.


int roughness/mode = 0 🔗

The color channel to consider as a roughness map in this texture. Only effective if roughness/src_normal is not empty.


String roughness/src_normal = "" 🔗

匯入時考慮作為粗糙度篩選法線貼圖的紋理路徑。指定此專案可以幫助稍微減少 3D 中的鏡面鋸齒。

匯入時的粗糙度篩選僅用於 3D 算繪,不適用於 2D。


float svg/scale = 1.0 🔗

SVG 應該算繪的比例,1.0 是原始設計尺寸。較高的值會導致較大的圖像。請注意,與字形過取樣不同,此影響 SVG 在 2D 中算繪的大小。另請參閱 editor/scale_with_editor_scale

注意: 僅適用於 SVG 影像。