elringus / sprite-dicing

Cross-engine tool for lossless compression of sprites with identical areas
https://dicing.elringus.me
MIT License
1.35k stars 144 forks source link

Sprite Centers are wrong #8

Closed zsculpt closed 3 years ago

zsculpt commented 3 years ago

I'm still having this problem with the latest 1.1 package. The first image is my actual PNG with alpha. As you can see, the sprite is near the bottom half of the PNG. The second image is with the pivot point set to default (the sprite has been re-centered), and the third image is with the pivot point with the checkbox "Keep Original" (the sprite has been offset based on the lower left-hand corner). How do I make this use the actual position of the sprite on the PNG?

Diced Sprites Problem

elringus commented 3 years ago

Check the animation scene in the repo, keep original works fine there.

zsculpt commented 3 years ago

I've looked at that example and it has the same problem. "Keep Original" sets the pivot point to the lower left-hand corner, which is not correct. The center should be the center of the source PNG.

zsculpt commented 3 years ago

Here you can see what's happening. Left image is the sprite dicing animation and the right image is a Unity sprite from the same PNG:

Sprite-Dicing-Error-2

elringus commented 3 years ago

That's by design. Keep Original preserves relative position of the pivot to the source texture content. The textures you've mentioned have transparent "slack", that's why it looks like the pivot has offset from the actual content.

zsculpt commented 3 years ago

Is it possibly for you to add in a mode that would preserve the position based on the dimensions of the texture? My use case is an app with literally hundreds of icons that are all a fixed size (256x256). The problem is when I use the SpriteDicing tools over Unity’s built-in sprites, their positions all get completely out of whack in their alignments to the UI. Please consider adding support for this, as I feel it is a quite common setup with UI.

On Feb 3, 2021, at 5:23 AM, Artyom Sovetnikov notifications@github.com wrote:

That's by design. Keep Original preserves relative position of the pivot to the source texture content. The textures you've mentioned have transparent "slack", that's why it looks like the pivot has offset from the actual content.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Elringus/SpriteDicing/issues/8#issuecomment-772469124, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABLMMRG6SQDKBCUDJCPI4XTS5E54PANCNFSM4UGB564Q.

elringus commented 3 years ago

Keep pivot does just that. It preserves position of the pivot relative to the source texture. The pivot will always be at the bottom-left corner, though (0, 0). I guess it's possible to add an option to control the original pivot position as well, but that's not something I personally need atm; PRs are welcome, though.

zsculpt commented 3 years ago

Right, and that’s what I’m getting at. Most UI stuff (when it comes to icons on buttons and such) uses a default pivot point that is at the center of the icon. There are literally hundreds of icons in this app with more being added every time I update it. Just please take it under consideration if it’s a feature that could be easily implemented for you, it would be hugely appreciated.

Cheers,

On Feb 3, 2021, at 11:00 AM, Artyom Sovetnikov notifications@github.com wrote:

Keep pivot does just that. It preserves position of the pivot relative to the source texture. The pivot will always be at the bottom-left corner, though (0, 0). I guess it's possible to add an option to control the original pivot position as well, but that's not something I personally need atm; PRs are welcome, though.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Elringus/SpriteDicing/issues/8#issuecomment-772704894, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABLMMRACINQOOTYDIWRUSZ3S5GFLBANCNFSM4UGB564Q.

elringus commented 3 years ago

If you want centered pivot, just disable keep and set it at 0.5,0.5

elringus commented 3 years ago

Keep pivot does just that. It preserves position of the pivot relative to the source texture. The pivot will always be at the bottom-left corner, though (0, 0). I guess it's possible to add an option to control the original pivot position as well, but that's not something I personally need atm; PRs are welcome, though.

I've added the option in new release. When Keep Pivot is enabled and source texture has an associated sprite, pivot of the sprite (set via sprite editor) will be preserved (relative to the dimensions of the source texture).