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

Fix out-of-bounds in 'combine' texture modifier #25

Closed
wants to merge 3 commits into from
Closed

Conversation

Niklp09
Copy link
Member

@Niklp09 Niklp09 commented Feb 26, 2024

Fixes #24
TenPlus1 asked me to create this PR since github doesn't let him.

Tested, and works. But I'm not sure if this is the best approach 🤔 .

@Niklp09 Niklp09 added the bug Something isn't working label Feb 26, 2024
@tenplus1
Copy link
Contributor

@Niklp09 - Thanks for the assist :) I find that it generates signs quicker this way although anyone using their own custom font sets will need to use the convert.sh I've included to negate the image files so they work with the new setup.

@wsor4035
Copy link
Contributor

wsor4035 commented Feb 26, 2024

But I'm not sure if this is the best approach

agree on this, just skim'd the pr tho

@tenplus1
Copy link
Contributor

@Niklp09 + @wsor4035 - Does something worry you guys about the fix ?

@appgurueu
Copy link

appgurueu commented Feb 29, 2024

FWIW, you could "negate" the image files using the ^[invert texture modifier to avoid messing with the media files.

I have to say though: The current media files seem like an ugly hack. The actual glyph is transparent, whereas the background is solid? Hence the approach of this PR - to invert alpha - makes sense. If maintaining backwards compat with "custom fonts" - without running a script - is desired, you could use ^[invert.

IMO, it would make the most sense to have white, opaque glyphs on transparent background. Then you could also use ^[multiply instead of ^[colorize, which would enable having a bit of shading for glyphs (rather than just plain solid color).

@tenplus1
Copy link
Contributor

tenplus1 commented Mar 1, 2024

@appgurueu - I did try to [invert media but it never worked properly on transparent areas and the unicode textures ended up with artifacts, so in the end editing the files had to be done by hand or script.

@tenplus1
Copy link
Contributor

If it worries anyone how the changes affect signs_lib, check out Xanadu server, we've been using it since the commit and it's working well.

@appgurueu
Copy link

I wouldn't mind the texture changes much. However, please at least run something like pngcrush - the new textures are much larger than they need to be. (You could also consider converting the textures to TGA to shave off some more bytes, or packing them up in a tilesheet.)

@tenplus1
Copy link
Contributor

@appgurueu - Run optipng on every texture, please find attached the final mod in .zip form.
signs_lib_NEW.zip

@Niklp09
Copy link
Member Author

Niklp09 commented Mar 15, 2024

Commited to the branch, sorry for the delay.

@appgurueu
Copy link

Anything stopping this?

@Niklp09 Niklp09 requested a review from wsor4035 March 31, 2024 15:35
Copy link
Member Author

@Niklp09 Niklp09 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(can't approve my own pr) Works fine in my test world, no warnings in the client log.
Media size 1.054 MB -> 1.073 MB is ok for me too.
Since this is a bit controversial, I would like to get a second approval.

@OgelGames
Copy link
Contributor

After some trial and error (the code is terrible to read), I figured out a simpler way to fix the issue: #27

@BuckarooBanzay BuckarooBanzay added bugfix fixes a bug and removed bug Something isn't working labels Apr 4, 2024
c = c or "0"
local tex = { }
for xx = 0, math.max(0, w), colorbgw do
table.insert(tex, (":%d,%d=signs_lib_color_"..font_size.."px_%s.png"):format(x + xx, y, c))
Copy link

@appgurueu appgurueu Apr 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aren't the signs_lib_color_* files unused now that you switched this to a color lookup table & ^[colorize? Can't you remove them now (or is something else using them)?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I only kept them around incase any other mod was using them, a compatibility thing mostly.

@OgelGames
Copy link
Contributor

I just tested this and it doesn't fix the issue, there are still out-of-bounds textures when there is text overflow.

@tenplus1
Copy link
Contributor

tenplus1 commented Apr 8, 2024

On further inspection the signs_lib_color_(pxsize)_n.png files are required for the sign to display properly, but I have removed the colours not in use. I also applied the size changes from the OgelGames pull request into this one which works a little better, so here is the latest mod update attached :)
signs_lib.zip

@OgelGames
Copy link
Contributor

Merged #27, closing this.

@OgelGames OgelGames closed this Apr 19, 2024
@OgelGames OgelGames deleted the oob_fix branch April 19, 2024 03:44
@tenplus1
Copy link
Contributor

@OgelGames - Could you re-open this as a working alternative.

@S-S-X S-S-X restored the oob_fix branch April 19, 2024 10:50
@S-S-X
Copy link
Member

S-S-X commented Apr 19, 2024

For now restored branch if someone is still working with it. Related issue was reopened so I guess meta discussion could go there.

@OgelGames
Copy link
Contributor

Could you re-open this as a working alternative.

As I noted previously, this PR doesn't work either. I think a lot more is needed to fix it properly.

@wsor4035
Copy link
Contributor

cross posting

frankly replacing colorized textures with ^[colorize is a good idea
as to the implementation, didnt exactly dig to deep into it, so perhaps it had some flaw, but the concept is good

@appgurueu
Copy link

If there was a good specification (and tests?) such that we could ensure low risk of breaking compatibility, I would be inclined to suggest a rewrite of this part of the logic: Generating text strings via [combine is relatively simple.

Is there a good specification though?

@tenplus1
Copy link
Contributor

Could you re-open this as a working alternative.

As I noted previously, this PR doesn't work either. I think a lot more is needed to fix it properly.

How so ? I've been using this on Xanadu and signs work fine.

@OgelGames
Copy link
Contributor

How so ? I've been using this on Xanadu and signs work fine.

It doesn't fix the out-of-bounds errors when the text overflows past the edge of the sign.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix fixes a bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

out-of-bounds combine textures
7 participants