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

Provide a way to create gradient textures in 2D with different types of fill, not just 1D #1677

Closed
Tracked by #7
Xrayez opened this issue Oct 16, 2020 · 7 comments
Closed
Tracked by #7

Comments

@Xrayez
Copy link
Contributor

Xrayez commented Oct 16, 2020

Describe the project you are working on:
Goost - Godot Engine Extension.

Describe the problem or limitation you are having in your project:
The current GradientTexture is only capable of generating horizontal one-dimensional textures. I'd expect such a class to provide a way to generate 2D gradients as well.

Describe the feature / enhancement and how it helps to overcome the problem or limitation:
Adding the Y component to the existing GradientTexture has the following benefits:

  • no need to create a simple gradient in an external program, increasing prototyping speed;
  • making Light2D masks with radial fill without leaving the editor;
  • enhancing TextureProgress to also include the height;
  • useful as shader input;
  • making it easy to create sky parallax/background in 2D without using shaders (again, the height is important here, as a 1x2048 texture can be repeated to span horizontally).

Helps use cases described in other proposals: #611.

Describe how your proposal will work, with code, pseudocode, mockups, and/or diagrams:

  1. Improve GradientTexture to allow more advanced types of fills godot#31655: modify existing GradientTexture class.
  2. Add GradientTexture2D godot#42855: create a new GradientTexture2D class.

Reasons for creating a separate class for this:

  • doesn't break existing functionality with GradientTexture at all (used by particle systems, visual shaders, color correction);
  • less complexity and more efficiency for existing GradientTexture;
  • by default, the texture has 256x256 dimensions rather than 2048x1, which is more intuitive for beginners;
  • adding more functionality to GradientTexture2D is easier in the future, different editor icons can be created;
  • if the proposal is not approved for core, can be easily made part of Goost or any other module. 😛

If this enhancement will not be used often, can it be worked around with a few lines of script?:
Shaders can be used for this, but not as easy to use for beginners.

Is there a reason why this should be core and not an add-on in the asset library?:
There are existing plugins like https://github.com/Maujoe/godot-custom-gradient-texture, but usability asks for better. I've actually tried to create a new type of Texture but it seems like it's impossible to extend the base class via script as seen in godotengine/godot#42830. The only feasible way to create such a thing is by extending ImageTexture but even then it lead to various inspector problems.

@djrain
Copy link

djrain commented Nov 9, 2020

Just want to point out that ideally, we need a much better solution for Light2D masks. Perhaps even built into Light2D. Unity for instance has sprite lights, freeform (polygon), point, and parametric, and each one has gizmos for convenient editing of parameters. But I can also imagine other places besides lights where you'd want to use similar textures, like particle emission masks. So a Texture, or multiple different ones, would be ideal if possible - assuming they come with gizmos that you can edit in the scene, and that the parameters are dynamic and changeable at runtime. I would guess Unity uses some sort of SDF shaders for speed (I have already mostly replicated their point lights using SDF shader and a viewport, but it's obviously not convenient).

Not that any of that would necessarily make this proposal irrelevant, but it's stuff to consider as there would definitely be overlapping functionality.

@Calinou
Copy link
Member

Calinou commented Nov 9, 2020

@djrain You may be interested in CanvasGroup and CanvasItem clipping and the new 2D lighting system, both of which are coming in 4.0.

@djrain
Copy link

djrain commented Nov 9, 2020

@Calinou Thanks, both things look awesome, though I'm not sure exactly how clipping is related to this? And there aren't currently any plans for generating light textures, correct?

@Xrayez
Copy link
Contributor Author

Xrayez commented Nov 16, 2020

It's been exactly one month since this proposal is created, and over a year for godotengine/godot#31655, so I think I'll start to implement this feature in Goost sooner than later (for Godot 3.2), once I'm done with some other features.

Unity for instance has sprite lights, freeform (polygon), point, and parametric, and each one has gizmos for convenient editing of parameters.

Polygon stuff is so prevalent in Godot that there's even AbstractPolygon2DEditorPlugin, and even some converters can be implemented more or less easily (if we're talking about implementing new polygon-based classes).

@Xrayez
Copy link
Contributor Author

Xrayez commented Dec 13, 2020

This proposal is now implemented in Goost: goostengine/goost#43.

@theraot
Copy link

theraot commented Aug 17, 2021

Looking for a build-in solution for a vertical gradient texture lead me to godotengine/godot#29748 and that lead me here. And the reason I was looking for that is for creating a custom UI theme (No, I can't set shaders there). Vertical gradient in buttons is much better than horizontal gradient in buttons. And I consider having it build-in to be better for quick prototyping. I haven't decided on how I want the UI theme. And look at that pressed button. What if I want it in another color? Oh.

@Chaosus
Copy link
Member

Chaosus commented Oct 29, 2021

Guess it's fixed now and should be closed.

@Chaosus Chaosus closed this as completed Oct 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants