Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Question about transparency in hair shader

Discussion in 'Shaders' started by iamarohan, May 10, 2022.

  1. iamarohan

    iamarohan

    Joined:
    Nov 16, 2021
    Posts:
    3
    removed
     
    Last edited: Aug 1, 2023
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,256
    The short answer to the question is: There is no perfect solution.

    Accurate and efficient sorting of arbitrary transparent surfaces for real time rendering is an unsolved problem.

    Modern hair rendering in games often relies on alpha testing, sometimes dithered, and then lean on temporal anti-aliasing (TAA) to clean it up. Other games use manually sorted geometry that's been carefully laid out to not intersect. Or hybrid opaque / transparent rendering which uses correctly sorted alpha testing for most of the hair and incorrectly sorted alpha blending to soften the edges.

    In some rare cases, like the recent Tomb Raider games, they've implemented full on order independent transparency sorting system, often limited just to Lara's hair with other characters relying on some other method, because it's very expensive.

    There's some discussion of hair sorting in this thread:
    https://forum.unity.com/threads/sta...-sided-is-very-shiny-on-the-underside.393068/

    Though the conclusion is basically "there's no one option that handles all cases properly".
     
    iamarohan likes this.
  3. iamarohan

    iamarohan

    Joined:
    Nov 16, 2021
    Posts:
    3
    Thanks for the answer!

    It's unfortunate that there is no one option that handles all cases.

    In my own research I have encountered the method using "correctly sorted alpha testing for most of hair and blending for edges" for hair shaders and feel like it's best suited for my case. However, I can't seem to find good articles that explain the method well enough for a noob like me to follow through :(.

    Are there are readings/posts you could recommend in this area?

    Thanks again for your answer! Hope you have a good day~
     
  4. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,256
  5. iamarohan

    iamarohan

    Joined:
    Nov 16, 2021
    Posts:
    3
    Aha I must have missed it!

    I'll make sure to check it our more thoroughly

    Thanks!