[sharing] 2pass_transparency _ possible with jit.gl.node?

    Oct 03 2015 | 10:13 pm
    Here is an old patch (2008!!!) allowing 2 pass transparency with jit.gl.sketch. it's based on chapter 10 of openGL The nice feature is that it's able to render transparency and depth without having to z-sort the objects. ____ One application for the alpha test is to implement a transparency algorithm. Render your entire scene twice, the first time accepting only fragments with alpha values of one, and the second time accepting fragments with alpha values that aren't equal to one. Turn the depth buffer on during both passes, but disable depth buffer writing during the second pass. ____ Structuring the sketch commands is a bit complicate, so :
    Do you think this technique could be implemented with jit.gl.node and 2 capturing cameras for examples. mixing them after... or with shaders aplied to cameras...

    • Oct 05 2015 | 6:04 pm
      thanks for sharing. i've noted a feature request for incorporating something like this into jit.gl.node/camera capturing.
    • Oct 05 2015 | 8:15 pm
      Would be great to have it standart with capture.
      So you don't think it's impossible to simulate it with 2 cameras? Principally playing with : 1st : glalphafunc equal 1., glenable alpha_test, gldepthmask 1 2nd: glalphafunc less 1., gldepthmask 0
      is depth_write attribute = gldepthmask 1 I suppose glalphafunc equal 1. , is not accesible through attributes.
      The main problem with the sketch logic is that you have to maintain a list of all textures/objects you want to bang ( 2 times)
      Perhaps it's possible to emulate it with shaders, like my question in this other thread: https://cycling74.com/forums/jit-gl-pass-_-where-to-put-jxp-files-in-library/
      does gl_FragDepth make sense for managing through shader, how objects write the depth buffer? Do you have an example of a shader writing gl_FragColor and gl_FragDepth too a bit like : mrt.depth.jxs but for an obj3d with depth_write=0 and writing the depthbuffer by itself?
    • Oct 06 2015 | 5:15 pm
      yes, depth_write is equivalent to gldepthmask, and no glAlphaFunc is not exposed through typical ob3d attributes.
      you can replicate the alpha function in a shader with the discard message.
      gl_FragDepth is absolutely the way to manage depth in a shader. i would search the internet for examples of this.
      i can't really say much more without spending some time digging into this, but i would imagine you can replicate your patch using two jit.gl.camera passes.
    • Oct 13 2015 | 11:41 pm
      Hi, thanks for the answer. Even if this 2 pass solution has some artifacts, it solves partly the conflict beetween depth and transparency found many times by users. I tried to make patches that could automaticaly solve this. and not have to construct a list of the objects to render. Or z-sorting them.
      jit.gl.camera does not take shaders like jit.gl.nodes. So I will have to apply 2 different shaders for all objects 1_ apply shader 1 simulating: glalphafunc equal 1., glenable alpha_test, gldepthmask 1 2_ bang the camera/capture 1 3_ apply shader 2 simulating: glalphafunc less 1., gldepthmask 0 4_ bang the camera/capture 2 5_ bang the mixing cameras
      So not an "automatic=1" possibility.
      and with 2 nodes capturing with shaders, i need to duplicate the objects for each nodes...
      I'm going to try with a pre-mrt shader for objects filling the 2 times ( images + norm-depth) perhaps? and then processing the capture=4 ________________ depth_write is equivalent to gldepthmask, Is depth_enable=1 is equivalent to glenable alpha_test? if it is: Having glAlphaFunc exposed as attributes for the camera will allow the 2 passes through 2 cameras in automatic. Perhaps the devault value could be the one used in max rendering.
      ____________________ Also: Are you planing in the future to have a kind of z-sorting system? Could you give a way to access the internal list of object linked to a node? So I could construct a 2pass sketch.. Thanks