godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.16k stars 97 forks source link

Add a single-color procedural Texture2D resource #9956

Open TheRealFame opened 5 months ago

TheRealFame commented 5 months ago

Describe the project you are working on

An 3D Turn Based RPG With a Heavy Story Focus.

Describe the problem or limitation you are having in your project

unable to fill TextureReact with a shader. A work around was using gradients, But I only needed a single color.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

It fixes the need to have to use a gradient, Even while that gradient isn't entirely in use. It also just adds more functionality for the possible resources the TextureRect can use.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

When the developer makes their TextureRect node, They can right click and add the parameter, From all the possible images. As a single color image/resource.

If this enhancement will not be used often, can it be worked around with a few lines of script?

Yep! Although how to make the shader isn't knowledgeable to me, As making this means you're gonna need to add a shader parameter for color, And fill the canvas with that color.

Is there a reason why this should be core and not an add-on in the asset library?

This seems overall like a smaller issue. And not something that needs implementation from an addon, Especially because it would just be undeeded.

AThousandShips commented 5 months ago

Are you talking about making a TextureRect with just a single colour in it? In that case what is not working for you with ColorRect?

TheRealFame commented 5 months ago

Are you talking about making a TextureRect with just a single colour in it? In that case what is not working for you with ColorRect?

Mhm, For the shader i am using, I cannot use a ColorRect, Or it breaks. So using a TextureRect was an overall fix for me. (Gradient Texture), And since that already exists, Why can't there just be a single color resource? It may be unnecessary, But it still seems they offered gradients with that same node. So this seems small as can be. (And the resource size can be small too. Or rendered out as srgb or another profile.)

Calinou commented 5 months ago

This already exists as GradientTexture2D (with a gradient that has a single color). In terms of efficiency, it's pretty much the same as picking a single color directly.

Mickeon commented 5 months ago

One could argue it should be easier to create a GradientTexture2D with one color (such as through presets), as there are quite a few steps to it. I can't blame anyone for not thinking about it.

TheRealFame commented 5 months ago

One could argue it should be easier to create a GradientTexture2D with one color (such as through presets), as there are quite a few steps to it. I can't blame anyone for not thinking about it.

I only thought about it because i'm a fan of filling godot with basic features, That can help any developer in any case 😅, So i actively wanna report and ask about these things as i get further into development, And further into a point where i can show off what i have done with the godot game engine.

Samvkes commented 5 months ago

For me at least, it's pretty common to want to create, and edit the colors of, my texture from code. Setting up and editing the colors of a gradientTexture2D is a lot more involved than just doing eg color = Color(1,0,0,1). Since I assume these simple textures are being used a lot for quick prototypes, making it more convenient to work with single colors would be nice.

AThousandShips commented 5 months ago

Updating the color of a gradient set to be a single color is pretty simple:

gradient_texture.gradient.set_color(0, my_color)

Or

gradient_texture.gradient.colors[0] = my_color

So you'd only need the [0] at the end compared to just assigning a single color, or just the extra gradient part if you might have a strict single color texture resource with a color property

Samvkes commented 5 months ago

I guess my point was mostly that setting up a gradient in code is a bit more work,(https://www.reddit.com/r/godot/comments/telp85/how_to_create_a_gradient_via_script/), and while changing colors isn't very different, with both of these operations you have to go read the docs to find out the specific syntax when it comes to dealing with gradients (color arrays and offsets), which seems a bit silly when you just want to work with a single color.

When I first looked at the texture creation menu I thought I was doing something wrong, because the simplest possible texture (a flat color) wasn't available. I don't think excluding it because another node fulfills a similar need (a node that you may not know about if you haven't used control nodes before and have done all your graphics with sprites) is necessarily a good reason.