Pixel-perfect in LÖVE

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
User avatar
kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

Pixel-perfect in LÖVE

Post by kikito »

I know that we can use the "nearest" filter to make images look more "pixely", but since LÖVE uses a combination of OpenGL and a variable dt, if you only use nearest you get "pixel deformations".

This is not uncommon. Unity has the same problem. There is a plugin called pixel-perfect which seems to address this. Here's its video:



From what I can tell, it does three things:

* It forces drawing images to integer coords (or maybe at integer+0.5 coords)
* It forces the camera translation to move in integer (or integer+0.5) increments
* It only allows pixel-proportional zooms in the camera. You can do x2, x4, etc. But no x1.75. And no rotations.

I am thinking about implementing something similar for LÖVE. You guys think I am missing anything, other than the 3 things I listed? I ask because the interface shown on that video seems to have lots of controls and stuff.
When I write def I mean function.
User avatar
N88
Prole
Posts: 10
Joined: Sat May 23, 2015 10:31 pm

Re: Pixel-perfect in LÖVE

Post by N88 »

I don't think you're missing anything. Actually there are not much settings for the pixel-perfect plugin in the gui shown in the video, EDIT: I think the pixel per unit value is how many pixels long is one space unit in unity world, perhaps?. I tried Unity just yesterday and it seems game objects have each a components stack. Will need more time to play with Unity to understand it better.
Also, some kind of pixel scaling + fullscreen fitting would be nice to have - every time you look at badly scaled pixels one pixel artist dies.
User avatar
Evine
Citizen
Posts: 72
Joined: Wed May 28, 2014 11:46 pm

Re: Pixel-perfect in LÖVE

Post by Evine »

Something like this? Instead of flooring the coordinates.
Edit:

Code: Select all

-- This Might be what you want, never in between a pixel
function pixelPerfectScale(pos,scale)
	return math.floor(0.5+pos/scale)*scale
end
Also you could just draw to an unscaled canvas. Then scale the canvas to the screen.

Code: Select all

--Wrong
function pixelPerfectScale(pos,scale)
	return math.floor(0.5+pos*scale)/scale
end
Artal, A .PSD loader: https://github.com/EvineDev/Artal
User avatar
Fenrir
Party member
Posts: 222
Joined: Wed Nov 27, 2013 9:44 am
Contact:

Re: Pixel-perfect in LÖVE

Post by Fenrir »

I considered working on something similar for my current project, but finally as we went for a "blurry" render I think it's not necessary, but I still would be curious to see it in action! :)
User avatar
T-Bone
Inner party member
Posts: 1492
Joined: Thu Jun 09, 2011 9:03 am

Re: Pixel-perfect in LÖVE

Post by T-Bone »

I second Evine's approach. With a canvas, you can easily rescale the whole image, pad with black bars etc. to get it to run on anything, while keeping the pixelated feel. It really guarantees that you're not doing anything wrong. You can still do rotations and scaling, and get all the lovely mode7-like artifacts.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest