Page 1 of 2

Pixel Effect

Posted: Sat Jun 22, 2013 7:47 pm
by cgrossi
Hi, guys!!

I can't understand pixel effect!! How does it work? How do I code it?!?!? Can someone give me some tips?!

Thanks!!

Re: Pixel Effect

Posted: Sat Jun 22, 2013 7:55 pm
by Robin
You'll find many examples in the Share a Shader thread. I recommend starting at the end of the thread, rather than at the beginning, because it might be that not all of them work with the current version of LÖVE. (It's been alive for two years, which is pretty long for a thread.)

You can run them, see what they do (if you don't see anything, just try the next one), and then look at the code, try to understand them. If that doesn't help, there are probably enough people here who know some tutorial or manual or something.

Re: Pixel Effect

Posted: Sat Jun 22, 2013 8:13 pm
by bartbes
Robin wrote:because it might be that not all of them work with the current version of LÖVE.
PixelEffects were only added in 0.8.0 ;).

Re: Pixel Effect

Posted: Sat Jun 22, 2013 8:49 pm
by cgrossi
Thank you, Robin.

I'll take a look at the thread...

Re: Pixel Effect

Posted: Sat Jun 22, 2013 9:17 pm
by Robin
bartbes wrote:PixelEffects were only added in 0.8.0 ;).
Oh, right. I was confused because the thread started before 0.8.0 was released (and people where already enthusiastically writing shaders).

So I guess it doesn't matter much then, if the only problem is going to be that some of them will error (for pushing 'q' rather than 'quit') when you press escape.

Re: Pixel Effect

Posted: Sat Jun 22, 2013 10:58 pm
by veethree
Here's some links that may have some information on shaders for you.

First a couple pages from the wiki:
https://www.love2d.org/wiki/love.graphi ... ixelEffect
https://www.love2d.org/wiki/love.graphi ... ixelEffect (this one contains a simple example)

And here's the reference for GLSL, Which is the language that you write shaders with, With a few changes explained in one of the links above.
http://www.opengl.org/sdk/docs/manglsl/

But in my opinion the best place to learn is the share a shader thread, Tons of examples there.

Re: Pixel Effect

Posted: Tue Jun 25, 2013 4:30 pm
by Ref
Ah!
The black art of GLSL!
Learn by fiddling with other people's Shaders - really a painful way to learn something.
Just look at what I had to do through just to be able to control the background and foreground colors.

Re: Pixel Effect

Posted: Tue Jun 25, 2013 7:24 pm
by raidho36
You shouldn't render with shaders, it breaks GPU rendering pipeline and results in ineffective rendering, from all perspectives.

You only should use them to alter the picture, like you can apply a bump map to the sprite, or a parallax map which gives some degree of 3d effect out of plain 2d sprite. Blur and complex color effects also goes here, anything such. If you feel you need to change sprite pixel color via some function, you use shaders.

Re: Pixel Effect

Posted: Tue Jun 25, 2013 7:37 pm
by Automatik
it breaks GPU rendering pipeline and results in ineffective rendering, from all perspectives.
How does it break anything?
From all perspectives, using a shader use a GPU. From all perspectives, a GPU is fast.(Ok, drawing directly the rectangle is also done with the GPU.)
I mean, I made a mandelbrot fractal viewer with a shader. While it's slow, It would be even slower if I did with any other method.(Except magic, of course.)
http://hastebin.com/xihobuxogo.lua (The goal was to have the smallest file possible while still being understandable.)

Re: Pixel Effect

Posted: Tue Jun 25, 2013 7:43 pm
by slime
raidho36 wrote:You shouldn't render with shaders, it breaks GPU rendering pipeline and results in ineffective rendering, from all perspectives.

You only should use them to alter the picture, like you can apply a bump map to the sprite, or a parallax map which gives some degree of 3d effect out of plain 2d sprite. Blur and complex color effects also goes here, anything such. If you feel you need to change sprite pixel color via some function, you use shaders.
I'm not really sure what you mean by this - all pixel shaders do is tell the GPU what color the resulting fragment should be, based on some input data. There's no real distinction between "altering the picture" and "rendering with shaders", as far as the GPU is concerned. It just runs the shader code and uses the result.

Here's a simplified diagram of the old (pre-tessellation shader) GPU pipeline. The extremely old fixed-functionality pipeline is usually reproduced by the driver creating its own shaders.

Image