Author Topic: Fog of War: covering lights  (Read 4598 times)

hummada23

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 45
    • View Profile
Fog of War: covering lights
« on: January 06, 2015, 04:54:29 AM »
Is it possible to make the fog only cover lights? For example: the player shines a light on a wall, but you can only see the light on the player's side.

This is much trickier than simply using FOWRenderers or getting the fog to only cover certain layers, because it isn't the light source that you want to cover- it's the effect of the light source on what it shines on. So for a 'beam' of light on a wall, for example, you may want to only show the part of the beam that isn't covered by the fog.

Any ideas?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Fog of War: covering lights
« Reply #1 on: January 14, 2015, 10:32:16 PM »
Only see the light on the player's side? Where else would it be? I don't quite understand the question.

If you're doing a MP game and are asking how to only show lights on certain clients, it's simple -- only create them on those clients where you want them visible.

hummada23

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 45
    • View Profile
Re: Fog of War: covering lights
« Reply #2 on: January 17, 2015, 06:26:41 PM »
The light might shine through to the other side of the wall as well (depending on the shaders you're using, as well as the rendering path, your shadow settings, the type of light you're using, and the type of projection your camera is using). Normally you would tweak all of these things in order to stop lights from going through walls.

What I'm wondering, though, is whether the fog can be used to do the same thing, given that it can be used to cover things that are out of the character's line of sight. This might be useful in some contexts (e.g., if you don't want to use shadows in your scene, but you also don't want lights to go through walls), and it would free up a number of other things (e.g., not forcing you to use a perspective camera or fullforwardshadows).

So what you mentioned about the MP game is on the right track, but you can't use FOW Renderers to block the effect of lights on, say, a floor (some parts of the light on the floor are visible to the character, while other parts aren't). With the floor example, I don't think switching off the renderer will work.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Fog of War: covering lights
« Reply #3 on: January 18, 2015, 04:47:54 AM »
Well, you can put a script on your lights that checks FOWSystem.IsVisible(light.transform.position), and if not -- turn it off. But that's about it.

hummada23

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 45
    • View Profile
Re: Fog of War: covering lights
« Reply #4 on: January 18, 2015, 05:44:12 PM »
Ok, I thought as much...

Thanks for your help as always.