# Save and apply in-game modifications to Material Instance?

**URL:** <https://forums.unrealengine.com/t/save-and-apply-in-game-modifications-to-material-instance/360361>\
**Category:** Asset Creation\
**Tags:** unreal-engine, Blueprint, question\
**Created:** [June 10, 2016, 8:44pm UTC](https://forums.unrealengine.com/t/save-and-apply-in-game-modifications-to-material-instance/360361 "2016-06-10T20:44:50Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![aaronkaminer](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@aaronkaminer](https://forums.unrealengine.com/u/aaronkaminer)\
**Post date:** [June 10, 2016, 8:44pm UTC](https://forums.unrealengine.com/t/save-and-apply-in-game-modifications-to-material-instance/360361/1 "2016-06-10T20:44:50Z")

</div>

I am writing a blueprint “game” that allows the user to play with scalar parameters of a material instance via a umg ui. I can modify a material instance at runtime… I would like to save those new scalar values and apply them to the material instance once the game is exited. I don’t want that info to only live with a saved game but rather I want it to actually propagate to the material instance itself. Is this possible via blueprint alone?

Use case: Right now I am using set scalar parameter (target is mesh component) and retrieving the slider value from the umg ui I created. If I change the roughness of a material all the way to zero… and close the game… I want the edited material instance to retain that new roughness value of zero.

Also (side note) I have read the ue4 documentation about creating a dynamic material instance in order to modify at run-time. While this does work…I have found that I do not need to do so. I can simply set scalar parameter on the material of a mesh component without actually creating a dynamic material instance. Is this process happening automatically? Or do both methods yield the same result?

---

<div class="post-metadata">

**Author:** ![aaronkaminer](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@aaronkaminer](https://forums.unrealengine.com/u/aaronkaminer)\
**Post date:** [June 13, 2016, 12:25am UTC](https://forums.unrealengine.com/t/save-and-apply-in-game-modifications-to-material-instance/360361/2 "2016-06-13T00:25:54Z")

</div>

No word on this one? Just to clarify…

Is it possible to save modified parameters from a dynamic material instance and then apply them to the original material instance via blueprint after the game is exited?

---

<div class="post-metadata">

**Author:** ![Dodgin](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Dodgin](https://forums.unrealengine.com/u/Dodgin)\
**Post date:** [June 13, 2016, 4:00pm UTC](https://forums.unrealengine.com/t/save-and-apply-in-game-modifications-to-material-instance/360361/3 "2016-06-13T16:00:17Z")

</div>

I would save the parameters out to a file in some arbitrary format, then have a function that loads the parameters from said format into a dynamic material instance.

---

<div class="post-metadata">

**Author:** ![aaronkaminer](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@aaronkaminer](https://forums.unrealengine.com/u/aaronkaminer)\
**Post date:** [June 13, 2016, 4:06pm UTC](https://forums.unrealengine.com/t/save-and-apply-in-game-modifications-to-material-instance/360361/4 "2016-06-13T16:06:57Z")

</div>

Sure, this works for saving and loading dynamic materials. But i want to pass those stored parameters from a saved game object to a material instance constant that already exists in the project. Basically pull info from the game and actually apply it to a uasset after game exit.

---

<div class="post-metadata">

**Author:** ![Dodgin](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Dodgin](https://forums.unrealengine.com/u/Dodgin)\
**Post date:** [June 13, 2016, 7:28pm UTC](https://forums.unrealengine.com/t/save-and-apply-in-game-modifications-to-material-instance/360361/5 "2016-06-13T19:28:46Z")

</div>

What is the use case for this? Uassets don’t exist after a game is packaged.

---

<div class="post-metadata">

**Author:** ![aaronkaminer](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@aaronkaminer](https://forums.unrealengine.com/u/aaronkaminer)\
**Post date:** [June 13, 2016, 8:19pm UTC](https://forums.unrealengine.com/t/save-and-apply-in-game-modifications-to-material-instance/360361/6 "2016-06-13T20:19:02Z")

</div>

> **[Marmoset Style UE4 Setup](https://forums.unrealengine.com/showthread.php?112880-Marmoset-Style-UE4-Setup)**
>
> Polycount thread here. NEW TEASER VIDEO: LATEST IMAGES (Original Post) Hello all, Recently I decided to start work on a personal tool that would help me achieve high quality renders from UE4 like I would typically get from...

I want to launch a game that allows the player to customize a dynamic material instance. Then upon save I want to store those parameters in a save game object. But… this doesn’t change the material instance itself… so if I wanted to use this as a previs tool… all modifications would live with the game but I need them to propagate to the material that the dynamic material instance was created from. Is there a way to take the save game object data and pass it to a material .uasset?

---

<div class="post-metadata">

**Author:** ![Dodgin](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Dodgin](https://forums.unrealengine.com/u/Dodgin)\
**Post date:** [June 13, 2016, 10:44pm UTC](https://forums.unrealengine.com/t/save-and-apply-in-game-modifications-to-material-instance/360361/7 "2016-06-13T22:44:06Z")

</div>

I’d say you have two routes here:

1. Make an actor that autoloads the parameters from a save file into the dynamic material instance of your choice in it’s constructor script.
2. Extend the Material Instance class in C++ to autoload from a save file, achieving the above but in it’s own new class.

I’d go with 1

---

<div class="post-metadata">

**Author:** ![Dodgin](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Dodgin](https://forums.unrealengine.com/u/Dodgin)\
**Post date:** [June 13, 2016, 10:47pm UTC](https://forums.unrealengine.com/t/save-and-apply-in-game-modifications-to-material-instance/360361/8 "2016-06-13T22:47:02Z")

</div>

This is kind of exactly what dynamic material instances are for. They are a template that you can modify parameters for at runtime

---

<div class="post-metadata">

**Author:** ![aaronkaminer](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@aaronkaminer](https://forums.unrealengine.com/u/aaronkaminer)\
**Post date:** [June 13, 2016, 10:51pm UTC](https://forums.unrealengine.com/t/save-and-apply-in-game-modifications-to-material-instance/360361/9 "2016-06-13T22:51:57Z")

</div>

Agreed. It doesnt sound like I can do what I want to do with bp since I need to do one of the following

1. modify a material instance constant without making a dynamic version that is lost after game closes.
2. transfer info from the dynamic material instance to a material instance constant after game close.

---

<div class="post-metadata">

**Author:** ![Dodgin](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Dodgin](https://forums.unrealengine.com/u/Dodgin)\
**Post date:** [June 13, 2016, 11:22pm UTC](https://forums.unrealengine.com/t/save-and-apply-in-game-modifications-to-material-instance/360361/10 "2016-06-13T23:22:43Z")

</div>

well you can do it fine with BP, you just need to make the BP logic to save and read from files. it will read whatevers in the file when the game starts up

---

<div class="post-metadata">

**Author:** ![Dodgin](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Dodgin](https://forums.unrealengine.com/u/Dodgin)\
**Post date:** [June 14, 2016, 3:03pm UTC](https://forums.unrealengine.com/t/save-and-apply-in-game-modifications-to-material-instance/360361/11 "2016-06-14T15:03:22Z")

</div>

do this:

1. player starts game
2. dynamic material instance is created
3. player closes game or hits save
4. dynamic material instance variables are stored persistently via [https://docs.unrealengine.com/latest/INT/Gameplay/SaveGame/Blueprints/index.html](https://docs.unrealengine.com/latest/INT/Gameplay/SaveGame/Blueprints/index.html)
5. player starts game
6. dynamic material instance vars are loaded if present
7. you have persistence 🙂

---

<div class="post-metadata">

**Author:** ![aaronkaminer](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@aaronkaminer](https://forums.unrealengine.com/u/aaronkaminer)\
**Post date:** [June 15, 2016, 4:59pm UTC](https://forums.unrealengine.com/t/save-and-apply-in-game-modifications-to-material-instance/360361/12 "2016-06-15T16:59:55Z")

</div>

I think I am not articulating my problem well enough. I know how to save and load these parameters… which means in game persistence. However, I want the actual material source to be modified after run-time.Let me explain.

1. I run the game…
2. The bp creates a dynamic material instance of " M\_Material\_001"
3. Player modifies the parameters.
4. Player closes game
5. M\_Material\_001 somehow inherits the modified parameters from the dynamic material instance.

This is not a problem related to game persistence. It is a basically trying to recreate the functionality of the material instance editor inside a game.

---

<div class="post-metadata">

**Author:** ![aaronkaminer](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@aaronkaminer](https://forums.unrealengine.com/u/aaronkaminer)\
**Post date:** [June 15, 2016, 5:02pm UTC](https://forums.unrealengine.com/t/save-and-apply-in-game-modifications-to-material-instance/360361/13 "2016-06-15T17:02:43Z")

</div>

Essentially I am trying to propagate modified material parameters from the dynamic material instance (created at runtime) back to the original material instance from which the dynamic one was created.

---

<div class="post-metadata">

**Author:** ![TheCoffeeKnight](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/thecoffeeknight/32/88719_2.png) [@TheCoffeeKnight](https://forums.unrealengine.com/u/TheCoffeeKnight)\
**Post date:** [October 14, 2024, 2:45pm UTC](https://forums.unrealengine.com/t/save-and-apply-in-game-modifications-to-material-instance/360361/14 "2024-10-14T14:45:03Z")

</div>

Posting this here for posterity. The comments were correct in handling it.

Sequence is as follows.

1. Load settings from file, applied to base material.
2. Adjust settings from material instance
3. Save settings from material instance into file.

You’re saving the settings that you make in the runtime, but in order for those settings to propagate they need to be set as the new defaults to the material that the instance stems from. If you’re concerned about needing like a Reset or something, you can always have a base settings file that can be loaded at any time.
