Skip to content
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

Several Gradient improvements (more interpolation modes, gradient reverse button, ...) #53321

Merged
merged 1 commit into from
Nov 8, 2021

Conversation

Geometror
Copy link
Member

@Geometror Geometror commented Oct 1, 2021

This PR aims to improve the Gradient resource by providing more interpolation modes, a gradient reverse button and restructuring the properties.
Implements godotengine/godot-proposals#1933 and godotengine/godot-proposals#1724

main

CHANGES:

  • Add 2 more interpolation modes to the Gradient resource:

    • Constant
    • Cubic

    grafik

  • Add reverse gradient function and the corresponding button to the inspector plugin

  • Restructured/cleaned up gradient properties (offsets and colors which are used rarely are now in a collapsed group called "raw data"

  • Use GradientTexture for the preview of the inspector gradient editor (reduce code and gain flexibility, no visual difference)

  • Fix gradient inspector plugin not updating when properties are changed

CURRENT MASTER:
grafik

THIS PR:
grafik

Note:
I know, a custom button is a bit overkill but I ran into a problem when using the normal button because the icon stayed invisible when it was set with btn->set_icon(get_theme_icon(...)) in EditorInspectorPlugin::parse_begin() [only if an svg icon is used, which is rendered at startup, so I guess the svg icons weren't rasterized yet] Furthermore, I couldn't find an easy way to update the icon of the button after a theme change which didn't involve lots of passthrough-functions.
If someone has an idea how to solve this with a general button let me know, but for now I think its fine (and even more light-weight since there is no TextParagraph instantiated).

As always, feedback is welcome :)

@Geometror Geometror requested review from a team as code owners October 1, 2021 20:58
@Calinou
Copy link
Member

Calinou commented Oct 1, 2021

I'd rename the "constant" mode to "nearest" to be consistent with the texture filtering mode's name.

Other than that, this seems like a pretty good change to me 🙂

@Geometror
Copy link
Member Author

Nearest neighbor would mean that for every sampled point the color of the nearest gradient point would be returned, but that is not the case as the color of one segment is determined by the left of two points and stays constant between points.
In Blender and other software it is called constant interpolation, so I went with that, but the term "stairs" is also sometimes used.

grafik
I could add nearest neighbor as well, but I think that constant/stair interpolation is enough (nearest isn't really that useful here).

Copy link
Member

@bruvzg bruvzg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reverse icon in the hiDPI mode is too large (EDSCALE should not be applied here, it's already taken into account by the theme icon loader).

Screenshot 2021-10-04 at 10 23 44

Everything else seems to be fine.

editor/plugins/gradient_editor_plugin.cpp Outdated Show resolved Hide resolved
editor/plugins/gradient_editor_plugin.cpp Outdated Show resolved Hide resolved
@Geometror Geometror force-pushed the gradient-improvements branch from fc4250b to 173a507 Compare October 9, 2021 18:47
@Geometror
Copy link
Member Author

Fixed and rebased.

@Geometror Geometror force-pushed the gradient-improvements branch 2 times, most recently from bfc7d58 to 8fe0b10 Compare October 12, 2021 14:21
scene/gui/gradient_edit.h Outdated Show resolved Hide resolved
@Geometror Geometror force-pushed the gradient-improvements branch from 8fe0b10 to ed0337c Compare November 8, 2021 18:12
@Chaosus Chaosus merged commit 38c698c into godotengine:master Nov 8, 2021
@Chaosus
Copy link
Member

Chaosus commented Nov 8, 2021

I think it's fine, thanks!

Riordan-DC pushed a commit to Riordan-DC/godot that referenced this pull request Jan 24, 2023
- Linear, Constant, and Cubic interpolation modes
- Partial backport of godotengine#53321
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants