PixelEffect vs MapPixel (a cry for pixeleffect enlightenmen)

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
User avatar
timmeh42
Citizen
Posts: 90
Joined: Wed Mar 07, 2012 7:32 pm
Location: Cape Town, South Africa

PixelEffect vs MapPixel (a cry for pixeleffect enlightenmen)

Post by timmeh42 » Thu Mar 15, 2012 3:13 pm

I'm currently trying to take a greyscale image and turn it into pure black and white every draw event.

Idon't know much about the way I should do this, but I think it should either be done by drawing to a framebuffer (or canvas), getting the framebuffer's imagedata, and then using a MapPixel function on the image data. This seems to be the easier method, as the color values are easy to manipulate, but I need to perform the mapping every draw event, and imagedata (or making a new image from it) specifically says that this isn't a good idea.

The second option seems to be using löve 0.8.0 and using PixelEffect, which appears to be much more speed-friendly. However, the wiki shows next to nothing on how to use these.

Therefore, could someone in the know please provide me (and other rookies) with some help or enlightenment on how to use PixelEffect?

User avatar
kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

Re: PixelEffect vs MapPixel (a cry for pixeleffect enlighten

Post by kikito » Thu Mar 15, 2012 3:34 pm

timmeh42 wrote: turn it into pure black and white every draw event.
Can't you store the black and white version somewhere, and just calculate it once, instead of on every draw event?
When I write def I mean function.

User avatar
timmeh42
Citizen
Posts: 90
Joined: Wed Mar 07, 2012 7:32 pm
Location: Cape Town, South Africa

Re: PixelEffect vs MapPixel (a cry for pixeleffect enlighten

Post by timmeh42 » Thu Mar 15, 2012 3:53 pm

Unfortunately not as the image (image? canvas? dunno what to call it) is dynamic; also, this isn't for merely a cosmetic effect as its used as an alpha mask for another image or texture.
I have already achieved the effect in GameMaker, but it used a rather hack-ish way (repeated drawing with a "dodge" blend mode as far as I remember), and I wanted to port it to Löve.
Last edited by timmeh42 on Thu Mar 15, 2012 6:39 pm, edited 1 time in total.

User avatar
richapple
Citizen
Posts: 65
Joined: Sun Dec 25, 2011 10:25 am

Re: PixelEffect vs MapPixel (a cry for pixeleffect enlighten

Post by richapple » Thu Mar 15, 2012 6:11 pm

I didn't know anything about pixeleffects too, but then found this thread:
Share a shader!

I have to say it's a great thread with very good examples! I learned quite much about shaders even though I knew nothing.

User avatar
timmeh42
Citizen
Posts: 90
Joined: Wed Mar 07, 2012 7:32 pm
Location: Cape Town, South Africa

Re: PixelEffect vs MapPixel (a cry for pixeleffect enlighten

Post by timmeh42 » Thu Mar 15, 2012 6:46 pm

Ah thanks very much. Didn't find it when i searched because I searched for the wrong terms...
On the other hand, oh poop. One of the shaders does exactly what I intended, and better (the metaballs one). Oh well ^^

Post Reply

Who is online

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