How to determine GPU with Alpha-Channel?



  • Hi All!!

    Is there is someone who know how to detect that GPU stream consists  alpha-Channel? 
    I need change mode projector blending mode to transparent for all transparent/partically-transparent GPU-streams.
    Thanks in advance.

  • Tech Staff

    I can't think of any prebuilt actors that can offer you this feature.

    The only thought I have, is that a GLSL shader could be used to strip away the RGB video values, and leave only the Alpha.
    Then the 'calc brightness' actor could be used to determine if there are alpha values, and how much.
    I haven't seen a shader that does this, although I would think this would be a rather simple shader.


  • Thanks, DusX !

    As I've understand, you suggest to use Shader to calculate Alpha-brightness? Good idea!
    I'll try this and post here if it will be successful.
    Do you mean Isadora doesnt have any build-in actors to isolate alpha-channel? 

  • Tech Staff

    @Mikhail

    Exactly. There are no built-in actors to isolate alpha (correct me please if I am wrong).
    A Shader may be a good option for adding this feature.
    Since shaders are expected to output video, simply output the alpha as a black and white video, then use the 'calc brightness' actor to give you a numerical reading.
    Please let me know if you succeed...


  • Dear @Mikhail + All,

    Good idea Ryan. Here's the shader code to strip out RGB and give you only alpha. Then you could use the CalcBrightness actor after the GLSL Shader actor. If the brightness ever goes below 100, then there is alpha.
    Best Wishes,
    Mark

    uniform float time;

    uniform vec2 mouse;

    uniform vec2 resolution;

    uniform sampler2D tex0;

    void main(void) {

    vec4 c0 = texture2D(tex0, gl_TexCoord[0].xy);

    gl_FragColor = vec4(1.0, c0.a, c0.a, c0.a);

    }



  • @ mark @Mikhail

    If a you want a B&W representation of alpha layer (not red and white), the code is this one (c0.a also in red layer)

    uniform float time;

    uniform vec2 mouse;

    uniform vec2 resolution;

    uniform sampler2D tex0;

    void main(void) {

    vec4 c0 = texture2D(tex0, gl_TexCoord[0].xy);

    gl_FragColor = vec4(c0.a, c0.a, c0.a, c0.a);

    }

    Best wishes,

    Jacques


  • Tech Staff

    @mark @jhoepffner

    Thanks!! I can make use of this as well.  :)

    Does this warrant a KB article?



  • @jhoepffner - Mine made black and white? It was just not transparent. Yes? (Slightly confused by your addition and the mention of red.)



  • @mark

    When I use yours on film with alpha mask, the mask is in red (not in black).
    Because you wright "gl_FragColor = vec4(1.0, c0.a, c0.a, c0.a);" with 1.0 in red value
    The value of the alpha mask is not important now, because you dont use it anymore so you can write "gl_FragColor = vec4(c0.a, c0.a, c0.a, c0.a);" or "gl_FragColor = vec4(c0.a, c0.a, c0.a, 0.0);"
    I join a patch with the result with your proposition and my correction
    All the best,
    Jacques

    1fbc29-markproposition.jpg 8f9419-jacquesproposition.jpg b38e88-testalpha02.izz


  • Tech Staff

    I just got to testing this method today.. and its perfect!



  • To : [DusX](http://troikatronix.com/troikatronixforum/profile/149/DusX) , [jhoepffner](http://troikatronix.com/troikatronixforum/profile/15/jhoepffner) , [mark](http://troikatronix.com/troikatronixforum/profile/2/mark) , Wow! Thanks Guys! You're cool!
    A lot of thanks! I try to use this shader also in my patch.

Log in to reply
 

Looks like your connection to TroikaTronix Community Forum was lost, please wait while we try to reconnect.