[Question] Setting materials for LOD1 and LOD2 via Blueprint

I imported a mesh with 3 LODs. Using Blueprint am randomly assigning different materials to index 1. Now this is not a problem for LOD0 as it works the way it should. However LOD1 and LOD2 doesnt seem to set these materials. They render the default checker material.

So i thought of two possible solutions. Either get LOD1 and LOD2 in BP and set their materials or create a Material Instance Constant (I’ll call this MIC for short) in Content Browser and assign it to the mesh and assign different textures to MIC via BP.

Step 1 failed because there is no way of accessing LOD’s in Blueprint. So i moved to Step 2 and created a MIC variable → assigned the MIC Material to it. Now when i try to use this variable there is no way of setting any parameters for MIC.

mic.jpg

So my question is simple. Event BeginPlay is connected to Set Material. As i said this only affects LOD0. How can i set this material for all other LOD’s?

Do you want the same material to be applied to LOD0, 1, and 2? Or you want to use different materials?

As for your MIC question, what you need to do is use CreateMIDForElement or CreateMIDForElementFromMaterial to create a dynamic material instance from the MIC. That will allow you to modify the parameters on the material at runtime.

Do you want the same material to be applied to LOD0, 1, and 2? Or you want to use different materials?

Yes i want the same material to be applied to LOD0, 1 and 2.

As for your MIC question, what you need to do is use CreateMIDForElement or CreateMIDForElementFromMaterial to create a dynamic material instance from the MIC. That will allow you to modify the parameters on the material at runtime.

Am aware of this but it only affects LOD0. LOD1 and 2 still renders the default checker material.

This answer had been marked as “Accepted”, which is why there was no follow-up response. I have removed the accepted status, and it will be answered as soon as possible.

Cheers!

In the static mesh editor, open up LOD1 and for each section click the “reset to default” button next to the material. This should lock it to the same numbered material in LOD0.

That should have been the default but maybe there is a bug there – let me know if that works!

Theres no Reset To Default button but theres a Reset To Base Material (yellow arrow) button near the materials. I clicked and now the material is the default checker material. Still LOD1 is rendering the default material.

Looks like this is a bug in the editor – I’ve entered a TTP to get it fixed.

In the meantime you should be able to workaround this. If your LODs have unique materials they will have an index you can use to override them in blueprint. By default they are laid out in order. As an example, let’s say LOD0 has 3 materials and so does LOD1. Then in Blueprint material indices 0, 1, and 2 will control the materials for LOD0 and indices 3, 4, and 5 will control the material for LOD1.

So if you assign the same material to indices 0 and 3, the first material slot of your LODs will share that material.

This is definitely an area that needs improvement – sorry for the complexity!

Awesome Nick!!..Works perfectly. Thank you. :slight_smile:

Umm…shouldn’t there be a “LOD Index” in addition to the “Element Index”(which’ll remove all ambiguity) in the 1st place?

its september 2016 now and this still seems to be a mess. my lods have different amount of elements and i need to switch a parameter on one material that is on different elements of the different lods. how can i access them???