blending/compositing whithout programmable shaders


    Sep 09 2006 | 8:25 pm
    Hi y'all,
    I'm having quite of pickle... i designed a video mixer using my GPU and everything works pretty well. I composed my video using jit.gl.slab objects and the nice array of included shaders, but now i'm porting my prototype to the pc it should be run on while performing, since that graphics card is quite better than the one on my laptop (on which i designed the patch)
    Well here comes the issue. since the graphics card on the pc is somewhat older, it does not support programmable shaders... seen afterwards, kinda stupid of me not to think of that earlier but hey... at least i'm learning.
    Now, is there a way to mix/blend/compose several movie (on a videoplane preferably) using only the GPU? U see, I don't wonna use the jit.op since that deliver's a readback to a jit.matrix... using the CPU. And this all slows down the patch too much. I definitely need my CPU cycles elsewhere!...
    I already tried out using the blend_enable parameter of the OB3D group, but this didn't deliver the pixing as i would like...
    Any help would be much appreciated, since i'm a little shy in time to get even some simple mixing to work...
    thanks in advance!

    • Sep 09 2006 | 8:31 pm
      You can do this using the @blend_mode attribute and 2 videplanes with @depth_enable 0 @blend_enable 1. See the OpenGL spec or the jitter opengl HTML doc for more info on this.
      wes
      On 9/9/06, david wrote: > > Hi y'all, > > I'm having quite of pickle... i designed a video mixer using my GPU and everything works pretty well. I composed my video using jit.gl.slab objects and the nice array of included shaders, but now i'm porting my prototype to the pc it should be run on while performing, since that graphics card is quite better than the one on my laptop (on which i designed the patch) > > Well here comes the issue. since the graphics card on the pc is somewhat older, it does not support programmable shaders... seen afterwards, kinda stupid of me not to think of that earlier but hey... at least i'm learning. > > Now, is there a way to mix/blend/compose several movie (on a videoplane preferably) using only the GPU? > U see, I don't wonna use the jit.op since that deliver's a readback to a jit.matrix... using the CPU. And this all slows down the patch too much. I definitely need my CPU cycles elsewhere!... > > I already tried out using the blend_enable parameter of the OB3D group, but this didn't deliver the pixing as i would like... > > Any help would be much appreciated, since i'm a little shy in time to get even some simple mixing to work... > > thanks in advance! >
    • Sep 09 2006 | 8:48 pm
      Hi,
      thanks for your quick reply! but umm... i don't get it to work. i'm not really seeing where i should insert the alpha value that should be used for blending...
      below i inserted a simple patch containing two movies an o a plane, if someone could be so nice to check where i'm missing. that would be superb.
      A link to the << jitter opengl HTML reference -unless u mean the Gl group page from the jitter object reference- >> or any other information about this would be great too.
      thanks a lot d
    • Sep 09 2006 | 9:00 pm
      Hi David, There were a few problems with your patch. First You had 2 blend_mode attributes and each ojnly had 1 value. @blend_mode takes 2 values. Also, you need to enable blending with @blend_enable 1. Here are the blend_mode from the docs:
      The source and destination planes associated with the blend mode (default = 6 7) Blend modes are specified in the form src_blend_mode dst_blend_mode. The supported modes are: 0 = zero 1 = one 2 = destination color 3 = source color 4 = one minus destination color 5 = one minus source color 6 = source alpha 7 = one minus source alpha 8 = destination alpha 9 = one minus destination alpha 10 = source alpha saturate
      For info on exactly what there mean, look for the OpenGL Red Book. You can view it as HTML online or download a PDF of it.
      Here's a modified patch:
      wes
    • Sep 09 2006 | 9:15 pm
      Thanks! pretty dumb mistakes indeed... but still, i'm a bit puzzled about how i can adapt the 'channel/plane' used for blending so that i can implement some kind of crossfade between the two movies by manipulating the 'channel/plane' in question.
      Anyhoo, I downloaded the red book and i'll start reading straight away... cuz i really need to get this -probably basic functionality - to work... (actually it was sitting here on my harddisk for quite some time, but just didnt get around to it...)
    • Sep 09 2006 | 9:21 pm
      On 9/9/06, david wrote: > > Thanks! pretty dumb mistakes indeed... but still, i'm a bit puzzled about how i can adapt the 'channel/plane' used for blending so that i can implement some kind of crossfade between the two movies by manipulating the 'channel/plane' in question. >
      For alpha blending, the alpha based blend modes will probably be your best bet.
      wes
    • Sep 11 2006 | 1:03 pm
      I've had to work in the same situation, with an older graphics card. However, I have 4 separate images and 4 separate alpha channels, all of which eventually blend together seamlessly. I use jit.op. Some operators are faster than others, so it works. Maybe I was in a hurry, but I did not see a way to handle multi-step compositing with GL just using blend and alpha settings. How would I pipe the results of one composite to another? By capturing the resulting texture map?
      Here is the tree of operations, with "x" representing a composite (though in actual practice I use both logical and arithmetic operations based on what I know of the geometry of the images and alphas):
      image1 x alpha1 image2 x alpha2 image3 x alpha3 image4 x alpha4 composite11 x composite 22 composite33 x composite44 composite1122 x composite3344 final image
      Could this be done with older GPUs using blend and alpha--and be done faster than with jit.op on the CPU?
      -- Paul
      On 9/9/06, Wesley Smith wrote: > On 9/9/06, david wrote: > > > > Thanks! pretty dumb mistakes indeed... but still, i'm a bit puzzled about how i can adapt the 'channel/plane' used for blending so that i can implement some kind of crossfade between the two movies by manipulating the 'channel/plane' in question. > > > > For alpha blending, the alpha based blend modes will probably be your best bet. > > wes >
      -- ----- |(*,+,#,=)(#,=,*,+)(=,#,+,*)(+,*,=,#)| -----
    • Sep 12 2006 | 2:58 pm
      Hi Paul,
      I'm afraid i'm not really getting the tree of operations you're trying to depict in your post, but below i've pasted a patch wich shows the technique i'm using now.
      This uses the alpha blend modes of the videoplanes ( 6 and 7 ), while i fill in the alphaplane of my movie myself. if you constructed any alphaplanes in your previous patch u could easily fill them in into the patch below. My guess is this could result in better performance since the if you're really just doing alpha blending with jit.op...
      One thing i didnt get out yet is the drawing order of the planes. Sometimes the rightmost plane is on top, sometimes the leftmost is. I guess i can control this myself by adding the @automatic 0 attribute to the videoplane and bang them myself whenever i want them to be drawn.
      anyhoo, u'll see what u can do.
      btw, if anyone has a straightforward example of drawing orders, that would be nice too :)
      greetz david