Multi-Pass Shader on camera in real-time

Hi @RJ5,

For a “monotone over greyscale” effect, have you experimented with either the “colorMatrix” or “colorPolynomial” filters? One of these might give you a reasonably close effect, but I’m not overly familiar with how the coefficient table will affect your live feed.

Brent

Hi Brent

Unfortunately these 2 effects will create colour images (which I’m not wanting)

I’m looking to create a similar effect to that of using coloured filters in black and white photography

In black and white photography you use different coloured filters to ensure that objects of different colours are separated and clearly defined. So for e.g. you would use a red filter to make all the blue objects in a scene increase in contrast (blue skies turn black). The final image is still in b&w, but the contrast of the blacks and the whites has shifted.

Hence my reason for wanting to combine monotone and greyscale. (works fine on static images just not on the live feed)

Hi @RJ5,

Can you give me a link to (or post) some examples of what the image should look like? As in, what they’d look like for a B&W photo with a red filter applied?

Brent

Hi Brent Here’s a link to a article on using coloured filters in black and white photographyhttp://www.photographymad.com/pages/view/using-coloured-filters-in-black-and-white-photography

Hi @RJ5,

Thanks for the link, I’ve done quite a bit of color photography in my day (and used some color filters in some cases) but I’ve not done any B&W. I can ask the engineers if multi-pass can be added to the live camera feed, or why it might not be supported in specific.

I wonder if you might try putting the contents of the camera feed into a snapshot, then applying a multi-pass to that?

Brent

P.S. - Out of curiosity, have you tested single-pass filters on the live feed on an actual iOS device? Some filters can hit the GPU harder than others, especially if applied on an object which must update every frame (i.e. the live camera feed).

Hi Brent

I grew up on B&W photography, it was easy to develop yourself and was loads cheaper than colour. 

When you say single-pass filter do you mean this method??

display.setDrawMode( "forceRender" ) local x = display.contentCenterX local y = display.contentCenterY local image = display.newRect( x, y, display.contentWidth, display.contentHeight ) image.fill = { type = "camera" } image.fill.effect = "filter.grayscale"

if so, then it works no problem at all.

Multi-pass also works no problem at all on a static image, it just won’t work on a live feed.

Unfortunately I can’t take a snapshot of the camera feed and multi-pass that as I need the user to be able to live edit the feed and view in real-time the changes that they are making. The only way I can see to do it with the snapshot method is to have it set up in an enterFrame event (taking 30/60 snapshots of the feed every second) , but surely there would be performance issues with that??

You might want to test out the snapshot method, with a Runtime event essentially “invalidating” (refreshing) the snapshot every so often. But first, make sure that your multi-pass filter works as expected on a snapshot, before trying to make that snapshot update with the camera feed. :slight_smile: