Home Unreal Engine

How to do Layered Materials in Unreal engine 4 UE4

So I Just watched the fallowing video on layered materials in unreal 4

<iframe width="1280" height="720" src="//www.youtube.com/embed/PjSFbPv3SLc?rel=0" frameborder="0" allowfullscreen></iframe>

However I just don't understand one thing about it. I understand how a Mat-layer blend node works, and how a material ID works to give coordinates to different layers. However What I don't understand is how they dragged materials in to other materials. I mean I tried dragging a material in to another material in the engine and nothing happened. Any ideas guys?

Replies

  • riot
    Offline / Send Message
    riot polycounter lvl 11
    Layered materials are actually just material functions, which are blended with other material functions, and by doing that (combining them) you create a new material.

    Actually, you don't need to set up different materials ids (you can, but its not necessary for the material layers to work). I usually do this when working with layered materials:

    1.Create a new material function (its important that its a material funcion, not just material, otherwise it won't let you use the material as a node). Then, inside the material function, add a "MakeMaterialAttributes" node, connect it to the output result and then you can start creating your material layer.

    2.Once you've got your layers, you'll need a mask to blend the materials. This will be a RGB or RGBA texture which contains a black and white mask in every channel for each material, to determine where it's going to "appear" that material. You'll need one mask less than materials (if you have 4 materials, 3 masks will be needed - I will explain why in the next points)

    3.Now create a regular material and go to the material details tab and check "Use Material Attributes" - that will get rid of the BaseColor, Normal, Roughness, etc. nodes and allow you to use the layered materials.

    4.Once you've got all set up, drag your material functions (material layers) into this new material and the mask texture. Create a new "MatLayerBlend_Standard" node and use the "main material layer" as base material (this material is going to be present on all the mesh), add another layer to the top material and the mask for that second layer on the alpha slot. This masking step puts another material on top of the previos one, but only reveals the top material where the pixels are white on the mask.

    5.Once you have all your layers blended, to add the normalmap of the whole mesh just use a "MatLayerBlend_BakedNormal" node, and if you want to add an global ao aswell, use "MatLayerBlend_AO".

    6.Finally, connect the last node (usually the ao or normal blend node) to the node where it says "Material Attributes" and you should have you layered material ready.

    Hope it helped! :)
  • VisceralD
    Ok this was very helpful, but I’m confused about the final steps. So I added the matlayerblend_baked normal and then I wanted to add a matLayerBlend_AO. I input the blended material from the matlayered_blend normal in to the material area of the matlayer blend AO. And then connected the blended material of that in to the material attributes. But got an error, how am I supposed to connect it?

    Really what might be most helpful is a high quality screenshot of how the nodes are supposed to be interconnected.

    Again thank you so much for your help.
  • riot
    Offline / Send Message
    riot polycounter lvl 11
    You're welcome, glad I could help :)

    Be careful when connecting the texture to the ao slot because it asks you for an (S) value (which I believe means scalar), not a (V3) (which I also believe means vector3). Because of that, you should only connect one channel,(for example the red channel, doesn't matter really since they're all the same in a grayscale ao texture), not the whole ao texture(rgb).Or you could pack the ao in the alhpa channel of another texture, like the normalmap, to save memory and optimize the shader.

    Also, be careful with how many textures you have. If you'te going to use a texture across different material layers, use FunctionInput nodes (scalar for one channel, vector3 for rgb texture) and then use it from the main material, not the layers. Otherwise, if you use the same texture sampler inside many layers, it quickly piles up and if you reach more than 15 texture samplers, the engine will give you an error when trying to compile.

    Here's how I have set up the last nodes, but its really simple: http://fc05.deviantart.net/fs70/f/2014/115/0/3/nodes_by_skate54-d7fvnz3.png
    Its important to note that what goes into the AO slot is a channel from a texture, not a whole rgb texture.

    I'm showing just that part because the rest of the material is a mess and you could get really confused just by looking at it xD
  • VisceralD
    Ok that explains it but I have a fallow up question to this then, How can I do like add a textrcoord(tile) or a panner to the material function inside another material. I want to be able to tile it specifically to the object I'm working on. So I don't want to do it in a material function because I need specific tiling for every object. Again a screenshot of how you would connect it will help as well.

    Thank you
  • riot
    Offline / Send Message
    riot polycounter lvl 11
    If I understand you correctly, you're trying to tile a texture inside a layered material from the main material. You could do that like this http://fc06.deviantart.net/fs71/f/2014/115/f/6/untitled_1_by_skate54-d7fvuyn.png
  • VisceralD
    How did you get the input texture tile scalar. I'm curious will this tiler it only in the main material, or everywhere, where the material function is used.
  • riot
    Offline / Send Message
    riot polycounter lvl 11
    You have to change it on the details tab, there is a dropdown that, by default is vector3, you should change that to scalar. I believe it only changes on the main material. Also, if you would use the same function in the same material more than one time but assign diferent values to the tiling input, it would tile differently according to the different scalar values.

    Everytime you "call" the function(drop it into the editor), it will require you to input a scalar value in that field, so yeah, you can use the same function multiple times with different scalar values in your projects, it should work fine.
  • VisceralD
    So how would you apply that to a panner or rotator, Can't I just plug my material function in to some-kind of placeholder node. Then just apply those qualities to that.
  • beefaroni
    Offline / Send Message
    beefaroni sublime tool
    Hey, this thread showed up on Google so I figured I'd bump it because I'm running into a wall :(

    Edit: Here is the fix

    CYDOLuP.png

    MwbFDmM.png
  • Jose.D
    Offline / Send Message
    Jose.D polycounter lvl 8
    I'm new to UE4, right now I'm trying to create a simple layered material (based on this tutorial). I created the material functions, used a MatLayerBlend_Standard (tryed "_Simple" too), I checked the "use material attibutes" option and the "material attributes" node is not showing, appears "Customized UV5" instead and doesn't let me link the blended material output to it.

    I read the documentation but it says nothing about that issue.
    Any ideas on what could be causing the problem, what am I doing wrong? :/


    Gjq2jSk.png
  • ed_3D
    That's odd, which version of UE4 are you using? I tried to replicate the problem but it's always showing up as Material Attributes for me on 4.8 preview 2. Have you tried creating a new material just to tick Use Material Attributes and see if it still acts the same?
  • Jose.D
    Offline / Send Message
    Jose.D polycounter lvl 8
    We're using 4.5.1, we tested it on multiple computers... same results, is showing "customized uv5" instead of "material attributes" :/
  • ed_3D
    Maybe try to plug it in anyway? Might be just the label that is wrong :D. If not then I have no idea, could only suggest to upgrade to another version of the engine.

    If you haven't already, you should post the problem up on UE4 AnswerHub, the devs should be able to help you out :)https://answers.unrealengine.com/

    edit:
    I think there is a workaround if you can't come up with a fix. If you untick "Use Material Attributes", and add a "BreakMaterialAttributes" node in, you can connect your output to it to break it off and then connect each of the nodes to where ever they should go i.e. BaseColor to BaseColor and so on
  • Jose.D
    Offline / Send Message
    Jose.D polycounter lvl 8
    Thanks! We're posting the question right now. We tried to break the attributes appart, but we need to blend a sss mat. and a metallic mat., and it appears that the main material doesn't allow to connect both attributes at the same time (when I use a default lit shader it disables the subsurface attr. and when I use a subsurface shader. it disables the metallic attribute input)
Sign In or Register to comment.