You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-15 13:51:40 +00:00
Consistently use normal_map
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user