Yes, you need a camera for every line of sight source, but this camera only renders a part of the scene using a fast depth only replacement shader.
So adding an extra line of sight source adds a bit of overhead, but only if the source is visible on screen. You can minimize this overhead by keeping the camera’s (attached to the source) far clipping plane as small as possible.
Hi there! I just bought GPU LoS =)
This asset is great! I managed to do a fast test integrating it with Manufactura K4 Top-Down Interiors. Here´s my early result:
In this case I didn´t excluded the furniture from the calculation process, so I´ll have better results later.
One thing that I still didn´t figured out is that I´m getting some artifacts on walls at the demo scene:
Edit: Following pdf manual, antialias solved it.
Great work on this asset! =D I´m eager to see what will be available next.
Cheers!
Hi there!
I´ve managed to get some interesting results for a 360* FOV using a single camera.
In this case the camera is over the character and is pointing down. I had to adjust far clipping plane until it reaches this circular volume. As this requires the camera to use a wide FOV, it messes with frustum calculation and raycasts but it´s worth considering this approach for some specific situations. In that case a distance check might handle the false positive.
I’m considering purchasing this asset, but I’m still not sure if it will be useful for my type/genre of game. I’m building a real-time strategy game (think StarCraft 2 or Command and Conquer style) that is “third person” top-down basically.
All I’m looking for is a fast way to calculate whether or not a ranged unit can see its enemy target without anything blocking its line of attack (such as a building between the unit/agent and it’s enemy target or a large hill).
I need ranged units to be able to detect if they do not have line of sight to their target, and if they don’t, then re-path to their enemy target until they do. I also would need to integrate the line of sight checks with my own scripts, so is there a Boolean variable or something that would say “yes this unit has line of sight” that I could then relay to my own script?
I’m going to have about 150 units for each player max, so each game might have about 300 total units maximum. Of course, not all of them will be on screen at the same time. A typical scenario would be about 40 - 60 units on screen at one time. Would your system still be peformant under these use-cases?
Glad you like the asset and thanks for the purchase! The screenshot with the manufactura assets looks really promising!
I’ve found another solution to the artifact problem you show in your second screenshot, which doesn’t require enabling anti-aliasing. If you set the clear flags property of the first camera to depth only, this will also fix the issue without any performance impact. This won’t allow you to set a clear color though, but that will probably not be a problem for a top down game.
The proper way to do a 360 degree line of sight, would be to combine 4 cameras, each with an FOV of 90 degrees. This way the frustum calculations still work correctly, and tweaking the line of sight cone becomes a lot easier! Here’s a quick screenshot showing my technique:
I’ll make sure to include a 360 prefab in the next update (which I’m planning to submit today).
To be honest, I don’t think this system would be very suitable for your needs.
It does include a script to check if an object is inside the line of sight (which sets a boolean value you can check from other scripts), but it does that for all line of sight sources / agents at the same time. This would make it impractical to check if one unit is inside the line of sight of another unit, and would require quite a few code changes.
Yep, I first tried using 4 cameras for the 360, but wanted to check if I could have better performance with a single one.
It will be really useful being able to render Line of Sight sources in different colors =)
I would recommend including a mask for the raycast, there can be situations where devs have an invisible wall that shouldn´t break LoS check.
Cheers
Concerning that subject, do you guys know how Warcraft 3 handled their Fog of war and FOV? It was very efficient. Never found any reference to the technical details of their magic =)
I am planning to buy this asset once it reaches mobile optimization, still I was reading the forum and got an answer for Velo222
Velo222 just make a mesh collider for your units, if you can have the mesh with less than 100 tris it will be great to handle “OnTriggerStay” collisions
Hey Tycho, this looks great! I’m considering using this in a prototype I’m working on, but I have a few questions.
Is this suitable for lighting? I’d like to have dynamic lighting simulated in my game, and this looks perfect if the performance is good enough for 20+ lights at once.
I’d also like to use this for a field-of-view system. Can I layer this effect, once for lighting then again for player FOV?
1: This system works with any kind of lighting ( static / dynamic, forward / deferred ). The amount of lights doesn’t influence the performance of the LOS effect, so if it runs smoothly before, it should run fine with this effect enabled.
I was referring to using this effect as the actual lighting - ie the scene is rendered without any lighting (fullbright) and this effect simulates light sources.
By layering I meant that after that lighting pass of this effect is applied, can I then apply another pass for player vision?
Hey I just picked up this asset is it possible to see if one of the players is actually visible in the LOS? For example I was working on a stealth game and I wanted to be to know if the enemy actually saw the player or not.