crashinvaders / gdx-texture-packer-gui

A simple way to pack and manage texture atlases for libGDX game framework.
Apache License 2.0
595 stars 73 forks source link

Premultiply Alpha Preview #29

Open raeleus opened 6 years ago

raeleus commented 6 years ago

I have a suggestion regarding the Premultiply Alpha option. The preview should reflect the use of premultiply alpha. Right now, it uses the default blend mode and renders the preview with the ugly black edges and such.

Black edges should be white

If I got it right, you'll need to change the blend mode to the following before you render the preview: spriteBatch.setBlendFunction(GL20.GL_ONE, GL20.GL_ONE_MINUS_SRC_ALPHA);

And then you would need to switch it back for your UI: spriteBatch.setBlendFunction(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);

This should only be applied to textures packed with Premultiply Alpha selected, of course. Thanks for your consideration.

metaphore commented 6 years ago

Thanks for the suggestion. I got your point here, but I'm not sure this is the right approach to apply any sort of post processing to the original atlas pages. You see, there could be a lot of different options that make plain pages look different from what they should be in the actual game, but those artifacts may be the only thing that can point to specific applied techniques to the atlas composing. From my perspective, it's important to show the original pages first and maybe like a second option allow user to turn on additional render features to check some cases they interested in.

On the other hand, atlas preview now operates like a dedicated component, it has no connection to selected atlas model and only works with the data it obtains from the actual saved file, which in this case has no information about premultiplied alpha and many other options. But this is rather implementation issue and since I'm going to extend supported export formats, this will be no longer a working solution and the atlas preview must be rewritten to reflect actual atlas state on the fly. So this probably will be a right moment to put such features in.

If you have any other ideas on how to improve atlas preview, I'm all ears!

raeleus commented 6 years ago

Yes, you raise very good points. A selectable option in the preview would be good. Other additions could be an option to change the transparency grid colors and the ability to select the corresponding file in Pack files by clicking the image in the preview. I don't think any of these are critical features though.