EQS Fog of war/Field of vision system

I just completed a system that uses the EQS circle trace to accurate draw the visible area around the player(or any actor), represented by a mesh generated by the procedural mesh component. Where every vertex of the mesh is one of the points of the EQS(in local space).
Can easily adjust the view range and cone.

The slight lag is caused by the video capture and partially the fact that I’m running from the viewport.

Now all I need to do is use this mesh to apply a post processing effect to the non visible areas to make them appear dark. The problem is that I have zero experience with post processing. If someone could shed some light on this or point me in a direction it would be super.

Also if anyone is interested in seeing the BP for this Id be happy to share.

​​​​Google drive link to project from lower post: https://drive.google.com/folderview?id=0B1_mL6EWhs3yY3d3aDdFUmRfd3M

Sweet! I hope this can be of help to you. Location Based Opacity
A link to download would be nice. :smiley:

O this is really cool, I’l definetly look into this and post updates if I implement it.
30 mins and I’l post a explanation of the system and a download link.

The system explained

So lets go over the system starting at the EQS (project link at bottom).
We use the circle trace which basically traces outwards from midpoint.


From top to bottom following arrows:

Radius is view range.

Space between is the space between trace points, lowering this will make the mesh more accurate around geometry but more expensive.

Arc direction should be checked and set to two points. Line from is querier and line to is a custom contex for the look direction, I’l go over that in a sec.

Arc angle is viewcone size.

Ignore Any Context Actor is very important, without it the trace will hit the querier and will never leave midpoint.

Trace mode should be geometry, otherwise you use the navmesh and that’s just not accurate.

Line works best for trace shape.

The EQS context for forward vector.


The context just gets the forward facing vector of your actor, get this in whatever way works best. My actor does not turn, it just appears to turn. That is why I don’t use Get Forward Vector.

Now for the generation logic, il also post the actual project. Its well commented (Mostly for myself to remember :))

So the procedural mesh function needs 2 arrays, vertices and triangles. The vertices are just the hit points of the trace (in local space).
First we resize both arrays to the correct size. to do this we get the length of the sector (or circumference if 360) and divide it by spacing between EQS points. Then plus one, don’t know why but it works. This is now the vertex array length, the triangle one is this multiply by 3.

Next populate the triangle array(integers), this is on Event begin play. It looks like this


0
2 triangle 1
1
0
3 triangle 2
2
0
4 triangle 3
3
etc…
Each integer is a reference to a vertex, 0 being the center and then the edge ones. One very important thing to remember is that if the view cone is 360 the last triangle needs to connect to vertex 1, otherwise the triangle tries to connect to a non-existent vertex. This is a simple branch that replaces the last triangle vertex.

For people that don’t catch the triangle thing(I know I didn’t till last night) here’s a wonderful illustration.


Red dots are vertices, numbers are references in triangle array.
Green lines are, well, the triangles.

Next the vertices, this is in Event tick(not the best, should rather use a more controlled fast tick, but it works for now).


Literally just translate trace points to local space(sight points on image is the trace points).

After that just plug in the two arrays into the Draw Mesh Section function, the procedural mesh component itself is on the character. The material used has Tow Sided enabled that it is visible.

Project link: TopDown - Google Drive
The project also contains some camera movement stuff and cross hair stuff, also a rudimentary AI. Feel free to use all of it.

I looked at the location based opacity but it seemed like you need to use a brush with it, is there a way I can set the generated mesh as the brush, instead of say a sphere?
Or am I understanding this incorrectly? Couldn’t find too much documentation on this. I really am a complete noob when it comes to graphical stuff.

Ok so I tried some post processing.

The red is post processing, green is vield of vision material.
The blue is your character.
Im using custom depth, this is the material.

So I have 3 problems. First I cant find a way to get the area in the world in the field of vision to stay normal with no post processing.
And secondly I cant find a way to color only the parts of objects that I can’t see.
Lastly when I remove custom depth from the terrain elements that they get colored when not seen the red kinda clips through If I move the camera around. I know why this is happening (I think) but I don’t know how to fix it.
Help would be greatly appreciated.

Made some progress.
Disabled “render on main pass” (render settings) for cone of vision that its invisible but still draw to custom depth buffer. I also offset the vertexes that fall on objects to the objects height. This is done to make the entire face of the object “colored” visible.
Also added logic that hides and unhides objects based on the view cone. enemies can even hied behind each other!
The only problem I still have is that the view cone still clips through stuff when the camera is off center with the player, see picture in above post.

Can’t seem to upload images now so I’l do that tomorrow.

So this is how the almost acceptable system looks like, still have the problem of clipping when moving the camera so advice would be nice.

Google drive link:
https://drive.google.com/folderview?id=0B1_mL6EWhs3yY3d3aDdFUmRfd3M

Hey thanks for the project files and explaining the implementation method. I started using Unreal engine couple of weeks ago and I am still getting used to it. I implemented everything as you did and I fixed all of the errors too. Although, my game does not use mouse input, so it is just WASD controls and I tried every setting with EQSquery but it doesn’t seem to work it always fails and the material is never displayed. I could use your help.

Thank you for your time.

EpEp, you’re Saint! This project saved few weeks of my life :slight_smile:
Thanks a lot!

EpEp, Thanks Man! It is good hint for me)

excuse me guys, how to use collision of the procedural mesh to generate overlap events when overlapping with other actors or pawns or characters?. I checked create collision bool in “create mesh section” node, but it didn’t work :frowning:
Here is my setup if anyone can help:

Hey @EpEp I downloaded your project but it seems like the procedural material is inverted (everything is black that should be visible and vice versa). How can this be fixed and why is it happening?

Thanks again for providing the project.