Home Technical Talk

[UE4 Shaders] Is there a way to call a (Material Function) with in a (Material Instance)?

polycounter lvl 12
Offline / Send Message
BARDLER polycounter lvl 12
I am trying to build a blend shader that blends together 4 different tileable materials through a RGB texture or vertex color. Here it is working:

Right now its all hard coded into the shader and it works fine, but I want to organize it so I can use Material Instances.

Here is my issue, I want to be able use prepacked material functions because I can hook up all the tileable textures I need to the material function instead of hooking up every tileable texture to every layer of the material instance. Here are some screenshots to help show what I mean.
Material Function 1, for a tileable red brick:


Here is how I am using the material function of the tileable red brick in the base shader:


Here is what I want my material instance to look like:


I know I can individually hook up every texture in the material instance, but I really want to figure out how to use these material functions as quick presets to grab and change materials around.

Thanks for any help with this!

Replies

  • Obscura
    Options
    Offline / Send Message
    Obscura grand marshal polycounter
    You won't be able to set them up in the way you want, but it is  possible to enable/disable them, base on a scalar. Currently I'm working on something similar... So first you need a scalar to tell it how much layers you want. Then I would use an another function, and inside that, there would be some 'if"s, and based on those it would return different outputs, like 4 layers, 3 layers, or only 2 layers.

    If number of layers = 4 then return the 4 blended layers
    if number or layers is less then 4, then look if its equal to 3. If so, then return it without the top layer. If number of layers is less then 3, then look if its equal to 2 etc...

    This is what I do, and it works nicely for me, but its a bit different from how you want to use it, so you may want to change the function inputs from float to material attribute. I use it so affect channels of the material. If you need further assistance then shoot me a message, and I can explain how to change it to your need.


  • BARDLER
    Options
    Offline / Send Message
    BARDLER polycounter lvl 12
    That is a great help for organization. Thank you for the tip. I did some digging on the forums and documentation and I can solve this problem with a custom written node. I don't know much programming so I might have to bug some friends.
  • genwu
    Options
    Offline / Send Message
    genwu polycounter lvl 7
    I'll be curious to hear how/if you can come up with a solution for this, as I've been trying to do the same thing - using functions to drive vert blending through an instance rather than through a main shader, but failing. Goodluck!
Sign In or Register to comment.