How do I connect more than 1 scalar for Metallic, Specular, and Roughness to 2 separate landscape layers? I need to do it for base color, at least, if not for normals layers too. I’m simply trying to get two paintable layers for a landscape that has landmass brushes I need to paint on in addition to the main landscape. The textures are the same for both of the paint layers, but one is metallic-like / shiny, while the first layer is a rocky layer.
The parts before that are simply a macro variation and a randomized texture variation. I’m not sure how to get both normal maps and base texture maps combined with the two variation setups either, at least before plugging them in the landscape layer blend node. Do I simply multiply them all together, one after another? or use lerps somehow? Any help for this?
Really depends on what you are after.
I don’t normally bother macro blending normals as you’d be hard-pressed to notice differences anyway.
Multiple Scalar parameters do little to performance, they aren’t free, but if you can get away with it it’s a solid choice.
Blending macro into spec or rough is also more of a nuisance than something you’ll ever notice.
It may actually make the baked impostors (if you ever need them) look off.
The base color is your most important part.
Roughness, usually because of performance is derived from the base color.
Channe R or G depending on what looks better, maybe with some math to ramp it up or down.
The least amount of textures you use, the more layers you can have with decent performance.
Unfortunately you can’t “pack” a base color, But you could toss a custom roughness in the Alpha and use it instead of the other channels.
Won’t be much of a performance improvement, but its 100% better than loading a different texture all together for each layer.
AS always.
Careful what you do, as landscape materials eat up around 90% of the performance using the default blend nodes the engine gives you.
I posted about ways around that several times, if the posts still exist after the flop that was the forum move.
You can also look into material branching execution. There’s a flaming topic describing how it doesn’t work but should, with solutions, and it’s particularly helpful to limit the complexity of the material on individual components.
Mind you. Overall you are still better off only using the landscape stuff to bake a mesh to use later.
This will probably always be the case thanks to epic.
Thanks for the input. I tried placing the macro variation (with a different texture than the landscape color) and the texture variation (with the node of the same name) in separate material functions. In the macro variation I put 3 function inputs for the 3 scalar parameters of metal, spec, and roughness, plus the main texture of the landscape all plugged into a make material attributes node. Setting the normals in the other variation function ensured they are getting that variation, I think, not completely sure though. Then in the material to apply to the landscape, I used Get and Set Material Attributes from the Macro variation function and connected each to a Blend Material Attributes node that has B empty, with the Alpha as the Texture Variation function. As far as I understand, it’s blending the attributes from the Macro variation based on the texture variation with normals then. The outputs of those connect to the layer blend node, having 2 layers, one for the shiny metal rock and one for the dry rock. It’s the same texture for both layers, but one is metallic like and one is dry rock because we’re simply trying to paint a few areas shiny yet having the same texture.
However, when painting, all I’m getting is the dry rock. I have the layerinfo objects assigned to the two different layers, but trying to paint with the shiny metallic layer is exactly the same as the dry layer. Not baking the landscape mesh for later use, and the landscape is not going to contain more than a few layers at the most. I don’t yet know how to pack the RGBA channels separately, enough at least (I’ve watched tutorials but haven’t tried it), to attempt that approach for now. I stopped trying to blend macro into the metal, spec, and rough pins of the main material node.
Thanks again. Do you have any other feedback or insight about this to get it working so I can simply paint from the two layers?
Functions and scalars override or are overridden by same name scalars.
If you nest a function with a scalar called X, inside a function with a scalar called X, they all assume same value.
You are adding RGB into a normal map.
That’s not really how normals work.
R is how much towards the right, G is towards top. B is height/depth. (Or swizzle the R and G, but its the same theory)
Any operation on it is probably also throwing it out of the 0 to 1 range. So clamp. Regardless of the process being incorrect.
Overall, for what you need, what I see seems way too complex.
Functions are ok, but the idea is to use them to reduce the amount of noodles - and scalar inputs with same names are kinda useless (until they change things again anyway, I’d keep the input, but would default it to the scalar/not plug a value to it)
Also, I’m not really following the logic of the break/make blend.
You are literally blending into nothing.
That can work if it’s what you need, put a red or a green into it to visualize if the alpha blending is even happening - since there’s no black on the screenshot, I would assume it’s not.
I used the BlendMaterialAttributes to connect the Macro with the Texture Variations, and have one output to connect to the Layer Blend Node. Otherwise, with the two functions there’s two wires that need to be connected to one input (on the Layer Blend Node). I wasn’t sure how else to do it. Do I multiply them, lerp, add, what is it?
Thanks for the info on scalar same names. I saw something in a tutorial and tried to replicate it, but obviously did it incorrectly.
I definitely deleted the normal from heightmap stuff because it was messing up the normals. I didn’t notice it until I got another aspect of the paint layers working, and it showed up having colored lines in it kinda merging with the texture. Plus, I hadn’t clamped it. I removed the scalar inputs too. I think they were interfering with the scalars nested in the macro function, not only because they’re the same name but also because one is being prioritized over the other. I saw this when I changed the values of one, and it didn’t change the result, whereas changing the value of the other scalars did change result.
Is Get and Set required in the context of using those functions? I saw that in another landscape material and wasn’t sure how it may be affecting the final result. I think it is too complex for what I’m trying to do too, but I don’t know how to simplify it so I can plug everything into 2 layers for the layer blend node and it works…
Create a function that outputs a material attributes node.
Add necessary input and scalars as default values within the function.
In the material, make 2 copies of the function.
The scalars within will override each other, so create and connect scalars with different names for the second function.
those are your 2 base layers.
Now create a second function for the macro variation.
Insert the function between the output node of the previous function so that both instances of the material have the macro variation applied.
Output the 2 functions directly into their respective layers.
You’ll need to break their output.
Create a copy of the layer blends to use for each output you need.
Base color, specular, roughness, metallic, and Nomal.
Then just connect the dots to the output node (or another make material).
Prototype this by using a simple color output in the function until you get it to paint what you expect.
And work on a single component landscape so you don’t wait 30minites for shader compilation between edits.
Thanks for that. I did it and it worked. Now I’m trying to include the texture variation I had before and I don’t know where to put it. I tried in the macro function, but it’s a 2 vector output and the macro is a material attributes output. I placed the texture variation function between the make mat attrs node and the output node, and it wasn’t compatible. I tried multiplying the two before the make attributes node, and it’s not compatible. Is there a transform node for this, lol?
All break material attributes pins are 4 channel max outputs.
I’m not exactly sure what the theory on mf_texture_varia from the screenshots above was, but that looks like a UV output so it needs to be within the material layer function you created to plug into the uv.
The other (3 textures with different uvs) applies directly to base color somehow.
Add, multiply, divide. Etc (clamp it too).
You can apply it as an overall at the end.
This is commonly the way you add landscape shadowing for fake clouds.
Remember the result of the macro has to have a very light intensity to not just completely change the base color.
Or you can use it as the alpha of a lerp like you did before, just blend the base color as 1, to a darkened base color as 2.
(Subtract .2 from the base color and clamp, for instance as B in the lerp).
Thanks again. I was thinking of using something other than Make Material Attributes so I could avoid having to add another function or something to get that MF_Texture_Varia working. It’s set to do random rotations and blending on a texture2d object of the diffuse texture I’m using as the landscape, only I change it to grayscale heightmap for that particular variation node in it. The macro variation is merely an overlay, while MF_Texture_Varia is intended to get variation of the diffuse texture and its normals, so there isn’t any repetition of the UVs. It was working well before I tried to use layers, and I even had a material with the two layers, but if I selected one of the layers it would cover everything with that layer and I couldn’t paint individually with the layers in different areas. It was also set to Alpha Blend in those layers for the older material. This landscape layering in Unreal Engine is far too complex to get 2 simple paint layers with two types of variation and a few attributes. I could’ve probably completed this in CryEngine by now without having to rework things a ton.
You could plug it into a custom uv for the the material, and then use the custom UV on the textures (change the uv as an input and feed it to the function).
So, I rearranged the material and the functions, plugged the texture variation output into the UVs of the macro function and into the UVs of the base texture and normal texture inside the material. I was getting the first layer to display, but then I cleared both layers (right-click > Clear Layer) and redid layerinfo objects, and now neither layer is showing. Here is my material in the M.E. currently:
I haven’t used custom UVs yet, partly because I don’t know how to connect it all correctly. Do I need to use Make Material Attributes and/or Break MAs somewhere in the material? The macro function is simply outputting the result of the 3 textures at different scales and varied in contrast / grayscale intensity, and the texture variation connected to the UVs for each of the 3 textures. The texture variation function is the same as before except I changed a few of the input parameters and made a function input as 2vector to get the UVs from the base texture and its normal, and it worked when applied to the macro textures. Why is it currently not rendering either of the layers when I paint?
Well.
First thing first. You can’t be “afraid” to play around and sling mud in the material editor.
Sure, if you get lost you’ll loose days in it, that’s true enough. But do experiment.
The custom UV is just that.
You can plug the math I to a pin and then use that UV anywhere in the material to call on that math.
(Be it just math, maybe like the result of a grstner wave, or an actual UV).
The primary benefit is to push the calculations on the GPU.
BUT - since like .22 or maybe prior the material will already optimize and group all the calls for you. So it’s not necessarily a performance savings.
What do I mean?
Take your current material. You are currently “solving” the same UV 4 different times
Plugging it directly into the custom UV and re-using the value would mean you are only doing the Calc once.
Instant benefit, right?
Wrong. The material editor should at least automatically be compiling your material in exactly the same way.
For clarity and because I care about it, I would still plug it into the custom UV and re-use it.
With that explained.
I honestly don’t know.
Does Set material attributes work exactly the same as Make material attributes?
Could that be why it’s not rendering for you?
That’s what I was wondering too, if Set is the same as Make. I’ll try the custom UVs, which would at least reduce the density of nodes. It could be why it’s not working yet, as it may be overlapping those UVs from calculating them multiple times, then overlapping them or trying to render it and failing due to unknown constraints or a lack of something. I read in the doc that material functions can break if they’re changed while being used in a material, which implies the need to create functions before placing even one of them in the material to avoid that. It sounds unreasonable to do, though.
Perhaps there’s a tutorial on youtube of how to combine functions with landscape layers correctly, and/or a video of how to use Set Material Attributes. I could have the wrong order of connections.
Your end result UVs could just be wrong too.
Particularly if not using it shows a result.
And do swap your material to use material attributes.
Currently you are trying to use a material attributes node as the base color.
If you want to avoid splitting again, just change the material settings and the output should then just work.