diff --git a/modules/opensimplex/doc_classes/OpenSimplexNoise.xml b/modules/opensimplex/doc_classes/OpenSimplexNoise.xml
index c87fb77a23b..286c62289ec 100644
--- a/modules/opensimplex/doc_classes/OpenSimplexNoise.xml
+++ b/modules/opensimplex/doc_classes/OpenSimplexNoise.xml
@@ -32,7 +32,7 @@
- Generate a noise image with the requested [code]width[/code] and [code]height[/code], based on the current noise parameters.
+ Generate a noise image in [constant Image.FORMAT_L8] format with the requested [code]width[/code] and [code]height[/code], based on the current noise parameters.
@@ -108,7 +108,7 @@
- Generate a tileable noise image, based on the current noise parameters. Generated seamless images are always square ([code]size[/code] × [code]size[/code]).
+ Generate a tileable noise image in [constant Image.FORMAT_L8] format, based on the current noise parameters. Generated seamless images are always square ([code]size[/code] × [code]size[/code]).
diff --git a/modules/opensimplex/noise_texture.cpp b/modules/opensimplex/noise_texture.cpp
index 98dbbf7289c..00caa43caaf 100644
--- a/modules/opensimplex/noise_texture.cpp
+++ b/modules/opensimplex/noise_texture.cpp
@@ -101,7 +101,7 @@ void NoiseTexture::_validate_property(PropertyInfo &property) const {
void NoiseTexture::_set_texture_data(const Ref &p_image) {
data = p_image;
if (data.is_valid()) {
- VS::get_singleton()->texture_allocate(texture, size.x, size.y, 0, Image::FORMAT_RGBA8, VS::TEXTURE_TYPE_2D, flags);
+ VS::get_singleton()->texture_allocate(texture, size.x, size.y, 0, p_image->get_format(), VS::TEXTURE_TYPE_2D, flags);
VS::get_singleton()->texture_set_data(texture, p_image);
}
emit_changed();
diff --git a/modules/opensimplex/open_simplex_noise.cpp b/modules/opensimplex/open_simplex_noise.cpp
index ba0655b332a..6bb996098df 100644
--- a/modules/opensimplex/open_simplex_noise.cpp
+++ b/modules/opensimplex/open_simplex_noise.cpp
@@ -99,7 +99,7 @@ void OpenSimplexNoise::set_lacunarity(float p_lacunarity) {
Ref OpenSimplexNoise::get_image(int p_width, int p_height) const {
PoolVector data;
- data.resize(p_width * p_height * 4);
+ data.resize(p_width * p_height);
PoolVector::Write wd8 = data.write();
@@ -107,22 +107,18 @@ Ref OpenSimplexNoise::get_image(int p_width, int p_height) const {
for (int j = 0; j < p_width; j++) {
float v = get_noise_2d(i, j);
v = v * 0.5 + 0.5; // Normalize [0..1]
- uint8_t value = uint8_t(CLAMP(v * 255.0, 0, 255));
- wd8[(i * p_width + j) * 4 + 0] = value;
- wd8[(i * p_width + j) * 4 + 1] = value;
- wd8[(i * p_width + j) * 4 + 2] = value;
- wd8[(i * p_width + j) * 4 + 3] = 255;
+ wd8[(i * p_width + j)] = uint8_t(CLAMP(v * 255.0, 0, 255));
}
}
- Ref image = memnew(Image(p_width, p_height, false, Image::FORMAT_RGBA8, data));
+ Ref image = memnew(Image(p_width, p_height, false, Image::FORMAT_L8, data));
return image;
}
Ref OpenSimplexNoise::get_seamless_image(int p_size) const {
PoolVector data;
- data.resize(p_size * p_size * 4);
+ data.resize(p_size * p_size);
PoolVector::Write wd8 = data.write();
@@ -144,15 +140,11 @@ Ref OpenSimplexNoise::get_seamless_image(int p_size) const {
float v = get_noise_4d(x, y, z, w);
v = v * 0.5 + 0.5; // Normalize [0..1]
- uint8_t value = uint8_t(CLAMP(v * 255.0, 0, 255));
- wd8[(i * p_size + j) * 4 + 0] = value;
- wd8[(i * p_size + j) * 4 + 1] = value;
- wd8[(i * p_size + j) * 4 + 2] = value;
- wd8[(i * p_size + j) * 4 + 3] = 255;
+ wd8[(i * p_size + j)] = uint8_t(CLAMP(v * 255.0, 0, 255));
}
}
- Ref image = memnew(Image(p_size, p_size, false, Image::FORMAT_RGBA8, data));
+ Ref image = memnew(Image(p_size, p_size, false, Image::FORMAT_L8, data));
return image;
}