devilutionX icon indicating copy to clipboard operation
devilutionX copied to clipboard

Off-by-one pixel alignment on mana vs health potions in belt/inventory

Open julealgon opened this issue 5 years ago • 7 comments

Health and mana potions are aligned differently in the belt slots, even though each belt cell has the exact same length.

raw

In the picture above, the mana potion is one pixel more to the right than the health potion, even though both potions have the exact same graphics. Here is a more detailed view of the misalignment:

image

The problem is unrelated to the actual cell position: having 2 of the same potion type next to each other always produce the same spacing.

UPDATE: Happens on inventory as well: image

I have not investigated this further to see if the problem is in the code, or in the CEL. I believe it could be in the CEL since both potions have very similar handling in code.

julealgon avatar Oct 02 '20 20:10 julealgon

I believe the correct solution to this would be when rendering any objcurs graphic, to detect how many columns and rows of transparent pixels exist on all sides of the graphic, and then automatically adjust the image to attempt to make all sides have an equal amount of columns and rows of transparent pixels.

kphoenix137 avatar Dec 05 '25 23:12 kphoenix137

I believe the correct solution to this would be when rendering any objcurs graphic, to detect how many columns and rows of transparent pixels exist on all sides of the graphic, and then automatically adjust the image to attempt to make all sides have an equal amount of columns and rows of transparent pixels.

Not sure I agree with that idea. The reason is that I personally think the mana potion above looks better than the health potion, but if we apply your rule, the health potion would be the "correct" one.

I would even argue that even the mana potion should be shifted 1 pixel to the right there, centralizing it on the container itself and disregarding the cord graphic.

Point being, I believe this should be a conscious design decision on a per-item basis, and not done automatically.

julealgon avatar Dec 08 '25 13:12 julealgon

I believe the correct solution to this would be when rendering any objcurs graphic, to detect how many columns and rows of transparent pixels exist on all sides of the graphic, and then automatically adjust the image to attempt to make all sides have an equal amount of columns and rows of transparent pixels.

Not sure I agree with that idea. The reason is that I personally think the mana potion above looks better than the health potion, but if we apply your rule, the health potion would be the "correct" one.

I would even argue that even the mana potion should be shifted 1 pixel to the right there, centralizing it on the container itself and disregarding the cord graphic.

Point being, I believe this should be a conscious design decision on a per-item basis, and not done automatically.

The alignment problem goes far beyond the two PRs you opened. A lot of item graphics have bad alignment and it seems weird to pick and choose specific ones to arbitrarily offset via hardcoding.

kphoenix137 avatar Dec 08 '25 18:12 kphoenix137

The alignment problem goes far beyond the two PRs you opened. A lot of item graphics have bad alignment and it seems weird to pick and choose specific ones to arbitrarily offset via hardcoding.

I can imagine there must be lots of other items with alignment problems, but I still don't think this should be automated. As for it being "weird"... I guess? Of course, it would be much nicer if we could just fix the source art directly, but that's not possible without getting into copyright territory, so to me the per-asset custom transform is the best bet on this.

I just think the automated approach will generate unpleasant results.

Also remember this also applies to animation frames, and not only to static item assets.

I do understand it would be far easier to support however.

julealgon avatar Dec 08 '25 19:12 julealgon

The alignment problem goes far beyond the two PRs you opened. A lot of item graphics have bad alignment and it seems weird to pick and choose specific ones to arbitrarily offset via hardcoding.

I can imagine there must be lots of other items with alignment problems, but I still don't think this should be automated. As for it being "weird"... I guess? Of course, it would be much nicer if we could just fix the source art directly, but that's not possible without getting into copyright territory, so to me the per-asset custom transform is the best bet on this.

I just think the automated approach will generate unpleasant results.

Also remember this also applies to animation frames, and not only to static item assets.

I do understand it would be far easier to support however.

I have a PR I wrote that applies manual adjustments to every item that isn't centered properly in frame. I think I closed it though, but I wouldn't want to reopen it unless I'm sure a bunch of magic numbers is the way to go. My suggested automated adjustments would only be applied to invcurs graphics. I find the hardcoding method a bit gross here because they're adjustments that aren't directly tied to the graphic frames themselves. If someone were to load in a modified version of objcurs.cel, they'd have to manually change the hardcoded values.

kphoenix137 avatar Dec 08 '25 19:12 kphoenix137

I suppose if we add adjustments to the TSV files, then any individual could make minor adjustments to any individual item graphic as they see fit. The downside is that it's a whole lot of work for something that we all know nobody is actually going to do for themselves. Furthermore, it's highly likely that any TSV changes will make the client incompatible with other clients in online games, because it's difficult to vet any individual TSV change to determine if it would break compatibility in any specific way.

StephenCWills avatar Dec 08 '25 20:12 StephenCWills

Yeah if we add an adjustment table it needs to go with the item definition. If it was hard coded then any mod would have to also miss align there items and would not have the full sprite area to draw there items on.

I'm fine with us having to ship a list of perfect D1 adjustments in the base TSV, people shouldn't be changing that unless the sprites are also changed.

But is this really an issue worth this level of perfectionism?

AJenbo avatar Dec 08 '25 23:12 AJenbo