GageCornelius

It's me again! I'll keep it short and sweet this time:

Is there a way to replace the materials once they are in UE4?

Also, I was having a peek at the material setup, and I wondered: Why are you guys passing all of the material maps individually? Is there an advantage to that method as opposed to passing it as a MaterialAttribute?

I was thinking of a system where you have all of your MaterialID's expressed as functions and output the MatterialAttribute only. This way if someone wants to replace a material, all they have to do is go into the function for that material, and customize it themselves. Thoughts?

0 0
voxelfarmtorres
It is not clear what you mean by "passing all of the material maps individually". That is not the case, material maps are all baked together into a single atlas map.

UE4 is limited on how many different UE materials you can layer. Voxel Farm worlds typically include dozens of different materials. This would be too much for UE4 material layering system. For this reason, the default Voxel Farm material uses an "uber-shader" where all Voxel Farm materials are handled by this shader. This shader will sample from the texture atlas based on material IDs that are linked to each triangle produced by Voxel Farm.

You can still change how all of this is shaded, however, we believe this system is able to provide the best performance.
0 0
GageCornelius

Well, you have the inputs for the material ID, and you keep passing along the individual components, and getting to the end you export the individual components. What I'm doing here is just changing the start and the ends. I'll try to work on it tonight, see what it gets me. I may also try what you have here to see if they can work with some of the landscape layering functions, and then compare it all.

 

So: Is there a way to replace materials in UE4?

 

P.s. - Here are the pictures of the before/after of the ComputeMaterialIDInfo function (Sample2), and the MixShadeSubMaterial function (Sample1). It was a minor change, i just presumed it might be a tad more efficient to do it this way, and if a way to customize the materials occurs, it might be the way in to blending things together. And again, that is assuming that you want to organize it this way. You can plug some of the things I plugged into


Sample2_A.png
 
Sample2_B.png *Plug things in differently, lots of custom nodes.
 Sample1_A.png
 Sample1_B.png

0 0
voxelfarmtorres
I'm sorry I still do not understand your question.

"Is there a way to replace materials in UE4?"

Do you mean replace UE materials or VF materials?

It seems the forum software made your blueprint captures illegible. Can you send this to support at voxelfarm.com?
0 0
GageCornelius

Replace VF Materials in UE4. Email has been sent.

 

Reason I ask about the Material attributes is because they do a great job of blending whole materials so long as you have the proper alpha for the blends, and what I saw seemed very manual.

0 0
voxelfarmtorres
Yes, but our tests with Layered Materials did not perform well. Some of our use cases have hundreds of different materials and we needed to support that. Let us know how it goes in your test.
0 0
voxelfarmtorres
From UE4's documentation:

Quote:
Keep in mind that all of your layers are rendering simultaneously, and then blended. For instance, if you had 4 layers in a Material, then for each pixel of your object, the system must test to see which of the four is blended, and rejecting any not in use. This added calculation makes the Layered Material more performance intensive.


If you have 100 different materials, which is a common case for production quality terrain, these 100 layers will be tested. This may not be a problem in your case, if the number of layers is not large.
0 0
GageCornelius

I will. I've managed to (mostly) recreate the building tools of EQN Landmark, and I had an idea about having 2 different VoxelFarmWorldActors in the game. The main one for landscape, and then another only to handle structures with a lower LOD than 2 so I can get better detail out of them, but I haven't tested that yet.

 

Also: It seems to me that what you do is essentially input the data necessary for the cell, get the index on the atlas, isolate it and use it for the 3 materials you need (as well as have the masks for the final blend) and then you blend them. But it's just 3 materials for any individual cell, correct?

0 0
voxelfarmtorres
Yes, correct, only 3 materials at any time. This constraints material transitions within a single triangle, but it is much faster since sampling different texture maps is probably the most expensive operation.
0 0
GageCornelius

I'm going to add making a simpler material blending the 3 material ID's and their corresponding maps as named vector parameters, and then making a material instance from that material to utilize, and the data sent to it will only be the MaterialID's. I can make a structure for the different types of variables, and then combine them in a larger structure so I can make a DataTable in UE4 where I can specify all of the variables I want. Then I can have blueprints do the rest by looking up the data in said data table, and plugging in the values that are specified, this way if something remains unchanged, the default values of the material instance won't affect the material in any way I deemed unnecessary. It might be frugal as well to take Material Instances that use the same 3 materials in them, and keep track of them. This way if I need to use the same combo, I'll just (via blueprints) Create a Material Instance duplicate of the Material Instance that utilizes the same 3 materials, and only alter the input RGB masks to change where they go.

0 0
voxelfarmtorres
Not sure I follow. You intend to create a material instance for each combination of 3 different voxel farm materials appearing in the cell? This is similar to something we tried, we saw instancing of materials was expensive. Again, maybe not an issue in your case due to a lower material count.
0 0
GageCornelius

I intend only to create 1. I'll have VF keep an array of material instances as it makes them and keep track of the 3 materials in them, filling in the variables from a data table where I'll have all the inputs the materials for said materialID. If the same 3 ever come up again, I'll just make an instance of the instance that originally had the 3 materials, and change the mask input value. Maybe to save on processing power, I can organize the output of the RGB mask based on the number value of the materialID. Heck, I'll compare it several ways, including a multidimensional array so that the first indexed material is organized in its own array, so this way instead of cross-referencing 100's of potential materials, I only have to check the materials inside the array that start with that first materialID. Of course, I would only have to do this for material combinations that are drawn, so I would have the cells spit out the 3 materials in their use to the VoxelFarmWorldActor for it to keep track of what materials to have on-hand. This way instead of having everything available at once, it only becomes available as the play moves through the world, and the cell LODs change to depict more detail, or less detail. But it may not save on much in the way of resources other than processing power to keep track of the combinations, since there would still be just as many instanced materials. But perhaps a double instancing will make SOME kind of difference, since each instance essentially becomes a format.

 

But I intend to use the data table to keep track of all the variables that all of the materials will use. If it's good enough, it may be worthwhile for me to look into more advanced things, such as making the textures less repeatable via a distance smoothing method and/or multiple textures for a material to randomly blend in and out smoothly so it isn't the same singular texture for grass repeating itself. Or I may include a randomizer so that if I supply 3 different materials for a wood grain, it can choose at random which one to utilize so long as there isn't a cell too already using one type, but being so close that they don't blend.

0 0
GageCornelius

So far, here's how I'm organizing this:

 

Voxel Farm creates a structure composed of 3 arrays. Each array is its own structure. They are as follow:

MapStruct -  (ParamName, Texture)
ScalarStruct - (ParamName, Float)
VectorStruct - (ParamName, LinearColorStructure)

Then the Vx Plugin creates a DataBase. The DB only fills MapStruct with 6 elements (Diffuse, Displacement, Emissive, Metallic, Normal, Roughness) for each DB item based on the materials that have been defined in Voxel Studio.

Whenever each cell receives its data, it'll fill in the "Mask" similar how you have it in the atlas, supplying it to the texture directly while all of the other information is drawn from the DataBase that was created.

After it sets everything up, I'll be able to go into UE4's material map for the cell, and add as many variables as I desire. All I will have to do from that point is add the information to the Database according to each corresponding structure, and only add data that is different from default values.

CellCreated-> VoxelDataReceived -> for each materialID supplied -> LookUpVoxelDB-> Sequence1(ForEachLoop(MapStruct)->SetTextureParam(ParamName, Texture))-> Sequence2(ForEachLoop(ScalarStruct)->SetTextureParam(ParamName, Float))-> Sequence3(ForEachLoop(VectorStruct)->SetTextureParam(ParamName, LinearColorStructure))

Of course I have yet to do the bit where the VoxelFarmWorldActor is keeping track of which 3 materials get put together, and I would also like to try to create a system where certain MaterialID's will use other instances of the CellMaterial that have special properties in them. I'm planning on having Gem Ores and Thick Ice utilize Subsurface Shading, and then not to mention potentially utilizing other ones such as glass and Thin Ice to use a MaterialInstance that is translucent rather than Opaque, but then I'll have to create a whole algorithm so that a material won't have the translucency issues based on the distance to itself, which will require me to play around with Unreal's Post Processing effects.

I'm still in the process of implementing all of this. Anyways, what do you guys think?

0 0