Skip to content

Commit 729be34

Browse files
committed
Style fixes for open simplex noise demo
1 parent abf9d68 commit 729be34

File tree

2 files changed

+18
-36
lines changed

2 files changed

+18
-36
lines changed
Lines changed: 12 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,108 +1,91 @@
11
extends Control
22

3-
#The OpenSimplexNoise object
3+
# The OpenSimplexNoise object.
44
var noise = OpenSimplexNoise.new()
55
var noise_texture = NoiseTexture.new()
66

7-
#Various noise parameters
8-
var noise_size = 500
7+
# Various noise parameters.
98
var min_noise = -1
109
var max_noise = 1
1110

12-
#Are we using a NoiseTexture instead?
13-
#Noise textures automatically grab and apply the noise data to an ImageTexture, instead of manually
11+
# Are we using a NoiseTexture instead?
12+
# Noise textures automatically grab and apply the noise data to an ImageTexture, instead of manually.
1413
const use_noise_texture = false
1514

1615
# Called when the node enters the scene tree for the first time.
1716
func _ready():
18-
19-
#Set up noise with basic info
17+
# Set up noise with basic info.
2018
$ParameterContainer/SeedSpinBox.value = noise.seed
2119
$ParameterContainer/LacunaritySpinBox.value = noise.lacunarity
2220
$ParameterContainer/OctavesSpinBox.value = noise.octaves
2321
$ParameterContainer/PeriodSpinBox.value = noise.period
2422
$ParameterContainer/PersistenceSpinBox.value = noise.persistence
2523

26-
#Render the noise
24+
# Render the noise.
2725
_refresh_noise_images()
2826

29-
#Do we need to set up a noise texture?
27+
# Do we need to set up a noise texture?
3028
if use_noise_texture:
3129
noise_texture.noise = noise
3230
$SeamlessNoiseTexture.texture = noise_texture
3331

3432

3533
func _refresh_noise_images():
36-
37-
#Adjust min/max for shader
34+
# Adjust min/max for shader.
3835
var _min = ((min_noise + 1)/2)
3936
var _max = ((max_noise + 1)/2)
4037
var _material = $SeamlessNoiseTexture.material
4138
_material.set_shader_param("min_value", _min)
4239
_material.set_shader_param("max_value", _max)
4340

44-
#Are we using noise textures instead?
41+
# Are we using noise textures instead?
4542
if use_noise_texture:
4643
return
4744

48-
#Get a new image if we aren't using a NoiseTexture
45+
# Get a new image if we aren't using a NoiseTexture.
4946
var image = noise.get_seamless_image(500)
5047
var image_texture = ImageTexture.new()
5148

52-
#Draw it
49+
# Draw it.
5350
image_texture.create_from_image(image)
5451
$SeamlessNoiseTexture.texture = image_texture
5552

5653

5754
func _on_DocumentationButton_pressed():
55+
#warning-ignore:return_value_discarded
5856
OS.shell_open("https://docs.godotengine.org/en/latest/classes/class_opensimplexnoise.html")
5957

6058

6159
func _on_SeedSpinBox_value_changed(value):
62-
63-
#Update the noise seed
6460
noise.seed = value
6561
_refresh_noise_images()
6662

6763

6864
func _on_LacunaritySpinBox_value_changed(value):
69-
70-
#Update noise
7165
noise.lacunarity = value
7266
_refresh_noise_images()
7367

7468

7569
func _on_OctavesSpinBox_value_changed(value):
76-
77-
#Update noise
7870
noise.octaves = value
7971
_refresh_noise_images()
8072

8173

8274
func _on_PeriodSpinBox_value_changed(value):
83-
84-
#Update noise
8575
noise.period = value
8676
_refresh_noise_images()
8777

8878

8979
func _on_PersistenceSpinBox_value_changed(value):
90-
91-
#Update noise
9280
noise.persistence = value
9381
_refresh_noise_images()
9482

9583

9684
func _on_MinClipSpinBox_value_changed(value):
97-
98-
#Just refresh
9985
min_noise = value
10086
_refresh_noise_images()
10187

10288

10389
func _on_MaxClipSpinBox_value_changed(value):
104-
105-
#Just refresh
10690
max_noise = value
10791
_refresh_noise_images()
108-

misc/opensimplexnoise/OpenSimplexNoise_Viewer.shader

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,17 @@ uniform float min_value = -1;
44
uniform float max_value = 1;
55

66
void fragment() {
7-
8-
//Get the color
7+
// Get the color.
98
vec4 color = texture(TEXTURE, UV);
109

11-
//Compare the value
10+
// Compare the value.
1211
float gray = color.x;
13-
if (gray < min_value){
12+
if (gray < min_value) {
1413
color = vec4(0, 0, 0, 1);
15-
}else if (gray > max_value) {
14+
} else if (gray > max_value) {
1615
color = vec4(1, 1, 1, 1);
1716
}
1817

19-
//Write back the color
18+
// Write back the color.
2019
COLOR = color;
21-
}
20+
}

0 commit comments

Comments
 (0)