Problem with scaling?

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
OmarShehata
Party member
Posts: 259
Joined: Tue May 29, 2012 6:46 pm
Location: Egypt
Contact:

Problem with scaling?

Post by OmarShehata »

Ok so, I've got a little problem with scaling. I'm not sure whether this is due to the algorithm Love/SDL uses to scale objects or if it's something on my end.

Basically I have this wire that I stretch. In the game, the longer I stretch it, the more I see the ends being transparent.

Here's how it looks in the engine:

Image


Here's how it should look:

Image

Any idea how Love handles scaling or why this happens?

In my render function:

Code: Select all

love.graphics.draw(self.sprite,self.x,self.y,self.angle,self.scaleX,self.scaleY);
User avatar
Boolsheet
Inner party member
Posts: 780
Joined: Wed Dec 29, 2010 4:57 am
Location: Switzerland

Re: Problem with scaling?

Post by Boolsheet »

Well, that's a bit odd. You can test if it's the linear filter and set it to nearest neighbor: Image:setFilter("nearest", "nearest"). If that "fixes" it, then it might be the neighboring pixel bleeding in... but that doesn't make sense if it's a 50x1, unless you have OpenGL 1.x without the non-power-of-two extension. In that case, it would pad the image to 64x2, however, that should look different than what you showed us. Edit: This is probably not correct.

I'm not sure... Can you produce a small test case that shows the same behaviour?
Shallow indentations.
User avatar
kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

Re: Problem with scaling?

Post by kikito »

Are you drawing something semi-transparent somewhere else?

I'm asking because you could have left a love.graphics.setColor(255,255,255,100) somewhere. Try setting the color to 255,255,255 right before drawing the image.

If that doesn't do it, upload the image you are using to the forum, so others can try it out.
When I write def I mean function.
User avatar
xelu
Prole
Posts: 9
Joined: Mon Jun 25, 2012 12:27 pm
Location: Romania
Contact:

Re: Problem with scaling?

Post by xelu »

Hey, I'm the artist on this project and jsut wanted to point out (Omar forgot to mention)

The 50x1 pixels cable asset is part of a spritesheet , and it's surrounded by transparent pixels
That's another reason why bicubic\bipolar scaling might be a factor.

We'll try with Nearest neighbor soon

Thanks :D
User avatar
Boolsheet
Inner party member
Posts: 780
Joined: Wed Dec 29, 2010 4:57 am
Location: Switzerland

Re: Problem with scaling?

Post by Boolsheet »

xelu wrote:The 50x1 pixels cable asset is part of a spritesheet , and it's surrounded by transparent pixels
That's another reason why bicubic\bipolar scaling might be a factor.
Oh yeah, that's it. Pad the border with the color of neighboring pixel instead of transparent ones. That means that you'll need 2 pixel between the sprites on the sheet, but it will ensure that it interpolates the colors as expected.
Shallow indentations.
User avatar
xelu
Prole
Posts: 9
Joined: Mon Jun 25, 2012 12:27 pm
Location: Romania
Contact:

Re: Problem with scaling?

Post by xelu »

@Boolsheet Thanks :D That solved it...

The thing was, i tried to surround it with same color pixels before manually.. and that fixed the problem but i didn't wanted to do this manually since I'm using this -http://www.codeandweb.com/texturepacker - Texture Packer to create the sprite sheets.

That would mean doing that procedure every time i make a change to the sprites.... So I thought this could be solved by code

But after taking a closer look I noticed the "Extrude" option in that program , that does exactly that... So this is a better way to solve this after all instead of trying to do the Nearest Neighbor thing code wise...

Thank again :D

We got beautiful wires now <3

Image
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot], Google [Bot] and 12 guests