[TUTORIAL] Fog Of War

Hi,
I think youโ€™re experiencing the same setup issue as DragonHunt10. Have you gone through the steps i posted in post #29? Pay particular attention to:

  1. The FOW_Mat_Instance material must have PP_Fow_Mat as its parent. Set both of the Texture Parameter Values to a plain white texture.

If your whole scene is black it means that the post-process is projecting a black texture on your scene, which is the equivilant to having your whole scene fogged. Changing the textures to a white texture will reveal the scene.

Hope that helps,

Hi,

There is no need to include FogOfWarWorker.h in FogOfWarWorker.cpp, rather include your project header-file (mine is called RpgTest.h, yours probably has a different name), and include FogOfWarWorker.h in your project header file. Iโ€™m unsure of whether it matters if you start your project as a blueprint or c++ project. I startet mine from the Top Down template as well and just added coded through the โ€œAdd code to projectโ€-option in the editor. If you want to take a look at a working sample, thereโ€™s a link in post #29 which should be fairly stripped down.

If you continue to struggle, I could probably take a look at your project if you make it available to me.

Cheers,

Hi, looks very well, but how install it? Sure i can make all these .h and .cpp files, but what about linking it to blueprints? Should i recteate it from scratch with images or hereโ€™s just that sample project from video with things installed already? Or any other kind out of the box solution?

You could either recreate from scracth or download an example implementation in post #29.

Cheers,

ty, would be nice put link into 1-st post

i tryed this example and here is my confusion:

i made second player start by copy/past, setted number of players 2 and launched game, first player have correct fog of war, all fine, but second donโ€™t have it at all :(, should i make any additional configuration? in RTS units usually have assigned player who control them and visibility rules between players, also in warcraft 3 there was additionaly rectangle area objects that can have visibility for certain players

Hi :

I tried this effect, and it looked awesome. The problem is that when I deploy the game on to Android device, it crashed.

In order to get the C++ code built for Android SDK and IOS xcode, the modf function has to use double instead of float.
The place it crashes is the RHIUpdateTexture2D function call. I am wondering if you can find a way to fix it or go around it?

Thanks,

Hi :

I successfully got it work on PC and mobile preview view by not using the postprocess component. But when deploy and launch the game on android device, it crashes at RHIUpdateTexture2D function call from the rendering thread. I am wondering if you can figure out a way to fix or go around this problem.

The math function modf(float, float) has to be changed to modf(double, double) for both android and ios.

Thanks,

Hi,

The practical application of this particular FOW-solution for an RTS is way beyond the scope of the tutorial, it is only intended to illustrate a way of graphically handling FOW for a single player. You may, however, register multiple actors to a single FOW-manager by calling AFogOfWarManager::RegisterFowActor(AActor* Actor) with the desired actor as the parameter.

Iโ€™m not entirely sure on what you mean by โ€œin warcraft 3 there was additionaly rectangle area objects that can have visibility for certain playersโ€, though I guess it would be possible to extend the solution to accomodate fogging/unfoggin of other shapes than circles, though I have unfortunately no immeadiate plans to do so.

Cheers,

Hi ,

Unfortunately I have no insight into how RHIUpdateTexture2D works on different platforms. Saw your question on the answerhub, and hopefully one of the devs or someone from the community could shed some light on it.

Regarding the modf, Iโ€™ve removed the entire line on my end since the โ€œfractionsโ€-variable is unused. For future reference I discovered later a modulo-function in Epicโ€™s math library, FMath::Fmod(float X, float Y) that should probably work hassle-free on all platforms.

Cheers,
.

Hey I would also personally like to just use blueprints but I do know some C++ and iโ€™m taking a course on it in college right now so I guess this would be a good project for me to just go ahead and stick with good ole code i used to make a bunch of mods with allot simpler programming languages like LUA and java. What iโ€™m wanting is gonna need some tweaking so iโ€™m probly gonna most likely be pming you.

Sure, PM away :slight_smile:

Updated material and LevelInfoโ€™s construction script for 4.9.
To upgrade, change the material node SceneTexture:Color to SceneTexture:PostProcessInput0 and change the construction script of LevelInfo to mimic the screenshot in the main post.

Cheers,

Hey man, i cant compile this code, got errors :frowning:

Okay if you could post or PM me the error list I could take a look at it. Please include the engine version youโ€™re compiling with as well.

Engine version - 4.9

Hi,
This looks like a linker error where the build tool is unable to find RHI (Rendering hardware interface)-related classes. I wrote a bit about it in the main post and youโ€™ll have to:

  1. Open the file named MyProject.Build.cs
  2. Locate line PublicDependencyModuleNames.AddRange(new string] { โ€œCoreโ€, โ€œEngineโ€โ€ฆ
  3. Add the strings โ€œRHIโ€, โ€œRenderCoreโ€ to the array.

Hopefully it will now compile.

Cheers,

Yeah, its working now.
I am new in c++, is there any way to register actor to fowmanager by blueprints? Because my actor isnt controlled by player, its controlled by AI (player sending commands to AI), and it spawns not on begin play. I have no idea how to register it by c++ =/

โ€“ double post โ€“

Well, i dont know, but i am getting crash after starting play =_=

Here is a log after crashโ€ฆ Any ideas?