Forum

Black & white

hi people!
i’m doing some vjing for tomorow and i would like to transform my textures (*.png) to black & white, any suggestions? i’m wandering if pixel shader could do the thing, i’m on radeon 7500 so i’m not wery it to it in practise. maybe freeframe…
well any suggestion is welcome!

did’nt try new beta yet, but when i’m finished with my egzames there will be a plenty of time for it… :( —> :)
(implication of emotions! cant get that booles algebra out of my mind…)

vedran

hi Vedran
Of course pixelshader can do it
The actual template code is :

float4 PS(vs2ps In): COLOR
{
//In.TexCd = In.TexCd / In.TexCd.w;
// for perpective texture projections (e.g. shadow maps) ps_2_0

float4 col = tex2D(Samp, In.TexCd);
return col;

}

just add

col = {( (1,1,1) - col.rgb),col.a};
before the return col >>

float4 PS(vs2ps In): COLOR
{
//In.TexCd = In.TexCd / In.TexCd.w;
// for perpective texture projections (e.g. shadow maps) ps_2_0

float4 col = tex2D(Samp, In.TexCd);
return col = {( (1,1,1) - col.rgb),col.a};

}
should works

sanch post an inversion, converting to bw is just like this:

col.rgb = (col.r + col.g + col.b)/3;
return col;

grz

yeah, i´m stupid , it s late, i have to sleep now
by the way you can use color transform for change the hue , saturation…
hsl(transform)
you just have to multiply the color with the transformation color
like : col = mul(col,tCol);

yes, the HSL (Transform) node is more flexible in this case, you can do a lot more stuff than just make the picture black and white …

yes. HSL (Transform) is best and most flexible!

just to be more intelligent then my bench mates:

tonfilm wrote:
col.rgb = (col.r + col.g + col.b)/3;

more accurate is this:
col.rgb = length( col.rgb ) / sqrt(3);

think of rgb color space as a cube ranging from 0,0,0 to 1,1,1.

so it makes sense to think of a color as if it would be a vector.
if you take the length of the vector, you have something like the brightness.
however the maximal length is sqrt(1² + 1² + 1²). (pythagoras)
so you have to divide through this to get a maximum of 1 for white…

however, because red, green and blue channels have different intensities it is more complicated.

the HSL (Transform) handles all these details. Just choose “Preserve Luminance” at the “Luminance Adaption”-pin and everything is handled for you.

maybe check out the help patch for this node. it also tries to explain colors as vectors in a color cube…

good night,
sebastian

to add to gregsns excellent summary: in professional video and image processing, black and white conversion is usually handled with the following formula:

col.rgb = (0.299* col.r) + (0.587* col.g) + (0.114*col.b)

it takes into account that the the primary colors have vastly different perceived brightness. a 100% blue looks much darker on the screen as a 100% green. if you just calculate the average of all color informations, colored images will look slightly wrong in black and white. the magic numbers above were determined by many experiments with human observers,

for static textures you could even try:
select FileTexture in the inspektor and then choose a suitable textureformat. for me L16 does the trick and loads avery image in black and white. not sure if L16 is available on all graficcards though.

good luck.

joreg: not sure if L16 is available on all graficcards though.
it’s working for me!

but the code is not!
don’t know why, i’ve just copy and paste the code that sanch wrote…
i’m realy interested in this stuff so if someone could help me with this one i’ll be great!

could this be a problem?
Techniques:
0 - Name: TSimpleShader, Passes: 1, validated on current hardware: 0
1 - Name: TFixedFunction, Passes: 1, validated on current hardware: 1

have to buy a new hardware…
vedran

last line from sanch should look like this:

return float4( float3(1,1,1) - col.rgb, col.a);

just copy this line into your code, if you take the whole function body you have to use the template from the new version …