Hi,
Our team is currently facing a performance issue, where we have too many material instances in our project. We are considering using Custom Primitive Data to reduce the amount of MI, but are facing an issue preventing us to use it as its full potential: a good part of our assets are using multiple materials.
This becomes an issue with architectural elements that would be difficult to split and where having different values for the same CPD would help our MI usage. An example would be a wall with a painted part: we’d like to make the paint different colors and roughness without impacting wood trims, but as they inherit all from the same master material, this is impossible.
Our main questions are:
- Is it possible to use CPD workflow with assets using multiple materials and requiring different values for the same CPD?
- We found out the default value of a CPD is always 0, which can lead to convoluted logic to take this into account. Couldn’t it be configured otherwise?
Thanks you for your insight on this subject.
Hello,
Thank you for reaching out.
I’ve been assigned this issue, and we will be looking into it for you.
Hello,
Thank you for reaching out.
Is it possible to use CPD workflow with assets using multiple materials and requiring different values for the same CPD?
The CPD slot itself is on the component so materials read the same value. However, the value itself could be a packed value which could be decoded on the material side. This basic idea can be carried out in a number of ways, including bitmask comparison.
We found out the default value of a CPD is always 0, which can lead to convoluted logic to take this into account. Couldn’t it be configured otherwise?
We will look into this further and get back to you.
Here are some suggestions for reducing the material instances if you have not considered it already:
If all these Materials use the same lighting mode, opacity etc, you can use Layered Materials with different CPD indices that correspond to different layers.
Please take a look at Layered Materials Overview documentation
https://dev.epicgames.com/documentation/en\-us/unreal\-engine/layered\-materials\-in\-unreal\-engine
You can also implement a typical “mask and select” technique which will provide multiple surface outputs from a single material as needed. In essence, part of the mesh is masked and this mask determines the surface output. A mask is obtained by sampling a texture channel or vertex color. Then, this mask is used to select a surface output with arithmetic. See Unreal Engine’s Switch Material Expression for an example of how this can be done. This technique can replace the need for multiple material slots and instances.
Please let us know if this helps