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"

DynamicMaterial breaks DecalComponent

I have an Actor that I've defined in C++ with a UDecalComponent. The material I'm using has some parameters that I want to change dynamically, so I create a DynamicMaterialInstance in the OnConstruction function of my actor:

  void ADecalTestActor::OnConstruction(const FTransform& transform)
      _decalMaterial = Decal->CreateDynamicMaterialInstance();

I've found that if the actor is already placed in the level before I add this code, it works perfectly fine Working

But if I run the editor with that code snippet it just displays a grey-green texture instead Broken

I was able to repro this with a new project using the simplest material I could think of Material

It seems the problem lies with creating the DynamicMaterialInstance in the construction script but I'd like the decal to be accurate when viewing the level in the editor window and not just when playing the game.

Product Version: UE 4.10
workingdecal.png (710.9 kB)
brokendecal.png (653.0 kB)
simplematerial.png (53.2 kB)
more ▼

asked Nov 20 '15 at 10:53 PM in Bug Reports

avatar image

919 40 61 206

avatar image Lovecraft_K ♦♦ STAFF Nov 23 '15 at 07:05 PM

Hello -

Can you take a look at this test project and see if you can identify (besides being a BP) any differences as to how you are calling your MID?

Thank You -

Eric Ketchum

Test Project 4.10.0

ah_decalmid.zip (473.0 kB)
avatar image kgamble Nov 23 '15 at 11:34 PM

The only things that stood out to me were that the material for the decal was set in the class defaults instead of the details panel in the level and that I used the top-down template instead of an empty project. I made a BP-only project using the top-down template and was able to repro the problem. I've uploaded it to https://www.dropbox.com/s/0e2v4kpcb6rnq4b/DecalTestBP.zip?dl=0

And in case you want to see it as well, my C++ test project is at https://www.dropbox.com/s/x5z87s193ryu2ot/DecalTest.zip?dl=0

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

1 answer: sort voted first

Hi kgamble -

In your BP project, the Material you have used to create a Dynamic Material from is not set to be a Decal Material in the Material Attributes. This is necessary even if you are using a Dynamic Material Instance.

If you go into the Decal Material and Change the Material Domain from Surface to Deferred Decal, your Blueprint project will work correctly.

In your code project you have actually set up a Dynamic Material Instance but you have not told the MID exactly what Material to be created from. If you want that to be exposed you can create a variable linked to the UMaterial property in code that you can assign a Decal Material in the Editor. Currently you have only a MID that can be assigned, with no way to link a base material to it.

Thank You

Eric Ketchum

more ▼

answered Nov 30 '15 at 03:13 PM

avatar image

Lovecraft_K ♦♦ STAFF
36.7k 702 260 735

avatar image kgamble Dec 02 '15 at 05:08 PM

Thanks, got it working now. The BP one was just an oversight on my part, guess I just forgot to change its domain. For the C++ side, I guess I was confused by the order things were done. I had changed the material in the Details panel once I had placed it but it seems my code in OnConstruction was overriding that. Added something to set the material before creating the MID and it works the way I was expecting.

avatar image AJ_Graphix Jul 28 '17 at 09:03 PM

Hey Eric, sorry to break the resolved status of this post, but thanks to your helpful test project, I discovered why the decal's dynamic material instance would always show up as the default decal material inside the level. Apparently, you cannot have the decal as the root of the blueprint, which means you cannot have a dynamic material in a blueprint whose Parent Class is decal actor. You must first choose actor, then manually add a decal component. This is how your BP test project was setup, and this is the only way that works. Not sure if that's by design, or a bug.

Thanks again for your help!


(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