Is get_noise_2d accessing values out of range?

Godot Version

v4.2.1.stable.official [b09f793f5]

Question

In my project there’s a sprite that is meant to move erratically. I’m basing its position on a noise resource: I get the values from the noise texture and apply those to the sprite’s coordinates. This works great but… I’m accessing the coordinates from the noise resource that are bigger than the dimensions of the noise resource. So this shouldn’t work?

Here is the code I’m using to move the sprite:

extends Sprite2D

@export var NoiseSource: NoiseTexture2D
@onready var NoiseValue = NoiseSource.noise

func _process(delta):
	var T # time
	T = Time.get_ticks_msec()*0.01
	position.x = 256+ NoiseValue.get_noise_2d(128, T)*128

and here is the noise resource:
image
So I’d expect that when the T goes over 64, it’ll throw an error. But it doesn’t, and it works great! What exactly is happening here, does get_noise_2d have automatic wrapping built in?

One thing is a NoiseTexture2D and another thing is a Noise Resource. They are different. A NoiseTexture2D is the visual representation of the noise in a specific area. A Noise resource generates the noise and it has no limits.

If you aren’t using the texture itself for rendering or in a shader it’s better to use the Noise resource directly so no extra data is generated (the texture). @export var noiseValue:Noise

Thank you!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.