Any ideas of how to create FOG OF WAR?

I know some people wasted many time to do it with UDK, also some people drop to develop strategy games with one of that reason.
Maybe some one have great idea of how to do FOG OF WAR with UE4, it should be possible now i hope.
Any ideas about where to start will be the best point.

Also, it wold be great if EPIC GAMES will provide an simple example, or even direct where to start/what to use/which class or function and same like…

The hardest tasks are most interest tasks, and i wanna try it.

With C++ source code access I would approach it a bit differently but I try to outline a solution that should work for Rocket.
Fog of war rendering can be like actual fog (how to distinguish from fog), like missing light (can be simpler to implement using lightfunctions) or in some other way (e.g. hiding units, greying out terrain).

You need some function that defines the shape (e.g. smallest distance to n units < some value). This function can be used to disable rendering of units.

In order to get a seamless transition for the ground you might want to have the functiom stored in a texture. In a normal 2d strategy game this could be a 2d texture. Upading from CPU is not exposed in Rocket so you would need to do that from the graphics card.
For this you can use a scenecapture actor. This actor renders a scene into a 2d texture (created in the content broswer, can be quite low res as we use bilinear filtering). This texture can be used in a material (lightfunction or decal material or translucent mesh with many 2d slices).
Start with a static painted 2d mask - once that works setup a scenecpatureactor creating the mask dynamically.
Using a sprite/decal/particle/static mesh you can render a disc for each object into the render target.

SceneCaptureActor is normally used to render a lit 3d scene - it has quite some overhead. Disable as much features as possible. We might optimize for such a 2d case if needed. If you have the SceneCaptureActor camera far from your actual scene it might run more efficiently (culling).
We consider supporting multiple scenes so one day this not be an issue.

You don’t need to update the fog of war each frame. You can specify a rate in the SceneCaptureActor.

I would do none of the above.

I would create an invisible actor that renders using only the custom depth node ( access the GBuffer) and use this to draw a mask a post process material could use.

Should be some light information here:
https://rocket.unrealengine.com/docs/ue4/INT/Engine/Subsystems/Rendering/PostProcessEffects/index.html

Some time ago i was looking any documentation or realization examples about fog of war but i have not found any about how to make it in 3D world, all i have seen was about 2D games.

Then i have started to experiment with fog of war on UDK and best result i have got was with light function.
The result can be found at:

Also before i gave tried volumetric fogs, postprocess and many other conceptions. Postprocess - it is 2D texture, so it is not projected to world, so it looks like you are looking on world through a hole in a wall, like a through sniper riffle, it not looks like fog of war.

But i always believe it should be some light rendering function with mask texture.
Mask texture is simple grayscale texture, which can have white colour for visible areas, gray colour for visited and not visible areas and black colour for undiscovered areas.
This mask can be created, and projected to current camera view, and light should be rendered only in white areas of that texture.

UE4 has deferred lightning, as i know, so, i think it makes possible to realize my idea, if light can be rendered with mask, but i do not know yet UE4 provides any render interfaces for that.

I really hope someone will told “hey i did it before and it should be done so and so”
Also i really hope Epic Games will provide some help to direct me with idea and information how it should be or can be done with UE4

Tnx

Fog of war techniques like the one you are describing will use a render target to retain information about which ‘cells’ in the game world have been visited and incorporate it into their core rendering setup. In Unreal, you could use the same render target setup in your materials and project it in world space. This would be quite easy to achieve and can be done in both UE3 and UE4 without any complex code or material shaders.

Light functions do not benefit from the performance gains in deferred rendering. I would not use lights to achieve this as it’ll quite simply look wrong - your fog of war should not be affecting object lighting and you don’t want discrepancies in lighting between objects within your field of view and those that aren’t.

Post processing using the GBuffer uses information in the world rendered directly as part of the scene, so I don’t see how it can anything but ‘projected to world’. It may not be the best technique to use when rendering the specific style of fog of war you are describing where unexplored areas are hidden from view (this isn’t strictly fog of war, you’re describing exploration mechanics instead), however it is perfectly suitable for other techniques that do not need to remember what you have visited, only what you can see (for example duplicating the setup in Company of Heroes.

assuming you are talking about units and not the minimap.

cheap way to do the unit visibility:
attach a collision component to a ‘minion’, on overlap set to visible, on end overlap set to invisible.

the ‘fog’ part is just a mask(or two depending on style) I would start with attaching a decal to my character that changes the opacity of the material.
or try using getting your pawns to paint on the verts like the brushes do in the editor.

you could also probably just use the exponential height fog volume too. although I havent the ‘foggiest’ idea how you could get that to work with Pawns affecting visibility instead of the camera.

Tnx.

For example, i always thought that starcraft fog of war it is a light function, maybe rendered with some visibility mask or some like that

I would create a volumetric grid ( think voxels), wich each 0.1 seconds or something like that, but it can also be calculated in a thread, gets wich parts of the grid can be seen and wich cant. Then, each frame of rendering, using the position of the units, i see in the grid if that square is seen or not, and make the unit hidden or not depending on it.
For the actual effect, i think i would go with a post process, but thats beyond what i know.

Thx to all.

Also, i wish Epic Games provide some info here too, so i hope they will do it.me info here too, so i hope they will do it.

For the visual effect, use a decal with an emissive of -1.Give it a black colour & script the texture for the opacity it uses.

Be careful of using a hud system as it is best to keep that stuff client side & will make it vulnerable to cheating.