# Use a Material File

**URL:** <https://forums.unrealengine.com/t/use-a-material-file/232159>\
**Category:** C++\
**Tags:** unreal-engine\
**Created:** [May 29, 2021, 11:16am UTC](https://forums.unrealengine.com/t/use-a-material-file/232159 "2021-05-29T11:16:17Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sergiotronik14](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Sergiotronik14](https://forums.unrealengine.com/u/Sergiotronik14)\
**Post date:** [May 29, 2021, 11:16am UTC](https://forums.unrealengine.com/t/use-a-material-file/232159/1 "2021-05-29T11:16:18Z")

</div>

Hi everybody, i am trying to load UMaterial from uassert files using the path, this material aren´t in the editor, only i have the file, this is the code:

||UMaterialInstanceDynamic\* Dyn;  
FString sPath = FPaths::ProjectDir() + FString(“Materials/00\_Mat.00\_Mat”);

```
UMaterial* mat = Cast<UMaterial>(StaticLoadObject(UMaterial::StaticClass(), nullptr, *sPath));

if (mat != nullptr) {
	Dyn = UMaterialInstanceDynamic::Create(mat, Mesh);
	UE_LOG(LogTemp, Warning, TEXT("material "));
}

```

the problem is never encounter the material but when i add the material to the project works, is it possible use a material witout the material is in the editor?

thanks

---

<div class="post-metadata">

**Author:** ![jwatte](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/jwatte/32/744941_2.png) [@jwatte](https://forums.unrealengine.com/u/jwatte)\
**Post date:** [May 30, 2021, 9:02pm UTC](https://forums.unrealengine.com/t/use-a-material-file/232159/2 "2021-05-30T21:02:34Z")

</div>

The editor processes and packages up all kinds of assets as part of the build process (and while you edit, in the background, so that you can preview these.)  
Without having the built asset, you cannot use it in the game.  
If you’re making a plugin, plugins can have their own Content directory, where you can put input assets used by classes in that plugin.

Why would you not add the material to the editor?

---

<div class="post-metadata">

**Author:** ![Sergiotronik14](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Sergiotronik14](https://forums.unrealengine.com/u/Sergiotronik14)\
**Post date:** [May 30, 2021, 10:52pm UTC](https://forums.unrealengine.com/t/use-a-material-file/232159/3 "2021-05-30T22:52:15Z")

</div>

Thank for your answer,

I am doing a function,which created terrain reading different files, every terrain have a different file and i can create more terrain adding more file, and my idea is, the texture,the material, can be added reading a file because i need the user can add his texture using his texture file for create different terrain without the editor only the proyect after packing.

i need the user can create different terrain without use the editor, but If It is not posible, i Will add different material and i Will get a list with the different material.

Thank you.

---

<div class="post-metadata">

**Author:** ![jwatte](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/jwatte/32/744941_2.png) [@jwatte](https://forums.unrealengine.com/u/jwatte)\
**Post date:** [May 31, 2021, 4:31am UTC](https://forums.unrealengine.com/t/use-a-material-file/232159/4 "2021-05-31T04:31:37Z")

</div>

You can make the texture be a parameter of the material, and create a dynamic material instance, and then configure a runtime generated (loaded) texture into that material.

A: terrain → material → Dynamic Material Instance (“MID”)  
B: texture on disk → bitmap in RAM → Runtime texture  
Configure B as the texture parameter on A. Done!

You may need to use a little bit of C++, but there’s reasonable suggestions of a few different approaches:

> **[Is it possible to load an image at runtime?](https://forums.unrealengine.com/questions/205006/is-it-possible-to-load-an-image-at-runtime.html)**
>
> I am making a game where the player can have custom emblems. My question is: Is it possible to load an image at runtime to use it as an emblem?

It mainly boils down to using something like Ramas plugin (or writing your own similar C++ code):

> [@(39) 's Extra Blueprint Nodes for You as a Plugin, No C++ Required!](https://forums.unrealengine.com/t/39-ramas-extra-blueprint-nodes-for-you-as-a-plugin-no-c-required/3448#post210419):
>
> Dear Community, star2 Newest Awesome star2 (In Complimentary (no cost) Victory Plugin!) Now You Can Get the Text Output (STDOUT or STDERR) from any .exe program, straight into Unreal Engine! is the output of zap a video compression commandline tool ([Handbrake](https://handbrake.fr/)), zap launched by your UE game & delivered straight into the Unreal Engine Viewport! zap rose Using only 3 Blueprints nodes! rose zap[Full Details and UE4 C++ Code](https://forums.unrealengine.com/t/39-ramas-extra-blueprint-nodes-for-you-as-a-plugin-no-c-required/3448/2644) MIT Software License for The…

---

<div class="post-metadata">

**Author:** ![Sergiotronik14](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Sergiotronik14](https://forums.unrealengine.com/u/Sergiotronik14)\
**Post date:** [May 31, 2021, 6:59pm UTC](https://forums.unrealengine.com/t/use-a-material-file/232159/5 "2021-05-31T18:59:34Z")

</div>

thank you , i am going to try this night and i tell if i have luck, i would use Ramas plugin but i can´t use anything that i don´t created

---

<div class="post-metadata">

**Author:** ![jwatte](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/jwatte/32/744941_2.png) [@jwatte](https://forums.unrealengine.com/u/jwatte)\
**Post date:** [June 1, 2021, 7:22pm UTC](https://forums.unrealengine.com/t/use-a-material-file/232159/6 "2021-06-01T19:22:17Z")

</div>

Presumably you can learn by reading the code, though!
