Up to date

This page is up to date for Godot 4.2. If you still find outdated information, please open an issue.

NoiseTexture3D

继承: Texture3D < Texture < Resource < RefCounted < Object

Noise 对象生成的噪声所填充的 3D 纹理。

描述

使用 FastNoiseLite 库或其他噪声生成器来填充所需大小的纹理数据。

该类在内部使用 Thread 生成纹理数据,因此如果生成过程尚未完成,Texture3D.get_data 可能会返回 null。在这种情况下,需要等待纹理生成后再访问图像:

var texture = NoiseTexture3D.new()
texture.noise = FastNoiseLite.new()
await texture.changed
var data = texture.get_data()

属性

Gradient

color_ramp

int

depth

64

int

height

64

bool

invert

false

Noise

noise

bool

normalize

true

bool

seamless

false

float

seamless_blend_skirt

0.1

int

width

64


属性说明

Gradient color_ramp

Gradient,用于将每个像素的亮度映射到一个颜色值。


int depth = 64

  • void set_depth ( int value )

  • int get_depth ( )

生成的纹理的深度(单位为像素)。


int height = 64

  • void set_height ( int value )

  • int get_height ( )

生成的纹理的高度(单位为像素)。


bool invert = false

  • void set_invert ( bool value )

  • bool get_invert ( )

如果为 true,则反转该噪声纹理。白变黑,黑变白。


Noise noise

  • void set_noise ( Noise value )

  • Noise get_noise ( )

Noise 对象的实例。


bool normalize = true

  • void set_normalize ( bool value )

  • bool is_normalized ( )

如果为 true,来自噪声发生器的噪声图像,将被归一化到范围 0.01.0

关闭归一化会影响对比度,并允许生成非重复的可平铺噪声纹理。


bool seamless = false

  • void set_seamless ( bool value )

  • bool get_seamless ( )

如果为 true,则从 Noise 资源请求无缝纹理。

注意:与非无缝噪声相比,无缝噪声纹理可能需要更长的时间来生成,并且/或者可能具有较低的对比度,具体取决于所使用的 Noise 资源。这是因为一些实现使用更高的维度来生成无缝噪声。

注意:默认的 FastNoiseLite 实现在生成无缝纹理时使用回退路径。如果使用的 widthheightdepth 小于默认值,你可能需要通过增大 seamless_blend_skirt 来让无缝混合更高效。


float seamless_blend_skirt = 0.1

  • void set_seamless_blend_skirt ( float value )

  • float get_seamless_blend_skirt ( )

用于无缝纹理生成的默认/回退实现。它决定接缝混合的距离。较高的值可能会导致较少的细节和对比度。详情见 Noise

注意:如果使用的 widthheightdepth 小于默认值,你可能需要通过增大 seamless_blend_skirt 来让无缝混合更高效。


int width = 64

  • void set_width ( int value )

  • int get_width ( )

生成的纹理的宽度(单位为像素)。