get Break Hit Result material (rendering material not physical material)

Hello,

I cannot seem to find a way to get the material (or the material element index) from the break hit result, when the line trace hits an object that has multiple materials. I sometimes have a wall actor (one static mesh) that has multiple materials assigned to it (as that wall belongs to multiple rooms). But there is only a Phys Mat in the break hit result. This won’t help me, beacuse there is no way to get the actual rendering material from the Physical Material (that I am aware of). Even if there is a way to get the rendering material, there is little use of it because, in my pipeline (and I believe in many other peoples pipelines) I have one base material and I make instances of that base material to create other specific materials (metal, wood, plastic etc…). And the Physic material attaches only to base materials, not to instances (as far as I am aware of).

Other people have also asked for such feature, and here are a few posts that I’ve found:

Many of the solutions that are proposed in these threads are to make multiple actors of that one actor that has many materials applied to it. In this way there will be one material per object. So instead of having one object with multiple materials, there will be several smaller objects with just one material each. This is also not a viable solution, because this can cause serious light leaks to appear, when baking the lightmaps on those smaller objects that should be one monolithic object (that would be baked correctly). This way of working has more drawbacks such as:

  • It is more time consuming to prepare the assets beforehand (that is to chop up the one solid object into smaller objects, so that each of those objects have only one material)
  • Since there are more objects with one material, it is very unflexibile if in the future you decide to rearange the materials (to add or to remove some of the materials). This would mean that I have to reattach the smaller objects together, which in term means that I would need to readjust the UVs as well. And since I’ve changed the UVs, if I have hand painted textures on those UVs, I need to repaint the textures… and this whole pipeline as you can see, just keeps on getting more complicated…

That is why I’d like to request for the break hit result to have a material or at least material element index (as integer) output. So we can later edit or change the returned material of just that part of the object that the line trace hit. I’m sure that other people are interested in this feature.

Thanks

sounds like this would also be a solution for you:

… if it were to be implemented
it was added as UE-22749, which then got set as duplicate from UE-14372, which is currently backlogged

But this still uses the physical materials, which would be very unoptimized way of working - let’s say there are 20 rendering materials, that means that I would still need to make 20 duplicate physical materials.

I don’t see why you need to duplicate anything. You can currently assign PhysicalMaterials to instances, and it’s only natural that my proposed method would allow to change any sub-PhysMats per-instance (hardcoding them in the parent Material would defeat the purpose of the feature)
so if they were to implement this feature, you’d need to create one PhysMat per “material type” (i.e. one for Steel, one for Plastic, etc) and be able swap them in material instances much like you can swap textures right now

btw you might get away with it, just by assigning a PhysMat to your MaterialInstance in the first place (yes you can do this, just open a MaterialInstance and you’ll see it). maaaaaybe the HitResult actually returns the PhysMat per MatInstance instead of per Actor, which would solve your issue (since you’re using multi-materials)

I’d like to thank the Unreal team for making this available in UE 4.16. :slight_smile:

How you can get hit material in 4.16? (or even 4.18)

See this example:https://youtube.com/watch?v=SvsSnkwB1TQ
Also search **Detect Material on Mesh Surfaces **in the 4.16 release notes.