Whining about "shaders" being impractical.
Posted: Sun May 02, 2010 12:29 pm
Right, so anjo's just told me about this awesome thing called love.graphics.newScreenshot(), which gets the current screen's imagedata. I was very exited, as i figured this meant we could use mapPixel() to have awesome shaders and the like
Sadly, the performance of newScreenshot() is terrible on this computer, so i wanted to see how practical it would be for use on everyone else's computer, and if it was related to the fact that this computer has 64MB VRAM in it
What I ask is that you require that somewhere, and then run shader() at the end of your draw callback and report the effect on your FPS. obvious it isn't a very pretty shader at the moment, but more to the point it's simple. I think the main bottleneck is love.graphics.newScreenshot(), but if that runs a lot faster on computers with newer GPUs then it's a moot point.
so yeah, some results would be lovely, to see if it's worth developing a shader feature for ilopocalypse at all.
Sadly, the performance of newScreenshot() is terrible on this computer, so i wanted to see how practical it would be for use on everyone else's computer, and if it was related to the fact that this computer has 64MB VRAM in it
Code: Select all
function getcolours(image,x,y,p)
if x-1 > 0 and x+1 < 639 and y-1>0 and y+1 < 479 then
r1,g1,b1 = image:getPixel(x+p[1],y)
r2,g2,b2 = image:getPixel(x,y)
r3,g3,b3 = image:getPixel(x+p[1],y+p[2])
r4,g4,b4 = image:getPixel(x,y+p[2])
r = (r1+r2+r3+r4)/4
g = (g1+g2+g3+g4)/4
b = (b1+b2+b3+b4)/4
return r,g,b
else return image:getPixel(x,y) end
end
function shadermap(x, y, r, g, b, a)
--get the position relative to the pixel's chunk
if math.floor(x/2) == x/2 then
--rightmost
if math.ceil(y/2) == y/2 then
--bottom
r,g,b = getcolours(shot,x,y,{-1,-1})
else
--top
r,g,b = getcolours(shot,x,y,{-1,1})
end
else
--leftmost
if math.ceil(y/2) == y/2 then
--bottom
r,g,b = getcolours(shot,x,y,{1,-1})
else
--top
r,g,b = getcolours(shot,x,y,{1,1})
end
end
return r, g, b, a
end
function shader()
shot = love.graphics.newScreenshot( )
shot:mapPixel(shadermap)
shot = love.graphics.newImage(shot)
love.graphics.draw(shot,0,0)
end
so yeah, some results would be lovely, to see if it's worth developing a shader feature for ilopocalypse at all.