Pixel Effect

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.
User avatar
cgrossi
Prole
Posts: 21
Joined: Fri May 24, 2013 6:08 pm
Location: Brazil

Pixel Effect

Post 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!!
Code games. You'll have fun!
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Pixel Effect

Post 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.
Help us help you: attach a .love.
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Pixel Effect

Post 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 ;).
User avatar
cgrossi
Prole
Posts: 21
Joined: Fri May 24, 2013 6:08 pm
Location: Brazil

Re: Pixel Effect

Post by cgrossi »

Thank you, Robin.

I'll take a look at the thread...
Code games. You'll have fun!
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Pixel Effect

Post 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.
Help us help you: attach a .love.
User avatar
veethree
Inner party member
Posts: 877
Joined: Sat Dec 10, 2011 7:18 pm

Re: Pixel Effect

Post 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.
User avatar
Ref
Party member
Posts: 702
Joined: Wed May 02, 2012 11:05 pm

Re: Pixel Effect

Post 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.
Attachments
rect.love
colored rounded rectangle
(1.36 KiB) Downloaded 167 times
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: Pixel Effect

Post 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.
Automatik
Citizen
Posts: 57
Joined: Sun Feb 17, 2013 7:05 pm

Re: Pixel Effect

Post 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.)
User avatar
slime
Solid Snayke
Posts: 3166
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: Pixel Effect

Post 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
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot], Google [Bot] and 11 guests