mx_separate
Splits a composite input (vector/color) into a single component (x/y/z/w or r/g/b/a). It also accepts 'outx/outy/outz/outw' aliases and numeric indices; if omitted or unrecognized, it returns the original input.
Core Advantages
A unified, forgiving channel accessor that supports multiple aliases and static indices with one API, reducing boilerplate and alias/casing errors; it leverages .element() underneath for clear intent.
Common Uses
Use uv()'s x or y to drive color mixing or roughness independently.
Extract the alpha (a) from a vec4 for opacity/masking.
Unpack packed data channels (r/g/b/a) to feed different computations.
Route different vector axes to separate node graphs.
How to adjust
Select the component via the second argument: 'x'|'y'|'z'|'w' or 'r'|'g'|'b'|'a'; 'outx'...'outw' are also accepted; or pass a static numeric index 0–3. If omitted or invalid, the original in1 is returned. Note: the index must be a static number (not a dynamic node).
Code Examples
1
2<Canvas>
3 <mesh>
4 <sphereGeometry args={[0.5, 128, 128]} />
5 {/* Split uv into x/y and feed different material slots */}
6 <meshStandardNodeMaterial
7 colorNode={mix(color(0x2e90ff), color(0xff7a59), mx_separate(uv(), 'x'))}
8 metalnessNode={mx_separate(uv(), 1)}
9 roughnessNode={mx_separate(vec3(0.2, 0.8, 0.5), 'g')}
10 />
11 </mesh>
12</Canvas>
13