TransWikia.com

Unity3D URP - How do I approach creating Fog of War for 3D top-down stealth game?

Game Development Asked by Zekko on December 21, 2021

What I try to achieve is a fog of war system for 3d top-down stealth game. I have searched the Internet and it seems that behavior I want to achieve can be done by using secondary camera that is rendering its output to a render texture. Then render texture is applied to a plane which sits above a map with a masking shader. I was following this video: https://www.youtube.com/watch?v=PNAvNeOTnSE however my project is using URP in Unity and the Clear Flags on camera settings is missing. So basically after each rendering loop render texture gets cleared and drawn again which makes impossible to "save" areas that already have been revealed by the player.

Maybe this can be done using another technique? I would like to have fog of war that covers entire rooms with black opaque plane and reveals them upon entering them but remains cleared once visited. However visited areas should be gray once left and enemies should be hidden from the player when not in line of sight. Something like in this video: https://youtu.be/jrK_Uvwwk9I?t=1247

I would really appreciate if someone pointed my in right direction.

One Answer

Until recently, camera stacking used to be unavailable in the URP. But with the newest release 2020.1 (released just yesterday), it's available again. Although with two limitations: It's unavailable when using the 2D Renderer or when using the VR Multi Pass mode. But there is a promise that this will change "soon™".

From the documentation linked above:

  1. Create a Camera in your Scene. Its Render Type defaults to Base, making it a Base Camera.
  2. Create another Camera in your Scene, and select it.
  3. In the Camera Inspector, change the Camera’s Render Type to Overlay.
  4. Select the Base Camera again. In the Camera Inspector, scroll to the Stack section, click the plus (+) button, and click the name of the Overlay Camera.

The Overlay Camera is now part of the Base Camera's Camera Stack. Unity renders the Overlay Camera's output on top of the Base Camera's output.

Answered by Philipp on December 21, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP