You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-08 12:40:44 +00:00
Add support for generating noise images with an offset.
(cherry picked from commit 97c8d9f348)
This commit is contained in:
committed by
Rémi Verschelde
parent
68f92e6785
commit
ecf8d99d37
@@ -62,6 +62,9 @@ void NoiseTexture::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("set_noise", "noise"), &NoiseTexture::set_noise);
|
||||
ClassDB::bind_method(D_METHOD("get_noise"), &NoiseTexture::get_noise);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_noise_offset", "noise_offset"), &NoiseTexture::set_noise_offset);
|
||||
ClassDB::bind_method(D_METHOD("get_noise_offset"), &NoiseTexture::get_noise_offset);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_seamless", "seamless"), &NoiseTexture::set_seamless);
|
||||
ClassDB::bind_method(D_METHOD("get_seamless"), &NoiseTexture::get_seamless);
|
||||
|
||||
@@ -82,6 +85,7 @@ void NoiseTexture::_bind_methods() {
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "as_normalmap"), "set_as_normalmap", "is_normalmap");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "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");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "noise_offset"), "set_noise_offset", "get_noise_offset");
|
||||
}
|
||||
|
||||
void NoiseTexture::_validate_property(PropertyInfo &property) const {
|
||||
@@ -137,7 +141,7 @@ Ref<Image> NoiseTexture::_generate_texture() {
|
||||
if (seamless) {
|
||||
image = ref_noise->get_seamless_image(size.x);
|
||||
} else {
|
||||
image = ref_noise->get_image(size.x, size.y);
|
||||
image = ref_noise->get_image(size.x, size.y, noise_offset);
|
||||
}
|
||||
|
||||
if (as_normalmap) {
|
||||
@@ -205,6 +209,14 @@ void NoiseTexture::set_height(int p_height) {
|
||||
_queue_update();
|
||||
}
|
||||
|
||||
void NoiseTexture::set_noise_offset(Vector2 p_noise_offset) {
|
||||
if (noise_offset == p_noise_offset) {
|
||||
return;
|
||||
}
|
||||
noise_offset = p_noise_offset;
|
||||
_queue_update();
|
||||
}
|
||||
|
||||
void NoiseTexture::set_seamless(bool p_seamless) {
|
||||
if (p_seamless == seamless) {
|
||||
return;
|
||||
@@ -252,6 +264,10 @@ int NoiseTexture::get_height() const {
|
||||
return size.y;
|
||||
}
|
||||
|
||||
Vector2 NoiseTexture::get_noise_offset() const {
|
||||
return noise_offset;
|
||||
}
|
||||
|
||||
void NoiseTexture::set_flags(uint32_t p_flags) {
|
||||
flags = p_flags;
|
||||
VS::get_singleton()->texture_set_flags(texture, flags);
|
||||
|
||||
Reference in New Issue
Block a user