Search Unity

  1. Looking for a job or to hire someone for a project? Check out the re-opened job forums.
    Dismiss Notice
  2. Unity 2020 LTS & Unity 2021.1 have been released.
    Dismiss Notice
  3. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Help Wanted How can I draw eyebrows in front of hair?

Discussion in 'Shader Graph' started by Sayuri_Artsy, Nov 24, 2019.

  1. Sayuri_Artsy

    Sayuri_Artsy

    Joined:
    Aug 12, 2018
    Posts:
    9

    Hi I am interested in making characters with very readable expressions, but I have a tendency to also give my characters long bangs that seem to obscure eyebrows. I was thinking it might be appealing if I could figure out a way to simply draw the eyebrows over the hair. The right pic was made by cheating, I literally just moved the brow meshes a foot forward, wouldn't work for a long term solution. Also I need the eyebrows to be drawn just in front of the hair, and not in-front of some wall that might be between the character and the camera.

    Having just finished a few games this year with an older version of unity, I have never touched shader graph before, but I do have some skill with the older method of making shaders through script.

    Though I am not even sure if this is strictly a shader question.

    Thank you for your time reading.
     
  2. Olmi

    Olmi

    Joined:
    Nov 29, 2012
    Posts:
    1,367
    You could perhaps get some semi-decent results by adjusting the draw order of the items. But if you make the eyebrows draw over the hair, then when you rotate the head, they will draw over the hair unity your head starts to obstruct the view to the eyebrows. And there might be some other artifacts too, maybe.Try changing your eyebrow material's renderQueue order to be one above the hair. I'm not sure if those hairs are alpha test or just opaque, but make it one above whichever mode you use.
     
  3. Sayuri_Artsy

    Sayuri_Artsy

    Joined:
    Aug 12, 2018
    Posts:
    9
    Both materials are opaque, I checked out the renderQueue, since the hair materials was set to "2000" I tried setting the brows to "2001" but it had no effect.
     
  4. Olmi

    Olmi

    Joined:
    Nov 29, 2012
    Posts:
    1,367
    Hm sorry I'm bit rusty with that stuff I see; it's opaque so it draws to zbuffer I think. Need to think a moment about this :)

    And if you change Ztest mode to something like Always, that will draw over everything opaque... So your eyebrows will actually show through all that opaque stuff.
     
    Last edited: Nov 24, 2019
  5. Olmi

    Olmi

    Joined:
    Nov 29, 2012
    Posts:
    1,367
    Just one hacky idea - I don't think you can change those Ztest modes on the fly but you could check the direction your object is facing and then swap the shader based on that. (i.e.have it look like exactly same shading-wise but with different Ztest mode.) But if you would want a setup that renders only over that hair, I think you would need to look into stencils.
     
    Last edited: Nov 24, 2019
  6. Sayuri_Artsy

    Sayuri_Artsy

    Joined:
    Aug 12, 2018
    Posts:
    9
    hmmmm stencils, ey? I'll have to do some research into that then-
     
  7. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    10,081
    Stencils would be the normal way to do this, or a depth offset. Neither of these are really an option with Shader Graph since stencils aren’t supported, and the only way you can do offsets will also break lighting and shadows.

    With the LWRP / URP you could potentially use the custom renderer feature to draw your characters’ eyebrows and hair so the eyebrows write to a stencil value and the hair is excluded from where that stencil was written to.

    Also, you don’t mention if you’re using the LWRP, URP, or HDRP. If you’re using the built in rendering paths then Shader Graph isn’t available to you as it only works with Unity’s provided scriptable render pipelines.
     
  8. Sayuri_Artsy

    Sayuri_Artsy

    Joined:
    Aug 12, 2018
    Posts:
    9
    Oh I'm sorry. I'm not super picky about what path can arise at the solution. But if you say that that solution does not lie in shadergraph, guess I'll just go back to scripting my own shaders. Still going to do some googling and youtube tutorial research though. Thanks for the run down!
     
unityunity