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 remapping the color channels of a texture on import #11243

Open
BlueCube3310 opened this issue Nov 27, 2024 · 0 comments · May be fixed by godotengine/godot#99676
Open

Allow remapping the color channels of a texture on import #11243

BlueCube3310 opened this issue Nov 27, 2024 · 0 comments · May be fixed by godotengine/godot#99676

Comments

@BlueCube3310
Copy link

Describe the project you are working on

The Godot Editor

Describe the problem or limitation you are having in your project

Related to #5182 and #9618

Currently, it's impossible to remap/swizzle the color channels of an image on import. This is a useful feature to have when, for example, a user wants to remove some color channels.

The engine is already able to discard unused color channels when using the Optimized channel packing mode. However, the user may want more control over this process, like removing an existing alpha channel which is never used by a model.

Another use case of this would be if the image contains per-channel packed data (like ORM) that doesn't match up with the standard Godot is expecting. (For example, certain workflows use a smoothness map instead of roughness, or the order of the channels is different, etc.). Additionally, a user may want to make a colored image completely grayscale.

While these issues can be overcome by editing the image in external graphics software, this process takes more time, especially when dealing with many resources on bigger projects.

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

A potential solution is to add a channel remap setting to the texture import pipeline. Each channel will support the following settings:

  • Red,
  • Green,
  • Blue,
  • Alpha,
  • Inverted Red,
  • Inverted Green,
  • Inverted Blue,
  • Inverted Alpha,
  • Unused (1 for alpha, 0 for others),
  • Zero,
  • One

Note that this is different from hardware swizzling which happens during texture sampling, but is limited to R/G/B/A/0/1 by most graphics APIs.

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

A proof-of-concept implementation can be found here: godotengine/godot#99676

The settings:

Image

The per-channel options:

Image

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

This can be done with a script, but it will be inconvenient as currently it's not possible to easily add custom steps to the texture import pipeline. As such, the easiest way I can think of would be to make a script that will load the source image, swap its channels, then either overwrite it or create a copy that will be imported into an internal format.

Processing an already imported image isn't a very good idea, espacially when it has been compressed.

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

As described previously, it can be an add-on, but it would be inconvenient to use.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant