Sprite pixel on the bottom left are glitched

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
User avatar
NegiMox
Prole
Posts: 6
Joined: Mon Apr 06, 2020 9:00 am
Contact:

Sprite pixel on the bottom left are glitched

Post by NegiMox »

Heya everybody,Iam new to LUA and also LOVE today i was creating new sprites but it showed some wired unwanted pixels on the bottom left corner.
This is the glitch which appears when i add love.graphics.setDefaultFilter('nearest','nearest').
with "love.graphics.setDefaultFilter('nearest','nearest')"
with "love.graphics.setDefaultFilter('nearest','nearest')"
Untitled.png (20.59 KiB) Viewed 7593 times
This is without love.graphics.setDefaultFilter('nearest','nearest').
without "love.graphics.setDefaultFilter('nearest','nearest')"
without "love.graphics.setDefaultFilter('nearest','nearest')"
ads.png (35.88 KiB) Viewed 7593 times
This is the code:

Code: Select all

push = require 'push'

WINDOW_WIDTH = 1280
WINDOW_HEIGHT = 720

VIRTUAL_WIDTH =512
VIRTUAL_HEIGHT = 288

local background = love.graphics.newImage('background.png')
local backScroll =0
local BACKGROUND_SCROLL_SPEED = 20
local BACKGROUND_LOPPING_POINT = 413 


local ground = love.graphics.newImage('ground.png')
local groundScroll = 0
local GROUND_SCROLL_SPEED = 60

function love.load()
  --love.graphics.setDefaultFilter('nearest','nearest')
   love.window.setTitle('Bad Bird')

push:setupScreen(VIRTUAL_WIDTH,VIRTUAL_HEIGHT,WINDOW_WIDTH,WINDOW_HEIGHT,{
     vsync = true,
     fullscreen = false,
     resizeable = true
   })
end

function love.resize(w,h)
	push:resize(w,h)
	-- body
end

function love.keypressed(key)

	if key == 'escape' then
		love.event.quit()
    end
end

function love.update(dt)
	backScroll = (backScroll+ BACKGROUND_SCROLL_SPEED * dt)	 % BACKGROUND_LOPPING_POINT
	--To perform the reset of the pos of the background we use %
    groundScroll = (groundScroll + GROUND_SCROLL_SPEED * dt)  % VIRTUAL_WIDTH

end

function love.draw()
	push:start()

    love.graphics.draw(background,-backScroll,0)

    love.graphics.draw(ground,-groundScroll,VIRTUAL_HEIGHT-16)  

	push:finish()
end
User avatar
steVeRoll
Party member
Posts: 139
Joined: Sun Feb 14, 2016 1:13 pm

Re: Sprite pixel on the bottom left are glitched

Post by steVeRoll »

In your drawing code, try putting the coordinates in the math.floor function.

Also, in the future, please ask questions in the Support and Development forum.
User avatar
NegiMox
Prole
Posts: 6
Joined: Mon Apr 06, 2020 9:00 am
Contact:

Re: Sprite pixel on the bottom left are glitched

Post by NegiMox »

I tried doing it,like this
function love.draw()
push:start()

love.graphics.draw(background, -backgroundScroll, 0)

gStateMachine:render()
love.graphics.draw(ground, math.floor(-groundScroll), math.floor(VIRTUAL_HEIGHT - 16))

push:finish()
end"
But still the same problem.
(For further post i will add them in Support)
User avatar
pgimeno
Party member
Posts: 3657
Joined: Sun Oct 18, 2015 2:58 pm

Re: Sprite pixel on the bottom left are glitched

Post by pgimeno »

It may help if you post something we can run and check ourselves. With just the code we can't run the program. A .love file would be great.
User avatar
NegiMox
Prole
Posts: 6
Joined: Mon Apr 06, 2020 9:00 am
Contact:

Re: Sprite pixel on the bottom left are glitched

Post by NegiMox »

This is made in LOVE 0.10.0
Here it is:
game.love
"Game"
(754.07 KiB) Downloaded 555 times
User avatar
pgimeno
Party member
Posts: 3657
Joined: Sun Oct 18, 2015 2:58 pm

Re: Sprite pixel on the bottom left are glitched

Post by pgimeno »

Thanks.

Hmm, I can't see the glitch at all. It may depend on your GL drivers.

The cause for this is usually that the coordinates of a pixel are close to 0.5. OpenGL uses fast float math and that screws up some things; in this case, rounding is not always consistent and these issues appear, and it can even vary from driver to driver.

The issue seems to be located at the diagonal of the quad, which supports the idea that the driver is to blame.
Attachments
Quad-glitch.png
Quad-glitch.png (3.3 KiB) Viewed 7442 times
User avatar
NegiMox
Prole
Posts: 6
Joined: Mon Apr 06, 2020 9:00 am
Contact:

Re: Sprite pixel on the bottom left are glitched

Post by NegiMox »

Oh ok,i will try updating my drivers.Btw thanks for helping me.
Post Reply

Who is online

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