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

Allow to invert texture colors in the default importer #9618

Open
Souchy opened this issue Apr 28, 2024 · 2 comments
Open

Allow to invert texture colors in the default importer #9618

Souchy opened this issue Apr 28, 2024 · 2 comments

Comments

@Souchy
Copy link

Souchy commented Apr 28, 2024

Describe the project you are working on

Tool applications for desktop.

Describe the problem or limitation you are having in your project

Standard icons usually come in black, which can't be modulated directly. I.E. on button icons.

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

The feature would invert the rgb channels, i.e. making black icons white.
Having this in an importer speeds up the process of inverting every texture.
It could also be interesting to have a grayscale modifier in combination with this.

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

ResourceImporterTexture::import

	r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "process/invert_color"), false));
	const bool invert_color = p_options["process/invert_color"];
		// Invert rgb channels
		if(invert_color) {
			const int height = target_image->get_height();
			const int width = target_image->get_width();

			for (int i = 0; i < width; i++) {
				for (int j = 0; j < height; j++) {
					const Color color = target_image->get_pixel(i, j);
					const Color inverted = Color(1 - color.r, 1 - color.g, 1 - color.b, color.a);
					target_image->set_pixel(i, j, inverted);
				}
			}
		}

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

It could be an importer script.

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

I believe it could useful to a lot of people, and less of a hassle, therefore better to be built in the engine.

@Calinou
Copy link
Member

Calinou commented Apr 28, 2024

Note that this was available in 3.x, but was removed in 4.0 as we didn't see any use cases for it back then: godotengine/godot#39202

@VideoGirlAi
Copy link

I decided to finally start converting my Godot 3 project to Godot 4, and was in the process of importing my bitmap fonts. I make my bitmap fonts textures in black, as it's easy to see in my image editor, and then I would invert colors on import so that the font is white in Godot. I'm pretty sad to see that this option is gone. I hope it can be re-implemented.

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

3 participants