Announcement

Collapse
No announcement yet.

Matte object bug with unclamped zdepth

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Matte object bug with unclamped zdepth

    Hi guys,
    we've discovered a bug when rendering an object with matte properties and unclamped zdepth: if we check to not generate render elements (that in my opinion should be the default behaviour for a matte object anyway), it outputs an infinite negative value.
    Here are some screenshots and a scene file
    Attached Files
    KCTOO - Directors

  • #2
    I think that value is what every pixel with nothing in the image generates for Z Depth. Since you have the plane set to not generate elements it is invisible to Z Depth and thus produces the same value as if nothing was there.

    Or am I missing something?

    Comment


    • #3
      Originally posted by Joelaff View Post
      I think that value is what every pixel with nothing in the image generates for Z Depth. Since you have the plane set to not generate elements it is invisible to Z Depth and thus produces the same value as if nothing was there.

      Or am I missing something?
      Well maybe yes, i guess everything could be possible, but i would expect a value of 0 if nothing is there, not minus infinity.
      KCTOO - Directors

      Comment


      • #4
        You could multiply the Z-Depth by the alpha. I guess it depends on how your post software interprets the Z-Depth.

        Comment


        • #5
          Ehehe let's say I know the math and tricks
          I already do this, but the problem will always be there since you have the premultiplication against infinity, even with an edge expand afterwards.
          Minus infinity it's just not what should be outputted.
          I'm a big big vray advocate, but the matte workflow hasn't always been its strength. Why would I want matte objects in render elements in the first place?! At least not as a default.
          I mean matte=hole since the beginning of time.
          KCTOO - Directors

          Comment


          • #6
            True about the edge pixels. But there is a trick: You could of course threshold your alpha at 0.0001 or something to get any non-zero value. You could also put a big plane or sphere far back and let that be your background, or clamp the Z-Depth.

            Again, it all depends on what you are doing with it in post. I don't think you want zero in there for a lot of post blur tools. You certainly don't want it if you are using the depth for fog. Most renderers I've used in the past 30 years output some kind obscure value for zero alpha areas when it comes to depth. Those areas are in mathematical terms undefined. These is no depth for a pixel that has no content.

            If you are comping this and doing a depth blur in post then you would often use a non-anti-aliased depth buffer, which will indeed give you the correct values for your edges, even those edges that are soft. I mean, if you anti-alias your depth buffer to begin with then all those edge values are completely wrong anyway. Do anti-aliased depth buffers often make better results (when applied to a beauty pass without alpha)? Sure, frequently, but I usually render both an anti-aliased and a non-anti-aliased version for Z depth and use whichever works best in post, sometimes mixing the two.

            I don't think you want a value of zero in those undefined areas, as depth blurs typically blur the FG pixels over the BG pixels. (Assuming zero is the film plane...) This would erroneously make all those undefined pixels FG pixels.

            Comment


            • #7
              Originally posted by kagemaru View Post
              Well maybe yes, i guess everything could be possible, but i would expect a value of 0 if nothing is there, not minus infinity.
              If you clamp the z-depth, the value goes to 0.0 (the same as the background.).
              It does look odd, admittedly, but it could be something due to the matting maths, not easy to get around of (you'll notice it goes to the other side of the value range if you don't invert Z.).

              Point Positions, from the samplerInfo RE seem unaffected (they stay at 0.0), so perhaps you may be able to use the B of those, if you can't clamp Z for other reasons.
              Lele
              Trouble Stirrer in RnD @ Chaos
              ----------------------
              emanuele.lecchi@chaos.com

              Disclaimer:
              The views and opinions expressed here are my own and do not represent those of Chaos Group, unless otherwise stated.

              Comment


              • #8
                To update the topic: it's a feature.

                With the setup above, the matte nodes become easily distinguishable from the Z channel alone by virtue of their going to the boundaries of precision.
                If 0.0/1.0 is the background (depending on z-channel inversion settings), the only other meaningful point by which to univocally identify a matte node is indeed infinity, plus or minus depending on Z settings.
                It's then easy to single those values out in post (f.e. with an expression) and get a pixel-perfect (albeit non-filtered) mask of the matted areas, or to convert those infinities to the exact values one would need (f.e. 0.0, 1.0, and so on.).

                This will work *only* on entirely unfiltered Z passes (i.e. turn off the RE filtering entirely.), meaning to get a decent selection one may need double-sized renders of the data passes, so to scale the seelection and filter that way.
                Last edited by ^Lele^; 14-07-2021, 06:42 AM.
                Lele
                Trouble Stirrer in RnD @ Chaos
                ----------------------
                emanuele.lecchi@chaos.com

                Disclaimer:
                The views and opinions expressed here are my own and do not represent those of Chaos Group, unless otherwise stated.

                Comment


                • #9
                  Just as a follow up on this topic: is this behaviour expected to be as is for the time being, or could we maybe expect the possibility to have it as 0 with a checkbox?
                  I'm kind of baffled that i'm the only one expecting to be have a straight-up working zdepth and not caring about selection in that pass, but if that's the case we'll setup things differently.
                  Thanks.
                  KCTOO - Directors

                  Comment

                  Working...
                  X