Author Topic: Transparent material with deferred fog  (Read 15 times)

mostlyhuman

  • Newbie
  • *
  • Posts: 1
    • View Profile
Transparent material with deferred fog
« on: November 13, 2017, 02:37:52 AM »
I have a character with a transparent hair shader and by default the fog does not render on top of the hair.  Is there a way to get Tenkoku fog to work with transparent shaders? 
I can get the hair to work with the forward scene fog but keeping the scene fog colors and levels synced to Tenkoku fog seems difficult.

Thanks in advance.

Chingwa

  • Administrator
  • Hero Member
  • *****
  • Posts: 1542
    • View Profile
    • Tanuki Digital
Re: Transparent material with deferred fog
« Reply #1 on: November 13, 2017, 08:51:27 AM »
Hi mostlyhuman,

The easiest answer here is to not use transparent objects... to use an opaque shader instead with a clip() tolerance so the pixel alpha value is always either always 100% or 0%. (obviously you would lose any partially transparent visuals).

Tenkoku does it's fog effects as an overlay, and it relies on objects writing to the camera depth buffer in order to generate fog correctly.

But it is possible to use fog on transparent objects as well.  You just need to jump through some hoops to do it.  You will need to edit the hair shader to decode fog effects directly in the shader itself, rather than doing it as an overlaid screen effect.

The setup is a little bit convoluted, but I discuss doing this for tree billboards in the following thread:
http://tanukidigital.com/forum/index.php?topic=980.msg3805#msg3805

The same idea would apply for transparent shaders of any type.  Let me know if this helps!