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

Add the ability to import and create palette indexed sprites from GIFs #18269

Closed
Two-Tone opened this issue Apr 18, 2018 · 9 comments
Closed

Comments

@Two-Tone
Copy link

I recently found out that some engines, like MUGEN, have the ability to import GIFs and automatically convert them into animated sprites. This makes creating and adding 2D animations into the engine incredibly easy and fast.

Mugen also expands on this by allowing the user to edit the indexed palette of sprites to very quickly create palette swapped sprites. Example

You could recolor a sprite with a shader, but it doesn't allow for the same level of fine grained control.

@Zylann
Copy link
Contributor

Zylann commented Apr 18, 2018

Just a note, with shader you not only have fine grained control (changing all colors if you want and dynamically), you also have non-destructive control, as in, no need to have separate sprites per palette (where a palette is just a texture listing colors in its pixels in the end). It just needs a bit more work upfront, though.

So, while a shader allows all this, that request mostly sounds like adding tools to do the same thing more easily, as well as supporting GIF.
Also, if Godot does allow indexed colors in import, it could also support PNGs which have indexed colors (so that Aseprite users don't have to use GIF just because it has palette)

@Two-Tone
Copy link
Author

I've not looked into shaders too deeply, but I was under the impression that a shader wouldn't be able to change just one color at a time, instead changing the whole palette.

@Zylann
Copy link
Contributor

Zylann commented Apr 18, 2018

@Two-Tone it's certainly possible to change a single (or more) specific colors in a shader, either by doing a simple if, threshold, or looking up a palette texture (get pixel color of the sprite, use it as X coordinate in the palette texture, and output that instead. For a palette swap, put other palettes further down the Y coordinate). As I said, it's a bit harder to set this up though. Maybe the ability to import sprites as paletted textures could complement this.

@blurymind
Copy link

blurymind commented Apr 19, 2018

It would certainly be very beneficial to have editor support to swap palettes of sprites that support it

It is a very easy and useful way to create variation in a game, without bloating it with more resources

I think Opentoonz can export images with indexed colors. One of the layer types that it uses (Toonz Raster) supports indexed colors and it's brilliant!
Cosmigo pro motion can also do it.

Old games have heavily used the technology to a point where they even animate the color palette of static image files to fake animation on huge background images
https://en.wikipedia.org/wiki/Color_cycling

It can be done in html5 too
http://www.effectgames.com/effect/article-Old_School_Color_Cycling_with_HTML5.html
http://www.effectgames.com/demos/canvascycle/?sound=0

A lot of games use it to create a day and night version of the same levels - without having to make any new sprites and having great artistic control over the result.

According to wikipedia PNG files support 8bit indexed color palette
https://en.wikipedia.org/wiki/Indexed_color#Image_file_formats_supporting_indexed_color

The question is wether we can have godot import that data and give the draw API/editor the capability to do some interesting things with it (such as swapping the palette) without too many lines of code (or writing a shader from scratch - which is still a workaround,limited and has been done already)

I wouldnt personally use gif as the filetype to do that myself. Png is better imo

Similar requests here:
#12670

@Two-Tone
Copy link
Author

@blurymind GIFs and PNGs should both be supported as while PNG is compressed, most people export their actual animations as GIFs since APNG is not widely supported.

@jjhaggar
Copy link

jjhaggar commented Jul 2, 2018

The use of indexed color images and pallette swapping without using shaders would make my life so much more easier. I really do hope this is done sometime in the future :)

In the meantime, we can use this for palette swapping https://godotengine.org/asset-library/asset/239

@golddotasksquestions
Copy link

I want to state that the ability to import GIFs into Animated Sprite node or AnimationPlayer would speed up any pixelart workflow and most other 2D workflows a thousandfold. And therefore would make the engine a lot more suitable for fast prototyping. Right now I have to do set timing any keys twice: Once in the Animation tool I use and then again in the Godot Editor.

Color cycling would be also a very very appreciated feature, benefitting everyone doing pixelart, which is a large portion of Godot users. Shaders are really complicated and hard to get into especially for beginners.
What @akien-mga mentioned here sounds like a great proposal!

@Xrayez
Copy link
Contributor

Xrayez commented Apr 16, 2019

I think GIF importing into SpriteFrames is totally doable, yet there's no even basic GIF image loader in Godot yet. The palette part is something I'm more interested in, see #28013.

If GIF importing will be a thing, there would be one issue with extracting palette from imported frames, as they will lose palette information in custom stex format used internally. It would need to store palette as well, meaning potentially breaking existing format...

Each palette entry could be modified, and reimported.

@Two-Tone
Copy link
Author

Ported this over to godotengine/godot-proposals#475, closing here.

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

8 participants