Whining about "shaders" being impractical.

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
Geti
Party member
Posts: 112
Joined: Tue Oct 20, 2009 6:38 am

Whining about "shaders" being impractical.

Post by Geti »

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 :D
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 :P

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

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.
User avatar
Fruchthieb
Prole
Posts: 20
Joined: Sat Sep 26, 2009 12:04 pm
Location: austria

Re: Whining about "shaders" being impractical.

Post by Fruchthieb »

Hey Geti,

I tried it here under Linux, Laptop, DualCore 2*2,3GHz, NVidia Geforce 9300m GS. Standard Hardware, i guess.
I got ca. 1FPS.

The same problem worried me some time ago. I thought about two answers:

First: Implementing shaders in C++, i dont know, if that really reduces CPU cost, i think it does not, since taking the screenshot forces the cpu down.
(Nevertheless: improve the löve engine itself should be a possibility)

Second: Dont take a screenshot, but using a layer, which you transform by a "shader". Main problem here is, that most of effects you cannot implement.

Until now i havent tried neither the former nor the latter. I dont have that much time at the moment and it has no priority for my little game.

Hope i can help, regards, Fruchthieb
User avatar
rhezalouis
Party member
Posts: 100
Joined: Mon Dec 07, 2009 10:27 am
Location: Indonesia
Contact:

[Response]Wow

Post by rhezalouis »

--===Spec===--
  • WinVista
  • Intel Core2Duo T7300 @ 2.00GHz
  • Mobile Intel(R) 965 Express Chipset Family 358MB
  • 3062MB RAM
--===Result===--
2 - 3 FPS
--===Average Execution Time===--
1.32 second per function call (deviation +/- 4.2%)
[40 sample @ timeLab1.5]

wow, that'd be a creepy shader! :o
Aargh, I am wasting my posts! My citizenshiiiip... :o
Geti
Party member
Posts: 112
Joined: Tue Oct 20, 2009 6:38 am

Re: Whining about "shaders" being impractical.

Post by Geti »

Hahah, exactly. The fact that all it does is mosaic the image is unsettling, I'm pretty sure it's the screenshot function that kills the FPS.
A much faster way to access the screen buffer for modification would be awesome.. mapPixel looks really powerful for this, but while we can't do anything with the screenbuffer there isn't any real way of doing stuff like this, which is a bit of a pity. It'd be such cool functionality ^^
User avatar
Fruchthieb
Prole
Posts: 20
Joined: Sat Sep 26, 2009 12:04 pm
Location: austria

Re: Whining about "shaders" being impractical.

Post by Fruchthieb »

Hey Geti,

no, it is not (only) the screenshot function. It is the traverse of the whole picture, and setting every pixel, which kills the FPS.

Regards...
Geti
Party member
Posts: 112
Joined: Tue Oct 20, 2009 6:38 am

Re: Whining about "shaders" being impractical.

Post by Geti »

No, it's the screenshot function. Just putting that into the program drops the FPS to almost the same level as the whole shader function. mapPixel isn't a very slow function comparatively :\
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 54 guests