Page 1 of 1
Problem with scaling?
Posted: Mon Oct 01, 2012 8:23 pm
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:
Here's how it should look:
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);
Re: Problem with scaling?
Posted: Mon Oct 01, 2012 9:20 pm
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?
Re: Problem with scaling?
Posted: Mon Oct 01, 2012 10:18 pm
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.
Re: Problem with scaling?
Posted: Mon Oct 01, 2012 10:23 pm
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
Re: Problem with scaling?
Posted: Mon Oct 01, 2012 11:25 pm
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.
Re: Problem with scaling?
Posted: Tue Oct 02, 2012 12:16 am
by xelu
@Boolsheet Thanks
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
We got beautiful wires now <3