Custom Material, Custom Mask, fetching colors or (sub)parameters from vectors

I am in the progress of porting a scene (just graphical) from a game we made in our own engine, into unreal engine.
In the game we have a custom shader, Where R,G,B describes the mask/amount of one type of texture (Three in total).
Since our artist painted the mask freehand in photoshop, the total added texture value will in many cases be bigger then one.
We solved this in our originial shader by Normalizing the color range. Thus giving us a total of 1.
Then add these together and out it, as diffuse.

The problem I am having is this.

  1. I can’t create a separat Vector3 and set it from the texture color, (then normalizing it to the correct range)
  2. I can normalize the output of the texture (this does in theory work since I have no alpha value, but might not be ideal as alpha could come to represent something else)
  3. I have no idea how to access the raw RGB(XYZ) from the vector i get back to use the result with the texture as a mask value since the output of all operations seems to be a vector3.

I guess the question is, whats the easiest way to set the values for a vec3 from any source, and access them per element?

What you’re looking for is the BreakOutFloat3Components node, which breaks a float3 into 3 floats (it has float2 and float4 versions). Internally it uses the ComponentMask node, which is like a swizzle in HLSL. So you’ll want to take your texture sample, ComponentMask(R,G,B) it, normalize that, then feed it into BreakOutFloat3Components, and use the scalars to mask out your other textures.


I expected something like that to exist, but that would not be the first name I guessed on. :slight_smile:

Technically it would be possible to feed in other materials instead of just textures as well with some cleaverness I would assume.

Check out the MatLayerBlend_ nodes for blending entire materials, odds are there’s a premade node for pretty much anything you can think of.