NoiseTexture2D

package
v0.0.0-...-357ca8a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 20, 2025 License: MIT Imports: 28 Imported by: 0

Documentation

Overview

Uses the FastNoiseLite library or other noise generators to fill the texture data of your desired size. NoiseTexture2D can also generate normal map textures.

The class uses Threads to generate the texture data internally, so Texture2D.GetImage may return null if the generation process has not completed yet. In that case, you need to wait for the texture to be generated before accessing the image and the generated byte data:

package main

import (
	"graphics.gd/classdb/FastNoiseLite"
	"graphics.gd/classdb/NoiseTexture2D"
)

func ExampleNoiseTexture2D() {
	var texture = NoiseTexture2D.New()
	texture.SetNoise(FastNoiseLite.New().AsNoise())
	texture.AsResource().OnChanged(func() {
		var image = texture.AsTexture2D().GetImage()
		var data = image.GetData()
		_ = data
	})
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Advanced

type Advanced = class

Advanced exposes a 1:1 low-level instance of the class, undocumented, for those who know what they are doing.

type Any

type Any interface {
	gd.IsClass
	AsNoiseTexture2D() Instance
}

type Extension

type Extension[T gdclass.Interface] struct{ gdclass.Extension[T, Instance] }

Extension can be embedded in a new struct to create an extension of this class. T should be the type that is embedding this Extension

func (*Extension[T]) AsNoiseTexture2D

func (self *Extension[T]) AsNoiseTexture2D() Instance

func (*Extension[T]) AsObject

func (self *Extension[T]) AsObject() [1]gd.Object

func (*Extension[T]) AsRefCounted

func (self *Extension[T]) AsRefCounted() [1]gd.RefCounted

func (*Extension[T]) AsResource

func (self *Extension[T]) AsResource() Resource.Instance

func (*Extension[T]) AsTexture

func (self *Extension[T]) AsTexture() Texture.Instance

func (*Extension[T]) AsTexture2D

func (self *Extension[T]) AsTexture2D() Texture2D.Instance

type ID

type ID Object.ID

ID is a typed object ID (reference) to an instance of this class, use it to store references to objects with unknown lifetimes, as an ID will not panic on use if the underlying object has been destroyed.

func (ID) Instance

func (id ID) Instance() (Instance, bool)

type Instance

type Instance [1]gdclass.NoiseTexture2D

Instance of the class with convieniently typed arguments and results.

var Nil Instance

Nil is a nil/null instance of the class. Equivalent to the zero value.

func New

func New() Instance

func (Instance) AsNoiseTexture2D

func (self Instance) AsNoiseTexture2D() Instance

func (Instance) AsNormalMap

func (self Instance) AsNormalMap() bool

If true, the resulting texture contains a normal map created from the original noise interpreted as a bump map.

func (Instance) AsObject

func (self Instance) AsObject() [1]gd.Object

func (Instance) AsRefCounted

func (self Instance) AsRefCounted() [1]gd.RefCounted

func (Instance) AsResource

func (self Instance) AsResource() Resource.Instance

func (Instance) AsTexture

func (self Instance) AsTexture() Texture.Instance

func (Instance) AsTexture2D

func (self Instance) AsTexture2D() Texture2D.Instance

func (Instance) BumpStrength

func (self Instance) BumpStrength() Float.X

Strength of the bump maps used in this texture. A higher value will make the bump maps appear larger while a lower value will make them appear softer.

func (Instance) ColorRamp

func (self Instance) ColorRamp() Gradient.Instance

A Gradient which is used to map the luminance of each pixel to a color value.

func (Instance) GenerateMipmaps

func (self Instance) GenerateMipmaps() bool

Determines whether mipmaps are generated for this texture. Enabling this results in less texture aliasing in the distance, at the cost of increasing memory usage by roughly 33% and making the noise texture generation take longer.

Note: GenerateMipmaps requires mipmap filtering to be enabled on the material using the NoiseTexture2D to have an effect.

func (Instance) ID

func (self Instance) ID() ID

func (Instance) In3dSpace

func (self Instance) In3dSpace() bool

Determines whether the noise image is calculated in 3D space. May result in reduced contrast.

func (Instance) Invert

func (self Instance) Invert() bool

If true, inverts the noise texture. White becomes black, black becomes white.

func (Instance) Noise

func (self Instance) Noise() Noise.Instance

The instance of the Noise object.

func (Instance) Normalize

func (self Instance) Normalize() bool

If true, the noise image coming from the noise generator is normalized to the range 0.0 to 1.0.

Turning normalization off can affect the contrast and allows you to generate non repeating tileable noise textures.

func (Instance) Seamless

func (self Instance) Seamless() bool

If true, a seamless texture is requested from the Noise resource.

Note: Seamless noise textures may take longer to generate and/or can have a lower contrast compared to non-seamless noise depending on the used Noise resource. This is because some implementations use higher dimensions for generating seamless noise.

Note: The default FastNoiseLite implementation uses the fallback path for seamless generation. If using a Width or Height lower than the default, you may need to increase SeamlessBlendSkirt to make seamless blending more effective.

func (Instance) SeamlessBlendSkirt

func (self Instance) SeamlessBlendSkirt() Float.X

Used for the default/fallback implementation of the seamless texture generation. It determines the distance over which the seams are blended. High values may result in less details and contrast. See Noise for further details.

Note: If using a Width or Height lower than the default, you may need to increase SeamlessBlendSkirt to make seamless blending more effective.

func (Instance) SetAsNormalMap

func (self Instance) SetAsNormalMap(value bool)

SetAsNormalMap sets the property returned by [IsNormalMap].

func (Instance) SetBumpStrength

func (self Instance) SetBumpStrength(value Float.X)

SetBumpStrength sets the property returned by [GetBumpStrength].

func (Instance) SetColorRamp

func (self Instance) SetColorRamp(value Gradient.Instance)

SetColorRamp sets the property returned by [GetColorRamp].

func (Instance) SetGenerateMipmaps

func (self Instance) SetGenerateMipmaps(value bool)

SetGenerateMipmaps sets the property returned by [IsGeneratingMipmaps].

func (Instance) SetHeight

func (self Instance) SetHeight(value int)

Height of the generated texture (in pixels).

func (Instance) SetIn3dSpace

func (self Instance) SetIn3dSpace(value bool)

SetIn3dSpace sets the property returned by [IsIn3dSpace].

func (Instance) SetInvert

func (self Instance) SetInvert(value bool)

SetInvert sets the property returned by [GetInvert].

func (Instance) SetNoise

func (self Instance) SetNoise(value Noise.Instance)

SetNoise sets the property returned by [GetNoise].

func (Instance) SetNormalize

func (self Instance) SetNormalize(value bool)

SetNormalize sets the property returned by [IsNormalized].

func (*Instance) SetObject

func (self *Instance) SetObject(obj [1]gd.Object) bool

func (Instance) SetSeamless

func (self Instance) SetSeamless(value bool)

SetSeamless sets the property returned by [GetSeamless].

func (Instance) SetSeamlessBlendSkirt

func (self Instance) SetSeamlessBlendSkirt(value Float.X)

SetSeamlessBlendSkirt sets the property returned by [GetSeamlessBlendSkirt].

func (Instance) SetWidth

func (self Instance) SetWidth(value int)

Width of the generated texture (in pixels).

func (Instance) Virtual

func (self Instance) Virtual(name string) reflect.Value

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL