Procedural Texture Generation

I am currently working on a Universe simulator. Currently working on methods to generate planet and moon surfaces procedurally.

I cant find any class regarding generating textures or materials in engine.

Can any one give me any leads?

Sure. We had this issue just a short while ago, and it took some time coming up with a solution.

I’m going to write up a quick Wiki about it and post it here. Okay?

Ok I will be waiting.

An article I whipped together about it. Let me know if you find anything unclear.

Please mark as resolved if this solution works for you :slight_smile:

Thank you… Awesome article. :slight_smile:

Has something become deprecated in the UpdateTextureRegions section of this code? When I attempt to set it up, I get a lot of unresolved external symbol errors.

This still works for us, could you copy paste your errors?

Here’s the error"

1>mapDynamicTexture.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: class TRefCountPtr __cdecl FTexture2DResource::GetTexture2DRHI(void)" (?GetTexture2DRHI@FTexture2DResource@@QEAA?AV?$TRefCountPtr@VFRHITexture2D@@@@XZ)
1>mapDynamicTexture.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::~TRefCountPtr(void)" (??1?$TRefCountPtr@VFRHITexture2D@@@@QEAA@XZ)
1>mapDynamicTexture.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 `protected: void __cdecl AmapDynamicTexture::UpdateTextureRegions(class UTexture2D *,int,unsigned int,struct FUpdateTextureRegion2D *,unsigned int,unsigned int,unsigned char *,bool)'::`5'::EURCMacro_UpdateTextureRegionsData::DoTask(enum ENamedThreads::Type,class TRefCountPtr const &)" (?DoTask@EURCMacro_UpdateTextureRegionsData@?4??UpdateTextureRegions@AmapDynamicTexture@@IEAAXPEAVUTexture2D@@HIPEAUFUpdateTextureRegion2D@@IIPEAE_N@Z@QEAAXW4Type@ENamedThreads@@AEBV?$TRefCountPtr@VFGraphEvent@@@@@Z)

1>mapDynamicTexture.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::SetupPrereqs(class TArray,class TInlineAllocator<4,class FDefaultAllocator> > const *,enum ENamedThreads::Type,bool)” (?SetupPrereqs@?$TGraphTask@VEURCMacro_UpdateTextureRegionsData@?4??UpdateTextureRegions@AmapDynamicTexture@@IEAAXPEAVUTexture2D@@HIPEAUFUpdateTextureRegion2D@@IIPEAE_N@Z@@@AEAAXPEBV?$TArray@V?$TRefCountPtr@VFGraphEvent@@@@anonymous_user_e71e0d8a?$TInlineAllocator@$03VFDefaultAllocator@@@@@@W4Type@ENamedThreads@@_N@Z)
1>mapDynamicTexture.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::FConstructor __cdecl TGraphTask::CreateTask(class TArray,class TInlineAllocator<4,class FDefaultAllocator> > const *,enum ENamedThreads::Type)”

(?CreateTask@?$TGraphTask@VEURCMacro_UpdateTextureRegionsData@?4??UpdateTextureRegions@AmapDynamicTexture@@IEAAXPEAVUTexture2D@@HIPEAUFUpdateTextureRegion2D@@IIPEAE_N@Z@@@SA?AVFConstructor@1@PEBV?$TArray@V?$TRefCountPtr@VFGraphEvent@@@@anonymous_user_e71e0d8a?$TInlineAllocator@$03VFDefaultAllocator@@@@@@W4Type@ENamedThreads@@@Z)
1>mapDynamicTexture.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 protected: void __cdecl AmapDynamicTexture::UpdateTextureRegions(class UTexture2D *,int,unsigned int,struct FUpdateTextureRegion2D *,unsigned int,unsigned int,unsigned char *,bool)'::5’::EURCMacro_UpdateTextureRegionsData::DoTask(enum ENamedThreads::Type,class TRefCountPtr const &)” (?DoTask@EURCMacro_UpdateTextureRegionsData@?4??UpdateTextureRegions@AmapDynamicTexture@@IEAAXPEAVUTexture2D@@HIPEAUFUpdateTextureRegion2D@@IIPEAE_N@Z@QEAAXW4Type@ENamedThreads@@AEBV?$TRefCountPtr@VFGraphEvent@@@@@Z)
1>mapDynamicTexture.cpp.obj : error LNK2001: unresolved external symbol “__declspec(dllimport) class FRHICommandListExecutor GRHICommandList” (_imp?GRHICommandList@@3VFRHICommandListExecutor@@A)
1>mapDynamicTexture.cpp.obj : error LNK2001: unresolved external symbol “__declspec(dllimport) bool GIsThreadedRendering” (_imp?GIsThreadedRendering@@3_NA)
1>mapDynamicTexture.cpp.obj : error LNK2001: unresolved external symbol “__declspec(dllimport) bool GMainThreadBlockedOnRenderThread” (_imp?GMainThreadBlockedOnRenderThread@@3_NA)

Looks like you’re missing a module. Make sure you have all of the following (not sure which one addresses this linker issue);

 PrivateDependencyModuleNames.AddRange(
            new string[] { 
                "RenderCore",
                "ShaderCore",
                "RHI",
            });

If you’re not aware, this goes into your “Project”.Build.cs file

Awesome. Will check that out soon. Thanks. :slight_smile:

Hi omberone,
I am trying to follow the article you wrote, but I have not clue where the code you present needs to reside. Can you provide some more information for c++ newbies? (does the code needs to be inside an actor? does it need to be stored in a specific place? etc)

It doesn’t really matter as long as you can manipulate the dynamic material (ie, you need to have a reference to the dynamic material). We put this in an actor however since it suited us the best.

Hi Omberone, thanks for this great resource. I was wondering if you could share a complete code sample along with the article? Many of the variables aren’t declared within the scope of your code snippet and I’m wondering what types these should be, how they are declared, etc.

For example, how do I get the texture that I imported into the editor referenced in my C++ code? What data type should the list of materials be, or the list of colors? And how do I get the reference to the material I need to make a dynamic instance of?

It’s been a long time since I used C++ at all and have never used Unreal before so diving in is a little daunting. Thanks so much for the help you’ve already provided.

Hey man, sure. I’ll update the wiki with two files, one .h file and one .cpp file

Awesome, thanks so much! I was able to get my texture updating with the help of your code.