-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add GradientTexture2D
#42855
Add GradientTexture2D
#42855
Conversation
Build artifacts are also available now, by the way: |
@Xrayez this need to be rebased |
Rebased, fixed See also test project attached in the original post. |
Co-authored-by: Mariano Suligoy <marianognu.easyrpg@gmail.com>
Fixed by creating texture placeholder, similarly to how RID GradientTexture2D::get_rid() const {
if (!texture.is_valid()) {
texture = RS::get_singleton()->texture_2d_placeholder_create();
}
return texture;
} Invalid textures were treated as bad by The same limitation exists in This is another change which differs current implementation from #31655, likely it wasn't completely obvious what changes were needed to make it work in The editor still doesn't auto-instantiate the default |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems fine now :)
I think this needs In GDScript, in theory you could extend @tool
class_name RadialLightTexture extends GradientTexture2D
func _init():
fill = GradientTexture2D.FILL_RADIAL
fill_from = Vector2(0.5, 0.5)
fill_to = Vector2(0.5, 0.0)
gradient = Gradient.new()
# Invert by switching black and white.
gradient.set_offset(0, 1.0)
gradient.set_offset(1, 0.0) But extending textures doesn't work because If you set those properties via inspector, you'll get this: So, currently it takes a lot of steps to setup a radial texture like this... Mainly talking about use case described in godotengine/godot-proposals#1717, so perhaps adding Automatically switching properties specifically for linear and radial types is also something to consider:
You only need to use either type of fill, so automatically switching those properties won't hurt anything, in my opinion. |
The 3.2 version of this PR is now merged in Goost: goostengine/goost#43. |
I've added |
Based on #31655, co-authored-by @MarianoGnu.
(yes, this is radial gradient texture used in a
Light2D
node, and animated withAnimationPlayer
).Godot proposal: godotengine/godot-proposals#1677.
Changes when comparing to #31655:
GradientTexture2D
rather than modifying existingGradientTexture
;GradientTexture
is better renamed toGradientTexture1D
;gradient
is empty, similarly toNoiseTexture
(NOTE:GradientTexture
needs a similar fix).get_width
andget_height
virtual overrides (NOTE:GradientTexture
needs a similar fix).enum
s to justFill
andRepeat
,NO_REPEAT
renamed toREPEAT_NONE
(conform to existing naming convention).fill_
andrepeat_
properties in the inspector.PROPERTY_USAGE_EDITOR_INSTANTIATE_OBJECT
forgradient
(doesn't work in currentmaster
, see Refactor auto-instantiation ofObject
properties in editor #43015);GradientTexture
(for now);Not sure about
fill_from
andfill_to
. Perhaps it would be better to rename this tofill_start_offset
andfill_end_offset
.To-do
Test project:
gradient_texture_2d.zip