diff options
Diffstat (limited to 'modules/opensimplex')
-rw-r--r-- | modules/opensimplex/doc_classes/NoiseTexture.xml | 4 | ||||
-rw-r--r-- | modules/opensimplex/noise_texture.cpp | 26 | ||||
-rw-r--r-- | modules/opensimplex/noise_texture.h | 6 |
3 files changed, 18 insertions, 18 deletions
diff --git a/modules/opensimplex/doc_classes/NoiseTexture.xml b/modules/opensimplex/doc_classes/NoiseTexture.xml index c06f3096de..7df261d2ba 100644 --- a/modules/opensimplex/doc_classes/NoiseTexture.xml +++ b/modules/opensimplex/doc_classes/NoiseTexture.xml @@ -5,7 +5,7 @@ </brief_description> <description> Uses an [OpenSimplexNoise] to fill the texture data. You can specify the texture size but keep in mind that larger textures will take longer to generate and seamless noise only works with square sized textures. - NoiseTexture can also generate normalmap textures. + NoiseTexture can also generate normal map textures. The class uses [Thread]s to generate the texture data internally, so [method Texture2D.get_data] may return [code]null[/code] if the generation process has not completed yet. In that case, you need to wait for the texture to be generated before accessing the data: [codeblock] var texture = preload("res://noise.tres") @@ -18,7 +18,7 @@ <methods> </methods> <members> - <member name="as_normalmap" type="bool" setter="set_as_normalmap" getter="is_normalmap" default="false"> + <member name="as_normal_map" type="bool" setter="set_as_normal_map" getter="is_normal_map" default="false"> If [code]true[/code], the resulting texture contains a normal map created from the original noise interpreted as a bump map. </member> <member name="bump_strength" type="float" setter="set_bump_strength" getter="get_bump_strength" default="8.0"> diff --git a/modules/opensimplex/noise_texture.cpp b/modules/opensimplex/noise_texture.cpp index 1181e69cd3..b29c2f84ce 100644 --- a/modules/opensimplex/noise_texture.cpp +++ b/modules/opensimplex/noise_texture.cpp @@ -40,7 +40,7 @@ NoiseTexture::NoiseTexture() { size = Vector2i(512, 512); seamless = false; - as_normalmap = false; + as_normal_map = false; bump_strength = 8.0; noise = Ref<OpenSimplexNoise>(); @@ -68,8 +68,8 @@ void NoiseTexture::_bind_methods() { ClassDB::bind_method(D_METHOD("set_seamless", "seamless"), &NoiseTexture::set_seamless); ClassDB::bind_method(D_METHOD("get_seamless"), &NoiseTexture::get_seamless); - ClassDB::bind_method(D_METHOD("set_as_normalmap", "as_normalmap"), &NoiseTexture::set_as_normalmap); - ClassDB::bind_method(D_METHOD("is_normalmap"), &NoiseTexture::is_normalmap); + ClassDB::bind_method(D_METHOD("set_as_normal_map", "as_normal_map"), &NoiseTexture::set_as_normal_map); + ClassDB::bind_method(D_METHOD("is_normal_map"), &NoiseTexture::is_normal_map); ClassDB::bind_method(D_METHOD("set_bump_strength", "bump_strength"), &NoiseTexture::set_bump_strength); ClassDB::bind_method(D_METHOD("get_bump_strength"), &NoiseTexture::get_bump_strength); @@ -81,14 +81,14 @@ void NoiseTexture::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::INT, "width", PROPERTY_HINT_RANGE, "1,2048,1,or_greater"), "set_width", "get_width"); ADD_PROPERTY(PropertyInfo(Variant::INT, "height", PROPERTY_HINT_RANGE, "1,2048,1,or_greater"), "set_height", "get_height"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "seamless"), "set_seamless", "get_seamless"); - ADD_PROPERTY(PropertyInfo(Variant::BOOL, "as_normalmap"), "set_as_normalmap", "is_normalmap"); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "as_normal_map"), "set_as_normal_map", "is_normal_map"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "bump_strength", PROPERTY_HINT_RANGE, "0,32,0.1,or_greater"), "set_bump_strength", "get_bump_strength"); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "noise", PROPERTY_HINT_RESOURCE_TYPE, "OpenSimplexNoise"), "set_noise", "get_noise"); } void NoiseTexture::_validate_property(PropertyInfo &property) const { if (property.name == "bump_strength") { - if (!as_normalmap) { + if (!as_normal_map) { property.usage = PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL; } } @@ -148,8 +148,8 @@ Ref<Image> NoiseTexture::_generate_texture() { image = ref_noise->get_image(size.x, size.y); } - if (as_normalmap) { - image->bumpmap_to_normalmap(bump_strength); + if (as_normal_map) { + image->bump_map_to_normal_map(bump_strength); } return image; @@ -225,17 +225,17 @@ bool NoiseTexture::get_seamless() { return seamless; } -void NoiseTexture::set_as_normalmap(bool p_as_normalmap) { - if (p_as_normalmap == as_normalmap) { +void NoiseTexture::set_as_normal_map(bool p_as_normal_map) { + if (p_as_normal_map == as_normal_map) { return; } - as_normalmap = p_as_normalmap; + as_normal_map = p_as_normal_map; _queue_update(); _change_notify(); } -bool NoiseTexture::is_normalmap() { - return as_normalmap; +bool NoiseTexture::is_normal_map() { + return as_normal_map; } void NoiseTexture::set_bump_strength(float p_bump_strength) { @@ -243,7 +243,7 @@ void NoiseTexture::set_bump_strength(float p_bump_strength) { return; } bump_strength = p_bump_strength; - if (as_normalmap) { + if (as_normal_map) { _queue_update(); } } diff --git a/modules/opensimplex/noise_texture.h b/modules/opensimplex/noise_texture.h index 73960ba85f..6f0d4aa5e1 100644 --- a/modules/opensimplex/noise_texture.h +++ b/modules/opensimplex/noise_texture.h @@ -57,7 +57,7 @@ private: Ref<OpenSimplexNoise> noise; Vector2i size; bool seamless; - bool as_normalmap; + bool as_normal_map; float bump_strength; void _thread_done(const Ref<Image> &p_image); @@ -82,8 +82,8 @@ public: void set_seamless(bool p_seamless); bool get_seamless(); - void set_as_normalmap(bool p_as_normalmap); - bool is_normalmap(); + void set_as_normal_map(bool p_as_normal_map); + bool is_normal_map(); void set_bump_strength(float p_bump_strength); float get_bump_strength(); |