Well, i dont know, never had problems with replications, but now… Clients always get black fowtexture =_=
Alexarg,
I had major fps-oscilliations with fow-texture sizes set to 2048, though none at 1024. I would guess i depends a bit on your rig. Another user also reported “lag” on win10, but none i compatability mode. I use Windows 10 (and DX11) though I haven’t had any fps drops. I wouldn’t know what to do except update your gpu-drivers and possibly try setting the texture size to 512.
Cheers,
Hi ,
which platform are you packaging for? I’ve only tested 64-bit windows builds which seem to work. On other platforms, I have no idea. As for networking, I’ve no experience developing networked games so there’s no out of the box-support for multiplayer features. If I were to look into it, I think the easiest way to do it is to have each client own the Fow-manager and spawn a Fow-worker-thread, calculate the fog and update local textures. If you aim to have the server do all of the fow-work, you’d probably have to create a worker thread on the server per connected client, replicated the textures to the client when they’re updated and make the client update the post-process shader. To make it work properly and efficiently would require a major rewrite.
Cheers,
Thank you for good guide^_^
Amazing work mate, congrats.
And thank you for sharing.
Has anyone been able to get this working in 4.11? My problem is that it’s not showing up. The whole map is revealed. I am using the same project from 4.9 that had it working.
Heoki,
I upgraded from 4.10 to 4.11 without any problems. Maybe post #65 adresses your problem. I would advise you to do some debugging around the Event OnFow Texture Updated.
Cheers,
Ah, I just tried in 4.11.1 and its working again. It hadn’t been working on any previous version of 4.11 that I’ve tried.
Hi!
Thanks for an awsome tutorial. I got it to work for a RTS multiplayer game and all is good
Though i can’t wrap my head around how to change color of the “not-in-visual” fog parts. We wouild lika to have a more greyish tone to different the in-game props shadows and the FOW. I changed the textures in the Material Instance with no succes. Any idea?
Thanks
Hi,
You can change the lightness/darkness of the shroud of darkness by altering the 100-value in the code here:
else {
sum += (Manager->blurKernel* * 100);
}
and here:
else {
Manager->TextureData[x + y * signedSize] = FColor((uint8)100, (uint8)100, (uint8)100, 255);
}
Cheers,
Thanks for a quick answer. I think my questions was kind of unclear, my apologies
We need to alter the Color, to make it more whiteish or greenish. As i interpretate your answer it only affects the black alpha color.
I see. One way to handle it is to do a small rewrite since the horizontal blur data is stored as Uint8 and not FColor. That rewrite would quadruple the memory footprint of the buffer (which isn’t necessarily terrible but should be avoided). Alternatively you could maybe create some kind of color-gradient or curve where 0 grades to black 127 grades to the color of your choice and 255 grades towards white (fully unveiled). Then in this line:
Manager->TextureData[x + y * signedSize] = FColor((uint8)sum, (uint8)sum, (uint8)sum, 255);
you’d use “sum” as the input for your curve, and the resulting RGB instead of sum. I’d have to experiment a bit with the math to get it “right” maybe with an S-curve or something semi-fancy, though you could probably get by using linear interpolation.
Some pseudo code would be:
if(sum < 127) {
transform 0->127 to 0->1
lerp from black to the color of your choice
} else {
transform 128->255 to 0->1
lerp from the color of your choice to black
}
You’d probably also want to change the current alpha for the shroud of darkness from 100 to 127 for the “color of your choice” to match more excactly.
Cheers,
Nice! I’ll have a go at it when i find some time. Really appreciate ur effort mate. If i get something working I’ll post it here later.
Have a good one.
Hi ,
is there any sample project for versions 4.10 o 4.11? I’m not being able to build/upgrade the one provided in #29 with my 4.10 version.
I’m no c++ freshman, but still I’m mortified to admit that I’m very unexperienced with the whole ue4 c++/api implementation, and I’m having difficulties implementing the code you provided in the main post.
Specifically, how do you create FRunnable classes? I can find the new Actor class, but nothing that hints to multi-thread/thread/runnable classes.
If I just copy/paste FogOfWarManager’s cpp/h files into a New Actor, then I can’t compile because it’s missing the FogOfWarWorker.
And if I paste FogOfWarWorker’s cpp/h files into an Empty Class I get these errors when compiling:
CompilerResultsLog:Error: Error FogOfWarManager.cpp.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: unsigned int __cdecl FRHIResource::AddRef(void)const " (__imp_?AddRef@FRHIResource@@QEBAIXZ) referenced in function "public: __cdecl TRefCountPtr<class FRHITexture2D>::TRefCountPtr<class FRHITexture2D>(class TRefCountPtr<class FRHITexture2D> const &)" (??0?$TRefCountPtr@VFRHITexture2D@@@@QEAA@AEBV0@@Z)
CompilerResultsLog:Error: Error FogOfWarManager.cpp.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: unsigned int __cdecl FRHIResource::Release(void)const " (__imp_?Release@FRHIResource@@QEBAIXZ) referenced in function "public: __cdecl TRefCountPtr<class FRHITexture2D>::~TRefCountPtr<class FRHITexture2D>(void)" (??1?$TRefCountPtr@VFRHITexture2D@@@@QEAA@XZ)
CompilerResultsLog:Error: Error FogOfWarManager.cpp.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __cdecl FRHICommandListImmediate::UpdateTexture2D(class FRHITexture2D *,unsigned int,struct FUpdateTextureRegion2D const &,unsigned int,unsigned char const *)" (__imp_?UpdateTexture2D@FRHICommandListImmediate@@QEAAXPEAVFRHITexture2D@@IAEBUFUpdateTextureRegion2D@@IPEBE@Z) referenced in function "public: void __cdecl `public: void __cdecl AFogOfWarManager::UpdateTextureRegions(class UTexture2D *,int,unsigned int,struct FUpdateTextureRegion2D *,unsigned int,unsigned int,unsigned char *,bool)'::`5'::EURCMacro_UpdateTextureRegionsData::DoTask(enum ENamedThreads::Type,class TRefCountPtr<class FGraphEvent> const &)" (?DoTask@EURCMacro_UpdateTextureRegionsData@?4??UpdateTextureRegions@AFogOfWarManager@@QEAAXPEAVUTexture2D@@HIPEAUFUpdateTextureRegion2D@@IIPEAE_N@Z@QEAAXW4Type@ENamedThreads@@AEBV?$TRefCountPtr@VFGraphEvent@@@@@Z)
CompilerResultsLog:Error: Error FogOfWarManager.cpp.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: static enum ENamedThreads::Type __cdecl FRenderCommand::GetDesiredThread(void)" (__imp_?GetDesiredThread@FRenderCommand@@SA?AW4Type@ENamedThreads@@XZ) referenced in function "private: void __cdecl TGraphTask<class `public: void __cdecl AFogOfWarManager::UpdateTextureRegions(class UTexture2D *,int,unsigned int,struct FUpdateTextureRegion2D *,unsigned int,unsigned int,unsigned char *,bool)'::`5'::EURCMacro_UpdateTextureRegionsData>::SetupPrereqs(class TArray<class TRefCountPtr<class FGraphEvent>,class TInlineAllocator<4,class FDefaultAllocator> > const *,enum ENamedThreads::Type,bool)" (?SetupPrereqs@?$TGraphTask@VEURCMacro_UpdateTextureRegionsData@?4??UpdateTextureRegions@AFogOfWarManager@@QEAAXPEAVUTexture2D@@HIPEAUFUpdateTextureRegion2D@@IIPEAE_N@Z@@@AEAAXPEBV?$TArray@V?$TRefCountPtr@VFGraphEvent@@@@anonymous_user_e71e0d8a?$TInlineAllocator@$03VFDefaultAllocator@@@@@@W4Type@ENamedThreads@@_N@Z)
CompilerResultsLog:Error: Error FogOfWarManager.cpp.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: static enum ESubsequentsMode::Type __cdecl FRenderCommand::GetSubsequentsMode(void)" (__imp_?GetSubsequentsMode@FRenderCommand@@SA?AW4Type@ESubsequentsMode@@XZ) referenced in function "public: static class TGraphTask<class `public: void __cdecl AFogOfWarManager::UpdateTextureRegions(class UTexture2D *,int,unsigned int,struct FUpdateTextureRegion2D *,unsigned int,unsigned int,unsigned char *,bool)'::`5'::EURCMacro_UpdateTextureRegionsData>::FConstructor __cdecl TGraphTask<class `public: void __cdecl AFogOfWarManager::UpdateTextureRegions(class UTexture2D *,int,unsigned int,struct FUpdateTextureRegion2D *,unsigned int,unsigned int,unsigned char *,bool)'::`5'::EURCMacro_UpdateTextureRegionsData>::CreateTask(class TArray<class TRefCountPtr<class FGraphEvent>,class TInlineAllocator<4,class FDefaultAllocator> > const *,enum ENamedThreads::Type)" (?CreateTask@?$TGraphTask@VEURCMacro_UpdateTextureRegionsData@?4??UpdateTextureRegions@AFogOfWarManager@@QEAAXPEAVUTexture2D@@HIPEAUFUpdateTextureRegion2D@@IIPEAE_N@Z@@@SA?AVFConstructor@1@PEBV?$TArray@V?$TRefCountPtr@VFGraphEvent@@@@anonymous_user_e71e0d8a?$TInlineAllocator@$03VFDefaultAllocator@@@@@@W4Type@ENamedThreads@@@Z)
CompilerResultsLog:Error: Error FogOfWarManager.cpp.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) class FRHICommandListImmediate & __cdecl GetImmediateCommandList_ForRenderCommand(void)" (__imp_?GetImmediateCommandList_ForRenderCommand@@YAAEAVFRHICommandListImmediate@@XZ) referenced in function "public: void __cdecl `public: void __cdecl AFogOfWarManager::UpdateTextureRegions(class UTexture2D *,int,unsigned int,struct FUpdateTextureRegion2D *,unsigned int,unsigned int,unsigned char *,bool)'::`5'::EURCMacro_UpdateTextureRegionsData::DoTask(enum ENamedThreads::Type,class TRefCountPtr<class FGraphEvent> const &)" (?DoTask@EURCMacro_UpdateTextureRegionsData@?4??UpdateTextureRegions@AFogOfWarManager@@QEAAXPEAVUTexture2D@@HIPEAUFUpdateTextureRegion2D@@IIPEAE_N@Z@QEAAXW4Type@ENamedThreads@@AEBV?$TRefCountPtr@VFGraphEvent@@@@@Z)
CompilerResultsLog:Error: Error FogOfWarManager.cpp.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) class FRHICommandListExecutor GRHICommandList" (__imp_?GRHICommandList@@3VFRHICommandListExecutor@@A)
CompilerResultsLog:Error: Error FogOfWarManager.cpp.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) bool GIsThreadedRendering" (__imp_?GIsThreadedRendering@@3_NA)
CompilerResultsLog:Error: Error FogOfWarManager.cpp.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) bool GMainThreadBlockedOnRenderThread" (__imp_?GMainThreadBlockedOnRenderThread@@3_NA)
Tutorial was fantastic, thanks a lot!
Did you manage to compile?
FRunnable is a base class declared in Core/Public/HAL/ThreadingBase.h; you simply want to create an empty class and extend FRunnable. When you use the “new c++ class” wizard from the editor just select none as parent class (but if you choose Any other parent class and copy/replace the entire code it will work fine).
The compilers error are probably caused by the fact that you didn’t include “RHI” and “RenderCore” in the public dependecies modules (file YourProject.build.cs in Source/YourProject folder) and the UpdateTextureRegions function as unresolved links.
Hi I have 0 experience in C++, I have updated Build.CS, I created 2 new C++ Classes with no parent, and copy past info from post #1. when I try to build in VS I get the following errors
(1)
Severity Code Description Project File Line Suppression State
Error The first include statement in source file ‘D:\GameDesign\GameJamWorkSpace\MyProject4\Source\MyProject4\FogOfWarManager.cpp’ is trying to include the file ‘RpgTest.h’ as the precompiled header, but that file could not be located in any of the module’s include search paths. MyProject4 D:\GameDesign\GameJamWorkSpace\MyProject4\Intermediate\ProjectFiles\EXEC 1
(2)
Severity Code Description Project File Line Suppression State
Error MSB3073 The command ““C:\Program Files (x86)\Epic Games\4.11\Engine\Build\BatchFiles\Build.bat” MyProject4Editor Win64 Development “D:\GameDesign\GameJamWorkSpace\MyProject4\MyProject4.uproject” -waitmutex -2015” exited with code -1. MyProject4 C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.MakeFile.Targets 37
@,
In FogOfWarManager.cpp the third code line reads:
#include "RpgTest.h"
This is the include to the main header file of your project. You’ll have to change this to the name of the “main header file” of your project. Looking at your error message, my best guess is that it’s called “Myproject4.h” on your end.
Cheers,
Thank! I did not add RHI and RenderCore modules!
I just saw this thread!
This is an incredible sharing @anonymous_user_964c5f2d, thanks!
And it looks great too!
Congratulations on this awesome implementation!
Rama
Hey so im no c++ profi.
I just c&p every thing in and added these RHI and RenderCore.
But now I have 200+ errors.
It starts with “FogOfWarManager.generated.h” couldnt be opened. Where did i miss to generate this?
Thanks