Skip to content

Commit 19c4d73

Browse files
Adding example NoiseTexture usage, as an example
Set the use_noise_texture flag to true to use it instead.
1 parent 27727fd commit 19c4d73

File tree

3 files changed

+20
-5
lines changed

3 files changed

+20
-5
lines changed
20.8 KB
Binary file not shown.

misc/opensimplexnoise/OpenSimplexNoise_Viewer.gd

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
11
extends Control
22

3+
#The OpenSimplexNoise object
34
var noise = OpenSimplexNoise.new()
5+
var noise_texture = NoiseTexture.new()
46

7+
#Various noise parameters
58
var noise_size = 500
69
var min_noise = -1
710
var max_noise = 1
811

12+
#Are we using a NoiseTexture instead?
13+
#Noise textures automatically grab and apply the noise data to an ImageTexture, instead of manually
14+
const use_noise_texture = false
15+
916
# Called when the node enters the scene tree for the first time.
1017
func _ready():
1118

@@ -19,20 +26,29 @@ func _ready():
1926
#Render the noise
2027
_refresh_noise_images()
2128

29+
#Do we need to set up a noise texture?
30+
if use_noise_texture:
31+
noise_texture.noise = noise
32+
$SeamlessNoiseTexture.texture = noise_texture
33+
2234

2335
func _refresh_noise_images():
2436

25-
#Get a new image
26-
var image = noise.get_seamless_image(500)
27-
var image_texture = ImageTexture.new()
28-
2937
#Adjust min/max for shader
3038
var _min = ((min_noise + 1)/2)
3139
var _max = ((max_noise + 1)/2)
3240
var _material = $SeamlessNoiseTexture.material
3341
_material.set_shader_param("min_value", _min)
3442
_material.set_shader_param("max_value", _max)
3543

44+
#Are we using noise textures instead?
45+
if use_noise_texture:
46+
return
47+
48+
#Get a new image if we aren't using a NoiseTexture
49+
var image = noise.get_seamless_image(500)
50+
var image_texture = ImageTexture.new()
51+
3652
#Draw it
3753
image_texture.create_from_image(image)
3854
$SeamlessNoiseTexture.texture = image_texture

misc/opensimplexnoise/project.godot

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,3 @@ config/icon="res://icon.png"
2424
quality/driver/driver_name="GLES2"
2525
vram_compression/import_etc=true
2626
vram_compression/import_etc2=false
27-
environment/default_environment="res://default_env.tres"

0 commit comments

Comments
 (0)