Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | davidpgil | |
Old Version | Published before Godot 3 was released. |
I have an image that has no alpha channel with a logo in the middle and the rest of the image is hot pink (red 255, green 255, blue 0). I want to make that color transparent in Godots viewport and when the game is run. How do I do that?
I know I can just save a PNG with alpha transparency, but I have some reasons I do not want to do this. I want to to “key out” or “chroma key” the hot pink color so it is not visible at all.
If this needs to be done with a script, please help me find what I need to look at in order to do this.
Thanks in advance for any help.
I know I can just save a PNG with alpha transparency, but I have some reasons I do not want to do this.
Using alpha transparency in PNGs is a better idea – image editing in a game engine is rarely a smart thing to do, and Godot does not have functionality to display a single color value as transparency.
This can be done automagically using ImageMagick. For example, you could use this ImageMagick command, looping over PNG files with a constant color as transparency key (here, it’s cyan):
mogrify -transparent "rgb(0, 255, 255)" image.png
Note that this will overwrite the original files, use convert
instead of mogrify
to be able to specify a destination file name.
Calinou | 2017-10-07 12:08
Thank you for your thoughtful response.
My hope was to take advantage of indexed color graphics. I have worked in creating gameboy and nintendo ds games in the past and I want to work with images in a very similar way where I could play with color indexes of a small group of colors to create certain visual effects. I know these days people don’t use indexed color graphics except for animated gifs, but I want to retain this “feel” for my project.
Again, I appreciate your response because it grants me more information to play with with. Also, imagemagick is awesome! tip of the hat to you.
davidpgil | 2017-10-07 22:34
Reviving this thread regarding Godot 3. The below solution works in Godot 2 but now I want to do this in Godot 3. How can I do this? If I should start a new thread, please let me know.
Anyone know how to do this in Godot 3?
davidpgil | 2018-11-11 23:10