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"

Change Landscape component material at game run-time?


I can Create Dynamic Material Instance, use Set Material function (Target is Primitive Component, the node says so) for StaticMeshComponent.

However, for LandscapeComponent, neither Set Material function nor Set Override Material (just an exposed property, although BlueprintReadWrite) works, nothing happens using them.




I even can write a function, SetOverrideMaterial(UMaterialInterface* Material), in ULandscapeComponent:

 OverridedMaterial = Material;

The component's material is changed, but is shown as the default material (checker), although in Blueprint if I get that Overrided Material, Get Base Material, it is the material I set.



ULandscapeComponent::GetLandscapeMaterial() in Landscape.cpp is inclosed in "#if WITH_EDITOR".

All references to ULandscapeComponent::OverrideMaterial are inclosed in "#if WITH_EDITOR".

Product Version: UE 4.9
more ▼

asked Dec 23 '15 at 12:00 PM in Blueprint Scripting

avatar image

181 14 21 32

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

2 answers: sort voted first

Changing the entire material in UpdateMaterialInstances is really heavyweight and isn't suitable for use outside the editor.

But we should be able to make a change so the landscape components have a MaterialInstanceDynamic in the front of them, allowing the user to adjust parameter values for nodes that were created in the original Landscape Material.

I've just added a feature request for that under UE-24979

At the moment each component has a MaterialInstanceConstant which points to another MIC (which is shared between components with the same layer usage) which finally points to the LandscapeMaterial.

The final MIC is stored in the MaterialInstance property of the LandscapeComponent. You could change that property to be a MaterialInstanceDynamic and change the code in UpdateMaterialInstances to create a M.I.D instead, under the comment "// Create the instance for this component, that will use the layer combination instance.".

After making this change and then modifying the LandscapeMaterial, each component should be allocated its own MaterialInstanceDynamic and you should be able to change parameters on it at will.

If you do end up getting this to work, please consider submitting a pull request.

  • Jack

more ▼

answered Jan 06 '16 at 10:59 AM

avatar image

1.3k 37 11 48

avatar image PowerDesign Jan 06 '16 at 02:40 PM

Thank you for the info, Jack!

I want to use 2 MIDs: MIDNear and MIDFar. Everything else is the same between the 2, except MIDNear has Tessellation. I probably don't need to change parameters.

Components are large enough, if at any time at most 4 components use MIDNear, a camera movement will results in about 2 components changing materials dynamically.

So, I should need another map (like LandscapeProxy's MaterialInstanceConstantMap) for the Far material.

I want something like what is implemented here: https://ogre3d.atlassian.net/browse/OGRE-204

avatar image eyosido Jan 15 '18 at 10:55 AM

@JackP_oldaccount : any update on this? UE-24979 does not exist anymore, what is the status of dynamic material instances for landscapes? In my testings it doesn't seem to work on 4.18.2.

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

I think the target for the dynamic material instance should be the mesh, not the Primitive Component, unless its the mesh object itself, but if that's not it, there is a different way of doing it which I prefer, because it allows gradual changes, basically it involves changing material properties at runtime, its the one way I know how to do this so far:

https://www.youtube.com/watch?v=IqqzKvBc9hc (Dynamic Snow tutorial by Liaret)

more ▼

answered Jan 05 '16 at 12:47 AM

avatar image

66 1 6 9

avatar image PowerDesign Jan 05 '16 at 01:59 AM

Materials can be assigned to StaticMeshComponent, or LandscapeComponent (Landscape mode > Manage > Selection tool to select components > Override Material). It's components.

I think you can only change material instance parameters at run-time, but not material properties like Tessellation.

(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