Rename GradientTexture to GradientTexture1D

1. Explicit and unambiguous when comparing to `GradientTexture2D`
2. Consistent with other class names where 1D is used in the engine.
This commit is contained in:
Andrii Doroshenko (Xrayez) 2021-11-07 14:35:45 +02:00
parent 9f46ce8652
commit 6742a338a8
13 changed files with 36 additions and 35 deletions

View file

@ -126,7 +126,7 @@
Each particle's initial color. To have particle display color in a [BaseMaterial3D] make sure to set [member BaseMaterial3D.vertex_color_use_as_albedo] to [code]true[/code]. Each particle's initial color. To have particle display color in a [BaseMaterial3D] make sure to set [member BaseMaterial3D.vertex_color_use_as_albedo] to [code]true[/code].
</member> </member>
<member name="color_ramp" type="Gradient" setter="set_color_ramp" getter="get_color_ramp"> <member name="color_ramp" type="Gradient" setter="set_color_ramp" getter="get_color_ramp">
Each particle's color will vary along this [GradientTexture] over its lifetime (multiplied with [member color]). Each particle's color will vary along this [GradientTexture1D] over its lifetime (multiplied with [member color]).
</member> </member>
<member name="damping_curve" type="Curve" setter="set_param_curve" getter="get_param_curve"> <member name="damping_curve" type="Curve" setter="set_param_curve" getter="get_param_curve">
Damping will vary along this [Curve]. Damping will vary along this [Curve].

View file

@ -39,7 +39,7 @@
The global brightness value of the rendered scene. Effective only if [code]adjustment_enabled[/code] is [code]true[/code]. The global brightness value of the rendered scene. Effective only if [code]adjustment_enabled[/code] is [code]true[/code].
</member> </member>
<member name="adjustment_color_correction" type="Texture" setter="set_adjustment_color_correction" getter="get_adjustment_color_correction"> <member name="adjustment_color_correction" type="Texture" setter="set_adjustment_color_correction" getter="get_adjustment_color_correction">
The [Texture2D] or [Texture3D] lookup table (LUT) to use for the built-in post-process color grading. Can use a [GradientTexture] for a 1-dimensional LUT, or a [Texture3D] for a more complex LUT. Effective only if [code]adjustment_enabled[/code] is [code]true[/code]. The [Texture2D] or [Texture3D] lookup table (LUT) to use for the built-in post-process color grading. Can use a [GradientTexture1D] for a 1-dimensional LUT, or a [Texture3D] for a more complex LUT. Effective only if [code]adjustment_enabled[/code] is [code]true[/code].
</member> </member>
<member name="adjustment_contrast" type="float" setter="set_adjustment_contrast" getter="get_adjustment_contrast" default="1.0"> <member name="adjustment_contrast" type="float" setter="set_adjustment_contrast" getter="get_adjustment_contrast" default="1.0">
The global contrast value of the rendered scene (default value is 1). Effective only if [code]adjustment_enabled[/code] is [code]true[/code]. The global contrast value of the rendered scene (default value is 1). Effective only if [code]adjustment_enabled[/code] is [code]true[/code].

View file

@ -1,10 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<class name="GradientTexture" inherits="Texture2D" version="4.0"> <class name="GradientTexture1D" inherits="Texture2D" version="4.0">
<brief_description> <brief_description>
Gradient-filled texture. Gradient-filled texture.
</brief_description> </brief_description>
<description> <description>
GradientTexture uses a [Gradient] to fill the texture data. The gradient will be filled from left to right using colors obtained from the gradient. This means the texture does not necessarily represent an exact copy of the gradient, but instead an interpolation of samples obtained from the gradient at fixed steps (see [member width]). GradientTexture1D uses a [Gradient] to fill the texture data. The gradient will be filled from left to right using colors obtained from the gradient. This means the texture does not necessarily represent an exact copy of the gradient, but instead an interpolation of samples obtained from the gradient at fixed steps (see [member width]).
</description> </description>
<tutorials> <tutorials>
</tutorials> </tutorials>

View file

@ -128,7 +128,7 @@
Each particle's initial color. If the [GPUParticles2D]'s [code]texture[/code] is defined, it will be multiplied by this color. To have particle display color in a [BaseMaterial3D] make sure to set [member BaseMaterial3D.vertex_color_use_as_albedo] to [code]true[/code]. Each particle's initial color. If the [GPUParticles2D]'s [code]texture[/code] is defined, it will be multiplied by this color. To have particle display color in a [BaseMaterial3D] make sure to set [member BaseMaterial3D.vertex_color_use_as_albedo] to [code]true[/code].
</member> </member>
<member name="color_ramp" type="Texture2D" setter="set_color_ramp" getter="get_color_ramp"> <member name="color_ramp" type="Texture2D" setter="set_color_ramp" getter="get_color_ramp">
Each particle's color will vary along this [GradientTexture] over its lifetime (multiplied with [member color]). Each particle's color will vary along this [GradientTexture1D] over its lifetime (multiplied with [member color]).
</member> </member>
<member name="damping_curve" type="Texture2D" setter="set_param_texture" getter="get_param_texture"> <member name="damping_curve" type="Texture2D" setter="set_param_texture" getter="get_param_texture">
Damping will vary along this [CurveTexture]. Damping will vary along this [CurveTexture].

View file

@ -84,7 +84,7 @@ void EditorResourcePicker::_update_resource_preview(const String &p_path, const
if (p_preview.is_valid()) { if (p_preview.is_valid()) {
preview_rect->set_offset(SIDE_LEFT, assign_button->get_icon()->get_width() + assign_button->get_theme_stylebox(SNAME("normal"))->get_default_margin(SIDE_LEFT) + get_theme_constant(SNAME("hseparation"), SNAME("Button"))); preview_rect->set_offset(SIDE_LEFT, assign_button->get_icon()->get_width() + assign_button->get_theme_stylebox(SNAME("normal"))->get_default_margin(SIDE_LEFT) + get_theme_constant(SNAME("hseparation"), SNAME("Button")));
if (type == "GradientTexture") { if (type == "GradientTexture1D") {
preview_rect->set_stretch_mode(TextureRect::STRETCH_SCALE); preview_rect->set_stretch_mode(TextureRect::STRETCH_SCALE);
assign_button->set_custom_minimum_size(Size2(1, 1)); assign_button->set_custom_minimum_size(Size2(1, 1));
} else { } else {

View file

Before

Width:  |  Height:  |  Size: 495 B

After

Width:  |  Height:  |  Size: 495 B

View file

@ -1168,7 +1168,7 @@ void CPUParticles2D::convert_from_particles(Node *p_particles) {
set_color(material->get_color()); set_color(material->get_color());
Ref<GradientTexture> gt = material->get_color_ramp(); Ref<GradientTexture1D> gt = material->get_color_ramp();
if (gt.is_valid()) { if (gt.is_valid()) {
set_color_ramp(gt->get_gradient()); set_color_ramp(gt->get_gradient());
} }

View file

@ -1328,7 +1328,7 @@ void CPUParticles3D::convert_from_particles(Node *p_particles) {
set_color(material->get_color()); set_color(material->get_color());
Ref<GradientTexture> gt = material->get_color_ramp(); Ref<GradientTexture1D> gt = material->get_color_ramp();
if (gt.is_valid()) { if (gt.is_valid()) {
set_color_ramp(gt->get_gradient()); set_color_ramp(gt->get_gradient());
} }

View file

@ -791,7 +791,7 @@ void register_scene_types() {
GDREGISTER_CLASS(MeshTexture); GDREGISTER_CLASS(MeshTexture);
GDREGISTER_CLASS(CurveTexture); GDREGISTER_CLASS(CurveTexture);
GDREGISTER_CLASS(CurveXYZTexture); GDREGISTER_CLASS(CurveXYZTexture);
GDREGISTER_CLASS(GradientTexture); GDREGISTER_CLASS(GradientTexture1D);
GDREGISTER_CLASS(GradientTexture2D); GDREGISTER_CLASS(GradientTexture2D);
GDREGISTER_CLASS(ProxyTexture); GDREGISTER_CLASS(ProxyTexture);
GDREGISTER_CLASS(AnimatedTexture); GDREGISTER_CLASS(AnimatedTexture);
@ -922,6 +922,7 @@ void register_scene_types() {
ClassDB::add_compatibility_class("EditorSpatialGizmo", "EditorNode3DGizmo"); ClassDB::add_compatibility_class("EditorSpatialGizmo", "EditorNode3DGizmo");
ClassDB::add_compatibility_class("EditorSpatialGizmoPlugin", "EditorNode3DGizmoPlugin"); ClassDB::add_compatibility_class("EditorSpatialGizmoPlugin", "EditorNode3DGizmoPlugin");
ClassDB::add_compatibility_class("Generic6DOFJoint", "Generic6DOFJoint3D"); ClassDB::add_compatibility_class("Generic6DOFJoint", "Generic6DOFJoint3D");
ClassDB::add_compatibility_class("GradientTexture", "GradientTexture1D");
ClassDB::add_compatibility_class("HeightMapShape", "HeightMapShape3D"); ClassDB::add_compatibility_class("HeightMapShape", "HeightMapShape3D");
ClassDB::add_compatibility_class("HingeJoint", "HingeJoint3D"); ClassDB::add_compatibility_class("HingeJoint", "HingeJoint3D");
ClassDB::add_compatibility_class("Joint", "Joint3D"); ClassDB::add_compatibility_class("Joint", "Joint3D");

View file

@ -917,7 +917,7 @@ float Environment::get_adjustment_saturation() const {
void Environment::set_adjustment_color_correction(Ref<Texture> p_color_correction) { void Environment::set_adjustment_color_correction(Ref<Texture> p_color_correction) {
adjustment_color_correction = p_color_correction; adjustment_color_correction = p_color_correction;
Ref<GradientTexture> grad_tex = p_color_correction; Ref<GradientTexture1D> grad_tex = p_color_correction;
if (grad_tex.is_valid()) { if (grad_tex.is_valid()) {
if (!grad_tex->is_connected(CoreStringNames::get_singleton()->changed, callable_mp(this, &Environment::_update_adjustment))) { if (!grad_tex->is_connected(CoreStringNames::get_singleton()->changed, callable_mp(this, &Environment::_update_adjustment))) {
grad_tex->connect(CoreStringNames::get_singleton()->changed, callable_mp(this, &Environment::_update_adjustment)); grad_tex->connect(CoreStringNames::get_singleton()->changed, callable_mp(this, &Environment::_update_adjustment));

View file

@ -1413,7 +1413,7 @@ void ParticlesMaterial::_bind_methods() {
ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "scale_curve", PROPERTY_HINT_RESOURCE_TYPE, "CurveTexture,CurveXYZTexture"), "set_param_texture", "get_param_texture", PARAM_SCALE); ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "scale_curve", PROPERTY_HINT_RESOURCE_TYPE, "CurveTexture,CurveXYZTexture"), "set_param_texture", "get_param_texture", PARAM_SCALE);
ADD_GROUP("Color", ""); ADD_GROUP("Color", "");
ADD_PROPERTY(PropertyInfo(Variant::COLOR, "color"), "set_color", "get_color"); ADD_PROPERTY(PropertyInfo(Variant::COLOR, "color"), "set_color", "get_color");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "color_ramp", PROPERTY_HINT_RESOURCE_TYPE, "GradientTexture"), "set_color_ramp", "get_color_ramp"); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "color_ramp", PROPERTY_HINT_RESOURCE_TYPE, "GradientTexture1D"), "set_color_ramp", "get_color_ramp");
ADD_GROUP("Hue Variation", "hue_"); ADD_GROUP("Hue Variation", "hue_");
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "hue_variation_min", PROPERTY_HINT_RANGE, "-1,1,0.01"), "set_param_min", "get_param_min", PARAM_HUE_VARIATION); ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "hue_variation_min", PROPERTY_HINT_RANGE, "-1,1,0.01"), "set_param_min", "get_param_min", PARAM_HUE_VARIATION);

View file

@ -1729,53 +1729,53 @@ CurveXYZTexture::~CurveXYZTexture() {
////////////////// //////////////////
GradientTexture::GradientTexture() { GradientTexture1D::GradientTexture1D() {
_queue_update(); _queue_update();
} }
GradientTexture::~GradientTexture() { GradientTexture1D::~GradientTexture1D() {
if (texture.is_valid()) { if (texture.is_valid()) {
RS::get_singleton()->free(texture); RS::get_singleton()->free(texture);
} }
} }
void GradientTexture::_bind_methods() { void GradientTexture1D::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_gradient", "gradient"), &GradientTexture::set_gradient); ClassDB::bind_method(D_METHOD("set_gradient", "gradient"), &GradientTexture1D::set_gradient);
ClassDB::bind_method(D_METHOD("get_gradient"), &GradientTexture::get_gradient); ClassDB::bind_method(D_METHOD("get_gradient"), &GradientTexture1D::get_gradient);
ClassDB::bind_method(D_METHOD("set_width", "width"), &GradientTexture::set_width); ClassDB::bind_method(D_METHOD("set_width", "width"), &GradientTexture1D::set_width);
// The `get_width()` method is already exposed by the parent class Texture2D. // The `get_width()` method is already exposed by the parent class Texture2D.
ClassDB::bind_method(D_METHOD("set_use_hdr", "enabled"), &GradientTexture::set_use_hdr); ClassDB::bind_method(D_METHOD("set_use_hdr", "enabled"), &GradientTexture1D::set_use_hdr);
ClassDB::bind_method(D_METHOD("is_using_hdr"), &GradientTexture::is_using_hdr); ClassDB::bind_method(D_METHOD("is_using_hdr"), &GradientTexture1D::is_using_hdr);
ClassDB::bind_method(D_METHOD("_update"), &GradientTexture::_update); ClassDB::bind_method(D_METHOD("_update"), &GradientTexture1D::_update);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "gradient", PROPERTY_HINT_RESOURCE_TYPE, "Gradient"), "set_gradient", "get_gradient"); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "gradient", PROPERTY_HINT_RESOURCE_TYPE, "Gradient"), "set_gradient", "get_gradient");
ADD_PROPERTY(PropertyInfo(Variant::INT, "width", PROPERTY_HINT_RANGE, "1,4096"), "set_width", "get_width"); ADD_PROPERTY(PropertyInfo(Variant::INT, "width", PROPERTY_HINT_RANGE, "1,4096"), "set_width", "get_width");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "use_hdr"), "set_use_hdr", "is_using_hdr"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "use_hdr"), "set_use_hdr", "is_using_hdr");
} }
void GradientTexture::set_gradient(Ref<Gradient> p_gradient) { void GradientTexture1D::set_gradient(Ref<Gradient> p_gradient) {
if (p_gradient == gradient) { if (p_gradient == gradient) {
return; return;
} }
if (gradient.is_valid()) { if (gradient.is_valid()) {
gradient->disconnect(CoreStringNames::get_singleton()->changed, callable_mp(this, &GradientTexture::_update)); gradient->disconnect(CoreStringNames::get_singleton()->changed, callable_mp(this, &GradientTexture1D::_update));
} }
gradient = p_gradient; gradient = p_gradient;
if (gradient.is_valid()) { if (gradient.is_valid()) {
gradient->connect(CoreStringNames::get_singleton()->changed, callable_mp(this, &GradientTexture::_update)); gradient->connect(CoreStringNames::get_singleton()->changed, callable_mp(this, &GradientTexture1D::_update));
} }
_update(); _update();
emit_changed(); emit_changed();
} }
Ref<Gradient> GradientTexture::get_gradient() const { Ref<Gradient> GradientTexture1D::get_gradient() const {
return gradient; return gradient;
} }
void GradientTexture::_queue_update() { void GradientTexture1D::_queue_update() {
if (update_pending) { if (update_pending) {
return; return;
} }
@ -1784,7 +1784,7 @@ void GradientTexture::_queue_update() {
call_deferred(SNAME("_update")); call_deferred(SNAME("_update"));
} }
void GradientTexture::_update() { void GradientTexture1D::_update() {
update_pending = false; update_pending = false;
if (gradient.is_null()) { if (gradient.is_null()) {
@ -1839,17 +1839,17 @@ void GradientTexture::_update() {
emit_changed(); emit_changed();
} }
void GradientTexture::set_width(int p_width) { void GradientTexture1D::set_width(int p_width) {
ERR_FAIL_COND(p_width <= 0); ERR_FAIL_COND(p_width <= 0);
width = p_width; width = p_width;
_queue_update(); _queue_update();
} }
int GradientTexture::get_width() const { int GradientTexture1D::get_width() const {
return width; return width;
} }
void GradientTexture::set_use_hdr(bool p_enabled) { void GradientTexture1D::set_use_hdr(bool p_enabled) {
if (p_enabled == use_hdr) { if (p_enabled == use_hdr) {
return; return;
} }
@ -1858,11 +1858,11 @@ void GradientTexture::set_use_hdr(bool p_enabled) {
_queue_update(); _queue_update();
} }
bool GradientTexture::is_using_hdr() const { bool GradientTexture1D::is_using_hdr() const {
return use_hdr; return use_hdr;
} }
Ref<Image> GradientTexture::get_image() const { Ref<Image> GradientTexture1D::get_image() const {
if (!texture.is_valid()) { if (!texture.is_valid()) {
return Ref<Image>(); return Ref<Image>();
} }

View file

@ -669,8 +669,8 @@ public:
~CurveXYZTexture(); ~CurveXYZTexture();
}; };
class GradientTexture : public Texture2D { class GradientTexture1D : public Texture2D {
GDCLASS(GradientTexture, Texture2D); GDCLASS(GradientTexture1D, Texture2D);
public: public:
struct Point { struct Point {
@ -710,8 +710,8 @@ public:
virtual Ref<Image> get_image() const override; virtual Ref<Image> get_image() const override;
GradientTexture(); GradientTexture1D();
virtual ~GradientTexture(); virtual ~GradientTexture1D();
}; };
class GradientTexture2D : public Texture2D { class GradientTexture2D : public Texture2D {