I'm one of the many who loves nice chunky pixel art, and as we know, filters are the enemy. I know we can use (Image):setFilter to turn this off for image scaling, but I'd love it if Framebuffer could also do this. In other engines I like to render everything to a small framebuffer and then blow it up 2x with no filtering to get nice crisp aliasing. but alas, Framebuffer always applies a linear filter.
Anyone know of a way to do this? Even if I could somehow convert a Framebuffer to an Image (so I could change the filters to 'nearest'), I'd be happy for now, but I couldn't figure out how to do that either. If there's no way to do it, consider this a feature request!
Other than that, just got into LOVE a few days ago and am really loving it!
'nearest' filter for Framebuffer scaling?
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
- kikito
- Inner party member
- Posts: 3153
- Joined: Sat Oct 03, 2009 5:22 pm
- Location: Madrid, Spain
- Contact:
Re: 'nearest' filter for Framebuffer scaling?
Hi there, welcome!
I haven't used framebuffers myself yet, but by reading the wiki, it seems that love.graphics.newImage with the framebuffer's imagedata will work:
I haven't used framebuffers myself yet, but by reading the wiki, it seems that love.graphics.newImage with the framebuffer's imagedata will work:
Code: Select all
local fb = ... -- your framebuffer
local image = love.graphics.newImage(fb:getImageData())
When I write def I mean function.
Re: 'nearest' filter for Framebuffer scaling?
Wouldn't this lead to memory hell if it is in the draw function?kikito wrote:Hi there, welcome!
I haven't used framebuffers myself yet, but by reading the wiki, it seems that love.graphics.newImage with the framebuffer's imagedata will work:
Code: Select all
local fb = ... -- your framebuffer local image = love.graphics.newImage(fb:getImageData())
Re: 'nearest' filter for Framebuffer scaling?
Creating an ImageData of a Framebuffer is a rather expensive operation. If you do it every frame, you will notice a framerate drop.
Luckily, a framebuffer is not required to scale up the whole scene: Use love.graphics.scale(2,2) and set the filter to 'nearest' on every image. You can do the latter automatically by overwriting love.graphics.newImage:
Luckily, a framebuffer is not required to scale up the whole scene: Use love.graphics.scale(2,2) and set the filter to 'nearest' on every image. You can do the latter automatically by overwriting love.graphics.newImage:
Code: Select all
local __newImage = love.graphics.newImage -- old function
function love.graphics.newImage(...) -- new function that sets nearest filter
local img = __newImage(...) -- call old function with all arguments to this function
img:setFilter('linear', 'nearest')
return img
end
Re: 'nearest' filter for Framebuffer scaling?
Yes, it does. I tried that, and the application quickly sucked up all the available memory.adrix89 wrote:Wouldn't this lead to memory hell if it is in the draw function?
Unfortunately, this doesn't work very well if some of the images get scaled, as the individual scaling does not adhere to the "global" scaling defined with love.graphics.scale(2,2). This results in differently sized pixels which looks rather ugly. Also, any particle effects ignore the scaling.vrld wrote:Use love.graphics.scale(2,2) and set the filter to 'nearest' on every image.
Putting everything into a frame buffer and scaling it up right before drawing is a bit more elegant, I think. If there were a way to set the frame buffer's filter mode, I'd use it as well. There is a feature request in the tracker: https://bitbucket.org/rude/love/issue/1 ... lter-modes
Who is online
Users browsing this forum: Ahrefs [Bot] and 5 guests