-
-
Notifications
You must be signed in to change notification settings - Fork 21.6k
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
Allow disabling the alpha trim on texture atlas creation. #57163
Allow disabling the alpha trim on texture atlas creation. #57163
Conversation
582cb86
to
e224b4c
Compare
This PR doesn't really fix that, it only allows to force the |
I understand your point. Maybe "fix" isnt the right word. But they are related and this PR implements that user's suggestion: "I suggest is godot trims transparent pixels from texture, need option to generate atlas as is with transparent pixels." Also, would checking 'crop_to_region' also avoid the error that that user pointed out? |
I just meant #53390 shouldn't be auto-closed by merging this PR (currently it will be because you wrote "Fixes #53390") as it doesn't fix the issue with the current state of things. But it's not a big deal, I guess another more specific issue could be open if that one gets closed (actually maybe I'll open one later anyway as there are more problems with the current implementation of
Yes, as with that option generated Actually, didn't think about it earlier but with your addition the |
Okay. I updated the comment to not say Fixes. Whats the point of Crop To Region? Should it just be removed? What's the use case for having it checked and unchecked? How does Crop To Region differ between Region and Mesh type import? |
I mean I can gather as much info as you, have to look at the relevant PRs / proposals / code. 😉
Take a look at godotengine/godot-proposals#1661
Looking at the code, it's used only in Region mode. |
Thanks for the link. So you want to see this as an enum where you either have Trim and Crop, Trim and Dont Crop or Dont Trim ? |
Yeah, something like that. Just not sure if that's clear what does what so it should probably be somehow explained somewhere. Also note that would be a breaking change so introducing such enum instead is probably not an option for |
Good point. So maybe this is okay like this for 3.x ? |
I highly support this suggestion, as it can alleviate the user-defined code's overhead in retrieving the images by considering region and margin. While the current default setting of stripping out the transparent pixels seems to have a very low optimization effect on memory, it can be still an option. Overall I think one of the main usability problems with the Atlas Texture is that the user has very small control on the very step of creating one (just a few options when importing selected images as Atlas Texture), while it generates a lot of unnecessary data later on, hard to maintain and work with. |
This PR has 'breaks compat' tag on it, but I dont think this does break compat since the default behaviour is to keep the trimming. |
Rect2 used_rect = image->get_used_rect(); | ||
Rect2 used_rect = Rect2(0, 0, image->get_width(), image->get_height()); | ||
if (trim_alpha_border_from_region) { | ||
//clip a region from the image |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While at it, the comment style could be improved too:
//clip a region from the image | |
// Clip a region from the image. |
Default to true
e224b4c
to
31d723c
Compare
Thanks! |
When creating an AtlasTexture, godot automatically removes unused pixels from the borders of the images. This is unexpected behaviour that changes the size of the texture. In general, if a developer asks for a texture of a specific size with transparent pixels in it, that's what the developer should get. Changing the size and contents of the texture can cause a plethora of issues.
For our project, this broke all of our styleboxes, as they had region's specified which were invalid because the size of the texture changes.
This PR creates an option for AtlasTexture importers to allow developers to enable the trim on transparent pixels on the borders. It defaults to Off, which I think is better, more expected behaviour. [ Edit - now it default to On to maintain compatibility ]
Related: #53390
3.x version #57165