0 votes

I'm prototyping a top down RTS where units have vision ranges that can be blocked by obstacles.

Here's a quick diagram

I'm working on a fog-of-war effect where terrain that is out of detection range and line of site is masked. There's no grid snap or turn based so I'd likely need to redraw this multiple times a second so I'll need to think about performance. I'm not sure what the final scale looks like but I'd like to keep options open to have a few hundred units (this may be a dealbreaker). Not sure if it matters but I'm working in C#.

My thought would be to either:

1. Build and draw polygons in the _draw call of a Sprite/Image Texture

  • Comes with the drawback of not having access to shaders
  • This might also be expensive to perform boolean polygon calculations in CPU since I can't draw subtractively AFAIK.

2. Paint an Image/Texture Myself

  • From what I can tell, this comes with big overhead.
  1. Start with a filled black mask
  2. Step through each unit and build a polygon circle with slices coped out based on obstacles
  3. Paint the polygons as transparency

3. Do Something With Viewports

I'm not really familiar with what's possible here. Could there be shaped sprites that combine with shader magic to add/subtract to the intended transparancy then write that to a mask texture over the main camera?

4. Go With Something Simpler

This may not really be viable as is.

Godot version v3.4.2 stable
in Engine by (12 points)
edited by

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.