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

NinePatch changes texture scale when resized #33225

Closed
shmellyorc opened this issue Nov 1, 2019 · 22 comments
Closed

NinePatch changes texture scale when resized #33225

shmellyorc opened this issue Nov 1, 2019 · 22 comments

Comments

@shmellyorc
Copy link

shmellyorc commented Nov 1, 2019

Godot version:
Godot 3.2 Alpha 3 (from your website)

OS/device including version:
Windows 10

Issue description:
When doing pixelated texture, resizing the Ninepatch changes its scale.

Steps to reproduce:

  1. Add a pixelated nine patch frame
  2. Set up the patch margins
  3. resize the nine patch in the editor.

Minimal reproduction project:
https://i.imgur.com/VeQeuhQ.gifv

Notes: Godot 3.2 alpha 1 doesn't have this issue. Anything past alpha 1 has this issue.

@clayjohn
Copy link
Member

clayjohn commented Nov 1, 2019

CC @puthre maybe related to your PR?

@puthre
Copy link
Contributor

puthre commented Nov 1, 2019

@shmellyorc you'll have to have your ninepatch texture resolution smaller than what you will have on screen otherwise it will get scaled down. Previously (before #32170) it would just be distorted (but you wouldn't have seen that in your example as the margins in your example are the same everywhere).

@akien-mga
Copy link
Member

So that's not a regression but a bugfix?

@clayjohn clayjohn added the cherrypick:3.x Considered for cherry-picking into a future 3.x release label Jan 13, 2020
@clayjohn clayjohn removed this from the 3.2 milestone Jan 13, 2020
@Shadowblitz16
Copy link

Shadowblitz16 commented Jan 20, 2020

@puthre both scaling down and distortion is considered a bug when it comes to how 9 slices should work.

if the 9 slice is smaller then the texture it should start clipping starting with the center, then the edges, then the corners until it is completely invisible with a size of 0,0

@puthre
Copy link
Contributor

puthre commented Jan 20, 2020

@Shadowblitz16 I don't think I understand your proposal (or as I understand it it would not look very good except with some hand picked use cases). The main reason for my fix as far as I remember was that you could not use the 9 patch frame at all in Stretch Mode = 2D mode where your viewport size is can be much lower than the actual resolution of the device (which happens when you deploy on a mobile device) and you need to have textures much larger than the size of the viewport to match that screen resolution. Before my fix it didn't even distorted in the same way with GLES2 and GLES3.
If you don't want it to scale, just provide a smaller texture.

@Shadowblitz16
Copy link

Shadowblitz16 commented Jan 21, 2020

No this is horrible for pixel art we shouldn't have to modify our textures because someone decided to change how 9 patches have always worked.

if anything it should be a flag or a project setting to scale down these things.
you basically just broke everyone's projects that relied on these.

this is kinda why I get angry is because some person comes along and instead of just fixing the problem they do something that doesn't make sense or breaks backwards compatibility

9 slices are there to prevent the edges from being warped there is no point in them if they don't do this.

if you need to scale these things, implement a way to scale the canvas or the scale the 9slice.

@akien-mga
Copy link
Member

@Shadowblitz16 While I can understand your frustration, I'll have to ask you to remain civil and avoid using making things personal. You may disagree with the change, but you shouldn't express anger, especially not against other community members. https://godotengine.org/code-of-conduct

@akien-mga
Copy link
Member

Can anyone provide a reproduction project so that we can see what works and what doesn't?

@puthre
Copy link
Contributor

puthre commented Jan 21, 2020

@akien-mga Here is one
nine-patch.tar.gz
Try both with gles2 and gles3 as they have different implementation (gles3 is implemented in a shader).

@naturally-intelligent
Copy link

naturally-intelligent commented May 7, 2020

Also having this issue with a broken downscaling after upgrading to Godot 3.2.1

It's nice there is a workaround for now, but I agree this is a bug/regression because NinePatches should never scale their corners (at least without some kind of flag allowing it set by the dev).

@Lucrecious
Copy link

@naturally-intelligent What exactly is the work around here? I've been stuck on how to fix this for hours...

@puthre
Copy link
Contributor

puthre commented May 10, 2020

@Lucrecious Scale your texture down to be smaller than the resolution of the patch on screen.

@naturally-intelligent
Copy link

Not scale - I think you mean to edit your 9P textures to have less stretch than the biggest use.

@Lucrecious
Copy link

@puthre @naturally-intelligent
Sorry, I feel very dumb, but I literally don't understand what you guys are saying.

I don't know what "less stretch than the biggest use" means or "scale your texture to be smaller than the resolution of the patch".

Would it be possible for either one of you to provide a concrete example using actual numbers? An example that starts from a 9P that down scales and ends with it being fixed? Doesn't have to be a Godot file, just some text.

@puthre
Copy link
Contributor

puthre commented May 12, 2020

@Lucrecious The nine patch margins will only stretch down if it can't fit in the small space you allocate to it on screen (small relative to the patch texture resolution). Just try to scale down the image texture that you are using for the nine patch (using gimp or something similar) and you will see what I mean.

@shmellyorc
Copy link
Author

in 3.0, the textures wouldnt stretch (wouldnt change scale). The corners and the ninepatch would stop to the size of the corners. Ever past 3.0, I have to make very small textures.

@naturally-intelligent
Copy link

naturally-intelligent commented May 22, 2020

@naturally-intelligent What exactly is the work around here? I've been stuck on how to fix this for hours...

If you look at this tutorial image:

https://tekeye.uk/android/examples/ui/android-9-patch-image-files

You will have to make middle sections 2,4,5,6, and 8 very small (ex: 1x1 pixel), while your corners (1,3,7,9) can be any size.

I spent the better part of a day in frustration thinking this was my fault, until I found this thread, so I feel your pain...

@mischiefaaron
Copy link

Confirmed that GLES2 implementation for tiling axis stretching doesn't work.
It looks identical to stretched mode as if it is the same option or acts the same.
This forces me to use GLES3 if I want to have my program's nine patches appear correctly.
I would much prefer keep using GLES2 for the wider compatibility.

@akien-mga akien-mga added this to the 3.2 milestone Oct 21, 2020
@akien-mga akien-mga removed the cherrypick:3.x Considered for cherry-picking into a future 3.x release label Oct 21, 2020
@akien-mga
Copy link
Member

Fixed by #42119.

@RPicster
Copy link
Contributor

RPicster commented Apr 5, 2021

Hello, this issue is still alive and kicking. It's not fixed by the mentioned commit.
Having the issue in GLES3 in 3.3RC7

@akien-mga
Copy link
Member

There are two nine patch modes, which one are you using? It would likely be better to open a new issue with full details on the issue as you experience it in recent build.

@RPicster
Copy link
Contributor

RPicster commented Apr 5, 2021

I tried it with different modes, settings Nodes and the problem was always the same - I will open a new issue!

Demindiro added a commit to Demindiro/OwnWar that referenced this issue Jul 12, 2021
See godotengine/godot#33225 for details
(Basically: backwards compatibility got broken and ninepatchrect scales
the corners down instead of just the middle/edges)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

10 participants