Rendering issue

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
User avatar
mr_happy
Citizen
Posts: 84
Joined: Fri Mar 18, 2016 8:57 pm

Rendering issue

Post by mr_happy »

Why does one edge of my, er, 'player' sprite (the green cube) sometimes display a white line alone one diagonal, whereas at other times is doesn't. There's only one place in the program where the image is drawn so it's not something I'm doing in code.
Screenshot at 2018-05-12 18-40-05.png
Screenshot at 2018-05-12 18-40-05.png (207.71 KiB) Viewed 2485 times
Screenshot at 2018-05-12 18-40-59.png
Screenshot at 2018-05-12 18-40-59.png (103.02 KiB) Viewed 2485 times
grump
Party member
Posts: 947
Joined: Sat Jul 22, 2017 7:43 pm

Re: Rendering issue

Post by grump »

Drawing the sprite at non-integer coords?
User avatar
mr_happy
Citizen
Posts: 84
Joined: Fri Mar 18, 2016 8:57 pm

Re: Rendering issue

Post by mr_happy »

grump wrote: Sat May 12, 2018 7:53 pm Drawing the sprite at non-integer coords?
Yes indeed; if I use ints everything is fine. I just read this [1], which sort of explains it - the fix is certainly easy enough. I think my understanding of how/where images are drawn is flawed - I was expecting draw() to place the image at the nearest integer position by default so x,y of 100.3, 100.1 would draw at 100,100 whereas 100.7, 100.1 would draw at 101, 100. Thanks for the clue anyway :D

[1] viewtopic.php?t=79661
User avatar
pgimeno
Party member
Posts: 3548
Joined: Sun Oct 18, 2015 2:58 pm

Re: Rendering issue

Post by pgimeno »

mr_happy wrote: Sun May 13, 2018 7:04 am I think my understanding of how/where images are drawn is flawed - I was expecting draw() to place the image at the nearest integer position by default so x,y of 100.3, 100.1 would draw at 100,100 whereas 100.7, 100.1 would draw at 101, 100. Thanks for the clue anyway :D
I don't think it was flawed, assuming you used the nearest filter. The problem typically shows up around n + 0.5 (e.g. 100.5), because due to rounding errors and floating point precision, some numbers are rounded up and some others are rounded down, and that discrepancy causes the visual artifacts.
User avatar
mr_happy
Citizen
Posts: 84
Joined: Fri Mar 18, 2016 8:57 pm

Re: Rendering issue

Post by mr_happy »

Thanks pgimeno, it just seems odd that the artefact is a 'white' line... I'd expect some sort of dithering of the black edge. No matter, easy enough to fix ;)
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 34 guests