diff --git a/doc/classes/GradientTexture2D.xml b/doc/classes/GradientTexture2D.xml
index f11b2a6018..a4a6237049 100644
--- a/doc/classes/GradientTexture2D.xml
+++ b/doc/classes/GradientTexture2D.xml
@@ -46,6 +46,9 @@
The colors are linearly interpolated in a square pattern.
+
+ The colors are linearly interpolated in a cone pattern.
+
The gradient fill is restricted to the range defined by [member fill_from] to [member fill_to] offsets.
diff --git a/scene/resources/gradient_texture.cpp b/scene/resources/gradient_texture.cpp
index c812321966..2699e79808 100644
--- a/scene/resources/gradient_texture.cpp
+++ b/scene/resources/gradient_texture.cpp
@@ -302,6 +302,9 @@ float GradientTexture2D::_get_gradient_offset_at(int x, int y) const {
ofs = (pos - fill_from).length() / (fill_to - fill_from).length();
} else if (fill == Fill::FILL_SQUARE) {
ofs = MAX(Math::abs(pos.x - fill_from.x), Math::abs(pos.y - fill_from.y)) / MAX(Math::abs(fill_to.x - fill_from.x), Math::abs(fill_to.y - fill_from.y));
+ } else if (fill == Fill::FILL_CONIC) {
+ float rel_angle = (fill_to - fill_from).angle_to(pos - fill_from);
+ ofs = Math::fposmod((double)rel_angle, Math::TAU) / Math::TAU;
}
if (repeat == Repeat::REPEAT_NONE) {
ofs = CLAMP(ofs, 0.0, 1.0);
@@ -442,7 +445,7 @@ void GradientTexture2D::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "use_hdr"), "set_use_hdr", "is_using_hdr");
ADD_GROUP("Fill", "fill_");
- ADD_PROPERTY(PropertyInfo(Variant::INT, "fill", PROPERTY_HINT_ENUM, "Linear,Radial,Square"), "set_fill", "get_fill");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "fill", PROPERTY_HINT_ENUM, "Linear,Radial,Square,Conic"), "set_fill", "get_fill");
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "fill_from"), "set_fill_from", "get_fill_from");
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "fill_to"), "set_fill_to", "get_fill_to");
@@ -452,6 +455,7 @@ void GradientTexture2D::_bind_methods() {
BIND_ENUM_CONSTANT(FILL_LINEAR);
BIND_ENUM_CONSTANT(FILL_RADIAL);
BIND_ENUM_CONSTANT(FILL_SQUARE);
+ BIND_ENUM_CONSTANT(FILL_CONIC);
BIND_ENUM_CONSTANT(REPEAT_NONE);
BIND_ENUM_CONSTANT(REPEAT);
diff --git a/scene/resources/gradient_texture.h b/scene/resources/gradient_texture.h
index 8b785fa775..04877bf7a2 100644
--- a/scene/resources/gradient_texture.h
+++ b/scene/resources/gradient_texture.h
@@ -78,6 +78,7 @@ public:
FILL_LINEAR,
FILL_RADIAL,
FILL_SQUARE,
+ FILL_CONIC,
};
enum Repeat {
REPEAT_NONE,