### [EFFECT] GreyShade

Posted:

**Mon May 03, 2010 5:38 pm**EDIT: Mediafire seems to be down. I can't reach the server. Please be patient I hope the server will be up soon...

Edit 2: Maybe it's just my provider or a router on the way, I can sometimes reach it sometimes not. If you see the thumbnails, you can also download the effect...

[size=110:12yj6itf]

[/size:12yj6itf]

It depends. Maybe you will never need GreyShade, but its advantage is its flexibility. Converting colors to shades of grey is a process based on luminance weights and the assumption that a certain weight is the right one. I know of at least three different luminance weight models.

First, let's have a look at the original colors in this example. (All images are thumbnails, click to see a larger version)

One is simply called 1/3 weight and is used by Greyscale/Greyscale Plus. It evenly weights the luminance of all three color channels (Red, Green, Blue).

The formula is Y' = 0.333R' + 0.333G' + 0.333B'

This is what it looks like.

Another one is used by NTSC & PAL/SECAM & JPEG, and it weights the green channel almost double as high as the red channel and more than five times higher than the blue channel.

The formula is Y' = 0.299R' + 0.587G' + 0.114B'

This is what it looks like.

The third one I know of is used by Photoshop and I can't reproduce it with an effect because it is a three-pass-model and effects in Construct need to be one-pass. The model takes into account the monitors gamma working space and weights green almost ten times higher than blue and more than three times higher than red. After a transformation into linear Gamma = 1, the formula is

Y = 0.2126R'^2.2 + 0.7152G'^2.2 + 0.0724B'^2.2

R' = G' = B' = Y^(1/2.2)

With GreyShade you can even do more. You can weight one channel dominant setting the others to zero. You may overload every value getting over-saturated colors, hard falloffs etc. Look at these two examples.

[size=110:12yj6itf]

There are four values you can alter at any time.

Red Luminance Weight (Weight the luminance of the red channel as float)

Green Luminance Weight (Weight the luminance of the green channel as float)

Blue Luminance Weight (Weight the luminance of the blue channel as float)

Intensity (The amount that is merged to the original as a percentage)

If you want to keep the original luminance, just make sure the three weights are positive values and sum up to 1 (one). But remember you may also use extreme values outside of this range, like -2.5 or 17. Also the intensity may be set to values like 178% or -342%

[size=110:12yj6itf]

Download GreyShade.fx and put it in the effects folder of Construct. You may also want to download the demo cap, that allows you to play around with different values.

GreyShade.fx

greyshade.cap

Edit 2: Maybe it's just my provider or a router on the way, I can sometimes reach it sometimes not. If you see the thumbnails, you can also download the effect...

[size=110:12yj6itf]

**"Hey, there already exists Greyscale/GreyscalePlus, why do we need another grey shader?"**[/size:12yj6itf]

It depends. Maybe you will never need GreyShade, but its advantage is its flexibility. Converting colors to shades of grey is a process based on luminance weights and the assumption that a certain weight is the right one. I know of at least three different luminance weight models.

First, let's have a look at the original colors in this example. (All images are thumbnails, click to see a larger version)

One is simply called 1/3 weight and is used by Greyscale/Greyscale Plus. It evenly weights the luminance of all three color channels (Red, Green, Blue).

The formula is Y' = 0.333R' + 0.333G' + 0.333B'

This is what it looks like.

Another one is used by NTSC & PAL/SECAM & JPEG, and it weights the green channel almost double as high as the red channel and more than five times higher than the blue channel.

The formula is Y' = 0.299R' + 0.587G' + 0.114B'

This is what it looks like.

The third one I know of is used by Photoshop and I can't reproduce it with an effect because it is a three-pass-model and effects in Construct need to be one-pass. The model takes into account the monitors gamma working space and weights green almost ten times higher than blue and more than three times higher than red. After a transformation into linear Gamma = 1, the formula is

Y = 0.2126R'^2.2 + 0.7152G'^2.2 + 0.0724B'^2.2

R' = G' = B' = Y^(1/2.2)

With GreyShade you can even do more. You can weight one channel dominant setting the others to zero. You may overload every value getting over-saturated colors, hard falloffs etc. Look at these two examples.

[size=110:12yj6itf]

**How to use it**[/size:12yj6itf]There are four values you can alter at any time.

Red Luminance Weight (Weight the luminance of the red channel as float)

Green Luminance Weight (Weight the luminance of the green channel as float)

Blue Luminance Weight (Weight the luminance of the blue channel as float)

Intensity (The amount that is merged to the original as a percentage)

If you want to keep the original luminance, just make sure the three weights are positive values and sum up to 1 (one). But remember you may also use extreme values outside of this range, like -2.5 or 17. Also the intensity may be set to values like 178% or -342%

[size=110:12yj6itf]

**Installation**[/size:12yj6itf]Download GreyShade.fx and put it in the effects folder of Construct. You may also want to download the demo cap, that allows you to play around with different values.

GreyShade.fx

greyshade.cap