Announcement

Collapse
No announcement yet.

EQS Fog of war/Field of vision system

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    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?...3d3aDdFUmRfd3M
    Last edited by EpEp; 10-18-2019, 06:43 AM. Reason: Copied project link to top.

    #2
    Sweet! I hope this can be of help to you. Location Based Opacity
    A link to download would be nice.
    Youtube
    Twitch

    Comment


      #3
      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.

      Comment


        #4
        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.
        Click image for larger version

Name:	TopDownEQS.png
Views:	1
Size:	175.2 KB
ID:	1120320
        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.
        Click image for larger version

Name:	TopDownEQSContext.png
Views:	1
Size:	210.8 KB
ID:	1120321
        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
        Click image for larger version

Name:	TopDownTriangel.png
Views:	1
Size:	357.8 KB
ID:	1120322
        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.
        Click image for larger version

Name:	TopDownIllustration.png
Views:	1
Size:	15.0 KB
ID:	1120323
        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).
        Click image for larger version

Name:	TopDownVertex.png
Views:	1
Size:	366.9 KB
ID:	1120324
        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: https://drive.google.com/open?id=0B1...0xzZnN3Ty16Ykk
        The project also contains some camera movement stuff and cross hair stuff, also a rudimentary AI. Feel free to use all of it.
        Last edited by EpEp; 12-20-2016, 07:42 AM.

        Comment


          #5
          Originally posted by Delicious View Post
          Sweet! I hope this can be of help to you. Location Based Opacity
          A link to download would be nice.
          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.

          Comment


            #6
            Ok so I tried some post processing.

            Click image for larger version

Name:	FOVTest2.png
Views:	1
Size:	680.8 KB
ID:	1120382

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

            Click image for larger version

Name:	PostProcessing1.png
Views:	1
Size:	335.2 KB
ID:	1120383

            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.

            Click image for larger version

Name:	PostProcessing Clip.png
Views:	1
Size:	665.8 KB
ID:	1120384
            Last edited by EpEp; 12-21-2016, 10:39 AM.

            Comment


              #7
              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.
              Attached Files

              Comment


                #8
                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
                Last edited by EpEp; 10-18-2019, 06:41 AM. Reason: The link broke it seems.

                Comment


                  #9
                  Originally posted by EpEp View Post
                  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/open?id=0B1...3d3aDdFUmRfd3M

                  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.

                  Comment


                    #10
                    EpEp, you're Saint! This project saved few weeks of my life
                    Thanks a lot!

                    Comment


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

                      Comment


                        #12
                        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
                        Here is my setup if anyone can help:

                        Comment

                        Working...
                        X