Forums > Jitter

fade to black in uyvy mode (in openGL) ?

February 5, 2008 | 3:10 pm

sorry if this is obvious, i am tryin figure the best and less costy method to achieve this :
i want to be able to fade movies to black when sending them into a compositing slab;
[jit.op @op * @val 0.] will (obviously) give a green background instead of black in uyvy mode, even after reconversion to rgba.
if i understand well how the operation shaders work they need two textures ; a "@val" attribute or "param val" does not really exist , which means in order to fade a movie to black i need to multiply it with a second texture being a black matrix , which i d like to avoid .

i am aware of Vade’s fader shader , which does the job perfectly , i am just curious about an internal solution .
am i missing something ?

example here :

#P outlet 579 492 15 0;
#P inlet 579 381 15 0;
#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P message 735 427 112 196617 param color 0. 0. 0. 1.;
#P flonum 661 382 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P message 661 401 57 196617 amount $1;
#P newex 649 426 76 196617 prepend param;
#P newex 633 455 182 196617 jit.gl.slab obama @file v001.fader.jxs;
#B color 14;
#P window linecount 3;
#P comment 1121 315 169 196617 send a black matrix in rightmost inlet ? wouldnt it b too costy on bigger resolutions ?;
#P window linecount 1;
#P comment 1121 300 100 196617 @val attribute ?;
#P comment 1122 282 242 196617 op.mult.jxs takes two textures in order to work (?);
#P window setfont "Sans Serif" 12.;
#P window linecount 3;
#P comment 1023 263 15 196620 ???;
#B frgb 248 0 157;
#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P comment 260 264 203 196617 this obviously does not work in UYVY mode;
#B frgb 248 0 157;
#P newex 955 281 164 196617 jit.gl.slab obama @file op.mult.jxs;
#P newex 512 178 30 196617 t b b;
#P newex 560 356 331 196617 jit.gl.slab obama @file cc.uyvy2rgba.jxs @automatic 0 @dimscale 2. 1.;
#P flonum 845 260 35 9 0. 1. 3 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 190 356 331 196617 jit.gl.slab obama @file cc.uyvy2rgba.jxs @automatic 0 @dimscale 2. 1.;
#P flonum 475 260 35 9 0. 1. 3 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 192 723 232 196617 jit.window obama @size 640 480 @depthbuffer 1;
#P newex 10 98 209 196617 jit.gl.render obama @erase_color 0. 0. 0. 1.;
#P newex 10 71 133 196617 t b b erase;
#P newex 10 45 51 196617 qmetro 2;
#P message 342 421 23 196617 0.5;
#P toggle 325 421 15 0;
#P flonum 325 446 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 560 285 295 196617 jit.op @op * @val 1.;
#P message 583 178 83 196617 read dishes.mov;
#P newex 560 206 238 196617 jit.qt.movie @adapt 1 @unique 1 @colormode uyvy;
#P newex 190 285 295 196617 jit.op @op * @val 0.;
#P message 325 464 88 196617 param amount $1;
#P window setfont "Sans Serif" 12.;
#P window linecount 2;
#P newex 190 507 380 196620 jit.gl.slab obama @file co.normal.jxs @param amount 0.5 @automatic 0;
#P objectname jit.gl.slab;
#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P newex 124 140 66 196617 t b b b b b;
#P newex 190 682 350 196617 jit.gl.videoplane obama @automatic 0 @transform_reset 2 @blend_enable 1;
#P message 213 178 80 196617 read dozer.mov;
#P newex 190 206 238 196617 jit.qt.movie @adapt 1 @unique 1 @colormode uyvy;
#P user jit.fpsgui 10 120 60 196617 0;
#P toggle 10 26 15 0;
#P user panel 112 251 1144 71;
#X brgb 255 255 255;
#X frgb 94 255 43;
#X border 3;
#X rounded 0;
#X shadow 0;
#X done;
#P window linecount 2;
#P comment 835 456 157 196617 vade’s shader works great , just curious about another solution;
#P connect 2 0 17 0;
#P fasten 17 0 18 0 15 66 15 66;
#P fasten 18 2 19 0 137 93 15 93;
#P connect 18 0 19 0;
#P connect 19 0 3 0;
#P connect 18 1 7 0;
#P connect 7 3 4 0;
#P fasten 5 0 4 0 218 199 195 199;
#P connect 4 0 10 0;
#P connect 10 0 22 0;
#P connect 7 2 22 0;
#P connect 22 0 8 0;
#P connect 9 0 8 0;
#P connect 7 1 8 0;
#P connect 8 0 6 0;
#P connect 7 0 6 0;
#P connect 15 0 14 0;
#P connect 16 0 14 0;
#P connect 14 0 9 0;
#P connect 21 0 10 1;
#P fasten 7 4 25 0 185 164 517 164;
#P connect 25 1 11 0;
#P fasten 12 0 11 0 588 197 565 197;
#P connect 11 0 13 0;
#P connect 25 0 24 0;
#P connect 13 0 24 0;
#P connect 24 0 8 1;
#P connect 32 0 38 0;
#P connect 37 0 32 0;
#P connect 33 0 32 0;
#P connect 36 0 32 0;
#P fasten 34 0 33 0 666 422 654 422;
#P connect 35 0 34 0;
#P connect 23 0 13 1;
#P window clipboard copycount 39;


February 5, 2008 | 3:25 pm

if you dont want to use my shader ( *cries in a corner all alone* ),
then you should be able to use the op math shaders included with
jitter from cycling to multiply just like jit.op @op *, and you’d but
that slab before your compositing shader to fade the individual
channels or after to fade the whole composited output.

:)

On Feb 5, 2008, at 10:10 AM, karl-otto von oertzen wrote:

>
> sorry if this is obvious, i am tryin figure the best and less costy
> method to achieve this :
> i want to be able to fade movies to black when sending them into a
> compositing slab;
> [jit.op @op * @val 0.] will (obviously) give a green background
> instead of black in uyvy mode, even after reconversion to rgba.
> if i understand well how the operation shaders work they need two
> textures ; a "@val" attribute or "param val" does not really exist ,
> which means in order to fade a movie to black i need to multiply it
> with a second texture being a black matrix , which i d like to
> avoid .
>
> i am aware of Vade’s fader shader , which does the job perfectly , i
> am just curious about an internal solution .
> am i missing something ?
>
> example here :
>
>
> #P outlet 579 492 15 0;
> #P inlet 579 381 15 0;
> #P window setfont "Sans Serif" 9.;
> #P window linecount 1;
> #P message 735 427 112 196617 param color 0. 0. 0. 1.;
> #P flonum 661 382 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
> #P message 661 401 57 196617 amount $1;
> #P newex 649 426 76 196617 prepend param;
> #P newex 633 455 182 196617 jit.gl.slab obama @file v001.fader.jxs;
> #B color 14;
> #P window linecount 3;
> #P comment 1121 315 169 196617 send a black matrix in rightmost
> inlet ? wouldnt it b too costy on bigger resolutions ?;
> #P window linecount 1;
> #P comment 1121 300 100 196617 @val attribute ?;
> #P comment 1122 282 242 196617 op.mult.jxs takes two textures in
> order to work (?);
> #P window setfont "Sans Serif" 12.;
> #P window linecount 3;
> #P comment 1023 263 15 196620 ???;
> #B frgb 248 0 157;
> #P window setfont "Sans Serif" 9.;
> #P window linecount 1;
> #P comment 260 264 203 196617 this obviously does not work in UYVY
> mode;
> #B frgb 248 0 157;
> #P newex 955 281 164 196617 jit.gl.slab obama @file op.mult.jxs;
> #P newex 512 178 30 196617 t b b;
> #P newex 560 356 331 196617 jit.gl.slab obama @file cc.uyvy2rgba.jxs
> @automatic 0 @dimscale 2. 1.;
> #P flonum 845 260 35 9 0. 1. 3 3 0 0 0 221 221 221 222 222 222 0 0 0;
> #P newex 190 356 331 196617 jit.gl.slab obama @file cc.uyvy2rgba.jxs
> @automatic 0 @dimscale 2. 1.;
> #P flonum 475 260 35 9 0. 1. 3 3 0 0 0 221 221 221 222 222 222 0 0 0;
> #P newex 192 723 232 196617 jit.window obama @size 640 480
> @depthbuffer 1;
> #P newex 10 98 209 196617 jit.gl.render obama @erase_color 0. 0. 0.
> 1.;
> #P newex 10 71 133 196617 t b b erase;
> #P newex 10 45 51 196617 qmetro 2;
> #P message 342 421 23 196617 0.5;
> #P toggle 325 421 15 0;
> #P flonum 325 446 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
> #P newex 560 285 295 196617 jit.op @op * @val 1.;
> #P message 583 178 83 196617 read dishes.mov;
> #P newex 560 206 238 196617 jit.qt.movie @adapt 1 @unique 1
> @colormode uyvy;
> #P newex 190 285 295 196617 jit.op @op * @val 0.;
> #P message 325 464 88 196617 param amount $1;
> #P window setfont "Sans Serif" 12.;
> #P window linecount 2;
> #P newex 190 507 380 196620 jit.gl.slab obama @file co.normal.jxs
> @param amount 0.5 @automatic 0;
> #P objectname jit.gl.slab;
> #P window setfont "Sans Serif" 9.;
> #P window linecount 1;
> #P newex 124 140 66 196617 t b b b b b;
> #P newex 190 682 350 196617 jit.gl.videoplane obama @automatic 0
> @transform_reset 2 @blend_enable 1;
> #P message 213 178 80 196617 read dozer.mov;
> #P newex 190 206 238 196617 jit.qt.movie @adapt 1 @unique 1
> @colormode uyvy;
> #P user jit.fpsgui 10 120 60 196617 0;
> #P toggle 10 26 15 0;
> #P user panel 112 251 1144 71;
> #X brgb 255 255 255;
> #X frgb 94 255 43;
> #X border 3;
> #X rounded 0;
> #X shadow 0;
> #X done;
> #P window linecount 2;
> #P comment 835 456 157 196617 vade’s shader works great , just
> curious about another solution;
> #P connect 2 0 17 0;
> #P fasten 17 0 18 0 15 66 15 66;
> #P fasten 18 2 19 0 137 93 15 93;
> #P connect 18 0 19 0;
> #P connect 19 0 3 0;
> #P connect 18 1 7 0;
> #P connect 7 3 4 0;
> #P fasten 5 0 4 0 218 199 195 199;
> #P connect 4 0 10 0;
> #P connect 10 0 22 0;
> #P connect 7 2 22 0;
> #P connect 22 0 8 0;
> #P connect 9 0 8 0;
> #P connect 7 1 8 0;
> #P connect 8 0 6 0;
> #P connect 7 0 6 0;
> #P connect 15 0 14 0;
> #P connect 16 0 14 0;
> #P connect 14 0 9 0;
> #P connect 21 0 10 1;
> #P fasten 7 4 25 0 185 164 517 164;
> #P connect 25 1 11 0;
> #P fasten 12 0 11 0 588 197 565 197;
> #P connect 11 0 13 0;
> #P connect 25 0 24 0;
> #P connect 13 0 24 0;
> #P connect 24 0 8 1;
> #P connect 32 0 38 0;
> #P connect 37 0 32 0;
> #P connect 33 0 32 0;
> #P connect 36 0 32 0;
> #P fasten 34 0 33 0 666 422 654 422;
> #P connect 35 0 34 0;
> #P connect 23 0 13 1;
> #P window clipboard copycount 39;
>
> –
> karrrlo
>


February 5, 2008 | 6:48 pm

On Feb 5, 2008, at 7:10 AM, karl-otto von oertzen wrote:

>
> sorry if this is obvious, i am tryin figure the best and less costy
> method to achieve this :
> i want to be able to fade movies to black when sending them into a
> compositing slab;
> [jit.op @op * @val 0.] will (obviously) give a green background
> instead of black in uyvy mode, even after reconversion to rgba.
> if i understand well how the operation shaders work they need two
> textures ; a "@val" attribute or "param val" does not really
> exist , which means in order to fade a movie to black i need to
> multiply it with a second texture being a black matrix , which i d
> like to avoid .
>
> i am aware of Vade’s fader shader , which does the job perfectly ,
> i am just curious about an internal solution .
> am i missing something ?

First of all, don’t overlook the fact that the cc.uyvy2rgba.jxs
shader has a "scale" param which can be used precisely to this extent
without another shader (it also has brightness/contrast/saturation
params which are applied in the YUV space, scale and bias params are
applied after the conversion to RGBA). So if you don’t need to do
this on the CPU, then that’s the approach I’d take (will be much
faster than doing on the CPU).

If you *do* need to perform this operation on the CPU, essentially
UYVY "black" is a zero value for the luminance channels and a 50%
value for the chrominance channels (since they are conceptually
signed values and 50% is their "zero" mark). This would be 127 0 127
0 (not considering "broadcast legal" stuff, where it would actually
be something like 127 16 127 16). Anyway, the easiest and fastest
thing to do is just use the built in parameters in the uyvy2rgba
shader, but if you have to do UYVY color processing on the CPU,
you’ll need to spend some time learning about what UYVY data is.

-Joshua


February 5, 2008 | 10:09 pm

thanks Vade and Joshua ,

please Vade dont cry , i love your shader(s) , use them quite a bit , i was just curious about other options and Joshua gave me clear perspectives ;)

thanks again

Quote: jkc wrote on Tue, 05 February 2008 19:48
—————————————————-
>
> On Feb 5, 2008, at 7:10 AM, karl-otto von oertzen wrote:
>
> >
> > sorry if this is obvious, i am tryin figure the best and less costy
> > method to achieve this :
> > i want to be able to fade movies to black when sending them into a
> > compositing slab;
> > [jit.op @op * @val 0.] will (obviously) give a green background
> > instead of black in uyvy mode, even after reconversion to rgba.
> > if i understand well how the operation shaders work they need two
> > textures ; a "@val" attribute or "param val" does not really
> > exist , which means in order to fade a movie to black i need to
> > multiply it with a second texture being a black matrix , which i d
> > like to avoid .
> >
> > i am aware of Vade’s fader shader , which does the job perfectly ,
> > i am just curious about an internal solution .
> > am i missing something ?
>
>
> First of all, don’t overlook the fact that the cc.uyvy2rgba.jxs
> shader has a "scale" param which can be used precisely to this extent
> without another shader (it also has brightness/contrast/saturation
> params which are applied in the YUV space, scale and bias params are
> applied after the conversion to RGBA). So if you don’t need to do
> this on the CPU, then that’s the approach I’d take (will be much
> faster than doing on the CPU).
>
> If you *do* need to perform this operation on the CPU, essentially
> UYVY "black" is a zero value for the luminance channels and a 50%
> value for the chrominance channels (since they are conceptually
> signed values and 50% is their "zero" mark). This would be 127 0 127
> 0 (not considering "broadcast legal" stuff, where it would actually
> be something like 127 16 127 16). Anyway, the easiest and fastest
> thing to do is just use the built in parameters in the uyvy2rgba
> shader, but if you have to do UYVY color processing on the CPU,
> you’ll need to spend some time learning about what UYVY data is.
>
> -Joshua
>
—————————————————-


September 25, 2010 | 7:26 pm

I’m trying to figure how to fade a uyvy video on the CPU. I tried to multiply the channels by 0.5, 0.06, 0.5, and 0.06 to obtain a result of 127, 0, 127, 0. But it doesn’t work.

Somebody can clarify that thing for me please?

Thanks a lot!

this is the patch:

– Pasted Max Patch, click to expand. –

September 29, 2010 | 7:47 pm

The patches uyvy-color-explorer.maxpat and uyvy-op-composite.maxpat in the examples helped me to solve my problem.


Viewing 6 posts - 1 through 6 (of 6 total)