Page 1 of 1

Cam11 bug when zoom = 0.6 (specifically)

Posted: Mon Oct 23, 2023 11:11 am
by togFox
So I've been a fan of cam11 for a long time but I've noticed something I've never bothered digging into. This line:

Code: Select all

cam:setZoom(0.6)
fails to draw lines - at all.

Any zoom works well but 0.6 (60%) precisely won't draw:

Code: Select all

love.graphics.line
love.graphics.circle("line")
love.graphics.rectangle("line")
but it will draw "fill" objects. It is odd and it is bizarre but is exactly zoom 0.60. See love file attached. This is repeatable on my Windows OS and on Gvovkiv Linux OS.

Run the love file with the console open, use the mouse wheel to change the zoom. Zoom to 0.60 and watch the magic.

Any clues?

Image

============

Image

Re: Cam11 bug when zoom = 0.6 (specifically)

Posted: Mon Oct 23, 2023 4:11 pm
by pgimeno
It's not a bug of cam11. Try this as main.lua:

Code: Select all

function love.draw()
    love.graphics.scale(0.6)

    love.graphics.circle("fill", 100, 200, 10)
    love.graphics.circle("line", 200, 200, 10)

    love.graphics.rectangle("fill", 300, 190, 20, 20)
    love.graphics.rectangle("line", 400, 190, 20, 20)

    love.graphics.line(100, 250, 410, 250)
end
Comment out the love.graphics.scale(0.6) to see the difference.

I don't know if this is fixed in Löve 12. Perhaps it's worth posting a bug report in the issue tracker if it annoys you.

Re: Cam11 bug when zoom = 0.6 (specifically)

Posted: Mon Oct 23, 2023 6:44 pm
by slime
What do you expect a line with less than 1 pixel width that's not centered at the middle of pixels to look like in a pixel grid?

If you offset the line's position by (0.5, 0.5), then the centers of each end will be at the center of a pixel instead of in between 4 pixels.

Re: Cam11 bug when zoom = 0.6 (specifically)

Posted: Tue Oct 24, 2023 12:06 pm
by pgimeno
slime wrote: Mon Oct 23, 2023 6:44 pm What do you expect a line with less than 1 pixel width that's not centered at the middle of pixels to look like in a pixel grid?

If you offset the line's position by (0.5, 0.5), then the centers of each end will be at the center of a pixel instead of in between 4 pixels.
But what about the circle?

Re: Cam11 bug when zoom = 0.6 (specifically)

Posted: Tue Oct 24, 2023 8:25 pm
by slime
pgimeno wrote: Tue Oct 24, 2023 12:06 pm But what about the circle?
It's using a line width that's smaller than 1, which is rarely going to give you a fully visible line.

The technical details for why it's entirely invisible have to do with the smooth line style's implementation reducing the core line width in order for the surrounding outer antialiasing line to not appear super thick. An implementation of line antialiasing that uses a completely different technique (like shader-based AA) might not have that behaviour. But regardless of which implementation is used, a line width that's less than 1 won't give you a fully visible fully opaque line because you've told it to be less than 1 pixel thick.