Search Unity

Cracks in HDRP Lit Tessellation shader? Solution for transparancy triangle draw order?

Discussion in 'Shaders' started by Automoda, Jan 16, 2019.

  1. Automoda

    Automoda

    Joined:
    Apr 27, 2017
    Posts:
    118
    Hey there. I'm testing the HDRP shaders and I have a couple issues to solve:

    #1 The tessellation doesn't seem to weld the verts it creates and seems to rely on the height map alone. Fine, but the problem is that no baked height map is going to be able to guarantee the vert will sample the exact same color if the vert sitting on a UV seam. Even if I turn off the texture dilation and push-out a couple pixels manually, I get glittery seams along the UV seams. This renders tessellation useless since anything worth anything in a game has UV islands. Is this going to be fixed, or am I doing something wrong, is there a magical tool to guarantee that verts on the boundary of UV islands get the exact same texture color, or is this kind of shader a useless novelty except on planes?



    #2 I'm glad the HDRP transparency shader can take fog, deal with taking and casting shadows, etc. The big problem that remains is the draw-order problem. Since with transparent items, draw order matters, any shape with a convexity to it can cause one part of the mesh to draw before another part (overlap). This means there's a 50/50 chance any particular triangle will draw on top of something it should be behind. I was hoping, now that we're in the future, we had some kind of sort solution that could fix this. If the triangle count was kept low, it would be an insignificant step that would make transparency finally work. Is there a fix? I don't see anything in the import settings for the mesh or the shader. If this is just a fact of life and sorting triangles is out of the question, then transparency is for convex items only. They should post that as an alert on the shader itself.

     
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    7,115
    Correct. Tessellation cannot weld the verts because GPU tessellation works on a single triangle at a time and it doesn't know what verts should be welded or not. More to the point, once the mesh has been uploaded the GPU it can't weld verts. It's up to you as the content creator to prepare the content to handle this. Usually it's about minimizing UV islands as much as possible, and trying to line up or hide seams that do exist.

    Efficient, and correct sorting of 3d transparency in real time rendering is still an unsolved problem.
    https://forum.unity.com/threads/render-mode-transparent-doesnt-work-see-video.357853/#post-2315934

    What you want is Order Independent Transparency, or OIT.
    https://forum.unity.com/threads/is-...ency-depth-sorting-issue.480631/#post-3128478

    The HDRP is primary intended for deferred rendering, which MSAA doesn't really work well with, so alpha to coverage isn't an option.
    Pre-Z is a good option if you don't need the object to be visible through itself, but I don't know of a way to do that with the HDRP since by default it doesn't like multi-pass shaders.

    However most modern AAA games these days using TAA don't use transparency at all if it can help it. Instead they use some form of dithered alpha clip and let the temporal aspect of TAA hide it. The trick is to use a noise pattern that changes every frame. Unfortunately I don't think Unity has this as an option, though it'd be plausible to implement using shader graph.
     
    hippocoder and AcidArrow like this.
  3. Automoda

    Automoda

    Joined:
    Apr 27, 2017
    Posts:
    118
    Thanks for your reply, bgolus. I knew all that stuff you'd described, but I was hoping that here in the future we had the technology, like some GPU mesh triangle sorting that could sort 3,000 triangles in a nanosecond. Instead they jump to ray tracing as if thats faster.

    The only way to make tessellation work, then, would be to have a tool that could make sure the edges of islands matched the mating edge as closely as possible, even perhaps bleeding the exact colors in and out one pixel to each side to ensure a good match. Does such a tool exist? Seems like it would be easy enough to write. Alas I'm not a coder. The only other idea that might work is an 8K displacement texture. That sure sounds like a plan. Bleh.

    Ok so transparency is cool for spheres and rectangle type stuff but nothing else. I really wish they'd just come out and say that in the first place-- I could have saved making a version of a creature that had transparent parts. There goes a week. Seems like all this fancy stuff in the HDRP transparency shaders is mostly not practical to use in a real game except for the occasional crystal shard...So long as it doesn't have any complexity and sits all alone. What a waste.
     
    racarate likes this.
  4. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    7,115
    Not sure about a nanosecond, but the technology to sort triangles exists.
    http://diaryofagraphicsprogrammer.blogspot.com/2018/03/triangle-visibility-buffer.html?m=1

    There's also the new mesh shaders that are in the latest Nvidia RTX cards, but few are going to take advantage of right now.

    The problem is both of these require pretty deep changes to how you go about rendering stuff, and they're not always faster for a lot of content.

    It also doesn't fully fix the transparency sorting issue as intersecting triangles still fail. For that you really need to sort per pixel. AMD showed that off like 8 years ago running in real time ... at about 5-20 times slower then normal rendering. And Intel has shown off some approximations that are essentially ground truth for simple cases, and passable for more complex ones, that run with very little performance impact ... but only on Intel IGPs which makes it useless.

    And then if course there's raytracing, but that's even slower, even with "RTX".

    Probably. I know there are plenty of tools like this for doing lightmapping and auto UVs through 3D Coat or Houdini. I've honestly always just done it by hand.

    Try looking at this:
    https://www.sebastiansylvan.com/post/LeastSquaresTextureSeams/
     
  5. Automoda

    Automoda

    Joined:
    Apr 27, 2017
    Posts:
    118
    Well that link is exactly the thing, code and all, but nobody has a usable tool to download that I can find. Its only been needed for ... 20 years or so.
     
  6. francois85

    francois85

    Joined:
    Aug 11, 2015
    Posts:
    630
    Late to the game but I can’t seem to find the lit tessellation shader in the shader graph.