x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Performance cost of Dynamic Material Instance?

Hi!

I figured whenever I created a Dynamic Material Instance, a new material was made with a number at the end, eg : MaterialInstanceDynamic_345 , and it keeps increasing as I called it from my blueprint.

Let's say I create a dynamic material instance each time I clicked a mouse button, does it overwrite the old one? or is it still stored somewhere? Is there something I should be aware when creating a dynamic material instance? That number makes me feel uneasy :|

cheers!

Product Version: UE 4.10
Tags:
more ▼

asked Feb 17 '16 at 07:33 PM in Using UE4

avatar image

vanadot
13 1 2 4

avatar image lukefwilson Jul 14 '16 at 07:11 AM

I'm also curious about this. I'm currently assuming it's just a memory cost.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

Hey Vanadot & lukefwilson,

A Dynamic Material Instance (DMI) should be created in the Construction Script of the object it will be applied to, and then have the result of the "Create Dynamic Material Instance" node saved to a variable immediately after creation.

Once that occurs you can use the DMI variable to call any of the "Set Scalar/Vector Parameter" functions to update the material instance in the event graph on tick, or begin play etc. Because you created and use the DMI variable, you are not creating a new instance each time you make a change.

I have seen a few examples where people forget to save the DMI variable, or create the dynamic instance somewhere other than the construction script, both of which will either cause an error or will create a new instance on each change. So long as you do what I mentioned in the first paragraph above, the performance is not an issue, it will be nearly as fast as using a normal material instance, and will not increase the "number" you mentioned in the original post.

Cheers,

DC

more ▼

answered Jul 14 '16 at 03:37 PM

avatar image

DotCam
3.1k 74 34 147

avatar image Araklaj Apr 17 '17 at 06:40 PM

I'm noticing that the number of DMI is still increasing as soon as you move the BP that is instanced in the level, as the construction script, which creates DMI, is re-run each time then. Is that normal, and no way to avoid it?

avatar image Spoondog Nov 20 '17 at 08:36 PM

As long as you do as DotCam says and assign the DMI to a variable once it's created, and check that variable before creating one, then it should be fine. Note that the DMI variable must be exposed (Instance Editable), else the Construction Script can't set it and will keep thinking it's empty.

alt text

Other option, if you don't need to see it in the editor, is to do it in BeginPlay instead of Construction Script, then the variable doesn't have to be Instance Editable and you know it's only going to happen once.

dmicreate.png (69.0 kB)
(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question