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.

NoiseTexture2D

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

Noise 物件生成的雜訊所填充的紋理。

說明

使用 FastNoiseLite 或其他庫來填充所需大小的紋理資料。NoiseTexture2D 還能生成法線貼圖紋理。

該類在內部使用 Thread 生成紋理資料,因此如果生成過程尚未完成,Texture2D.get_image() 可能會返回 null。在這種情況下,需要等待紋理生成後再存取圖像和生成的位元組資料:

var texture = NoiseTexture2D.new()
texture.noise = FastNoiseLite.new()
await texture.changed
var image = texture.get_image()
var data = image.get_data()

屬性

bool

as_normal_map

false

float

bump_strength

8.0

Gradient

color_ramp

bool

generate_mipmaps

true

int

height

512

bool

in_3d_space

false

bool

invert

false

Noise

noise

bool

normalize

true

bool

resource_local_to_scene

false (overrides Resource)

bool

seamless

false

float

seamless_blend_skirt

0.1

int

width

512


屬性說明

bool as_normal_map = false 🔗

  • void set_as_normal_map(value: bool)

  • bool is_normal_map()

如果為 true,產生的紋理包含一個由原始雜訊建立的法線貼圖,解釋為凹凸貼圖。


float bump_strength = 8.0 🔗

  • void set_bump_strength(value: float)

  • float get_bump_strength()

該紋理中使用的凹凸貼圖的強度。更高的值會使凹凸貼圖看起來更大,而更低的值會使它們看起來更柔和。


Gradient color_ramp 🔗

Gradient,用於將每個圖元的亮度對應到一個顏色值。


bool generate_mipmaps = true 🔗

  • void set_generate_mipmaps(value: bool)

  • bool is_generating_mipmaps()

決定是否為該紋理生成 mipmap。啟用該屬性可減少紋理鋸齒,但會增加約 33% 的記憶體佔用,生成雜訊紋理也可能需要更長的時間。

注意:使用該 NoiseTexture2D 的材質需要啟用 mipmap 篩選才能讓 generate_mipmaps 生效。


int height = 512 🔗

  • void set_height(value: int)

  • int get_height()

生成的紋理的高度(單位為圖元)。


bool in_3d_space = false 🔗

  • void set_in_3d_space(value: bool)

  • bool is_in_3d_space()

決定是否在 3D 空間中計算雜訊圖像。可能會導致對比度降低。


bool invert = false 🔗

  • void set_invert(value: bool)

  • bool get_invert()

如果為 true,則反轉該雜訊紋理。白變黑,黑變白。


Noise noise 🔗

Noise 物件的實例。


bool normalize = true 🔗

  • void set_normalize(value: bool)

  • bool is_normalized()

如果為 true,來自雜訊產生器的雜訊圖像,將被正規化到範圍 0.01.0

關閉正規化會影響對比度,並允許生成非重複的可平鋪雜訊紋理。


bool seamless = false 🔗

  • void set_seamless(value: bool)

  • bool get_seamless()

如果為 true,則從 Noise 資源請求無縫紋理。

注意:與非無縫雜訊相比,無縫雜訊紋理可能需要更長的時間來生成,並且/或者可能具有較低的對比度,具體取決於所使用的 Noise 資源。這是因為一些實作使用更高的維度來生成無縫雜訊。

注意:預設的 FastNoiseLite 實作在生成無縫紋理時使用退回路徑。如果使用的 widthheight 小於預設值,你可能需要通過增大 seamless_blend_skirt 來讓無縫混合更高效。


float seamless_blend_skirt = 0.1 🔗

  • void set_seamless_blend_skirt(value: float)

  • float get_seamless_blend_skirt()

用於無縫紋理生成的預設/退回實作。它決定接縫混合的距離。較高的值可能會導致較少的細節和對比度。詳情見 Noise

注意:如果使用的 widthheight 小於預設值,你可能需要通過增大 seamless_blend_skirt 來讓無縫混合更高效。


int width = 512 🔗

  • void set_width(value: int)

  • int get_width()

生成的紋理的寬度(單位為圖元)。