Author Topic: Fog of War with transparent shader?  (Read 3713 times)


  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 18
    • View Profile
Fog of War with transparent shader?
« on: May 06, 2014, 06:16:37 PM »
I need to use fog of war on my scene where I have some transparent polygons on my terrain. Unfortunately those polygons are moving in and out of the darkness, and in-between they don't shade right. Can you give me a transparency shader that works properly with your script?


  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Fog of War with transparent shader?
« Reply #1 on: May 06, 2014, 10:16:47 PM »
Fog of War works by tinting the color of each pixel after checking its depth. Transparent shaders don't write to depth, so it's not possible to shade them properly. You need to use a shader that actually writes to depth. A two-pass shader (first time to draw to depth, second time to draw the object) would do the trick -- however this is a Unity usability question at this point -- and you can find a few examples just by doing a google search.

Like this for example:!)