subgroupMax
Performs a max reduction of the input e over all active invocations in the current GPU subgroup and broadcasts the result. Also known as: Subgroup Max, Wave Max, Warp Max (conceptual synonyms; the TSL API name is fixed as subgroupMax).
Core Advantages
Hardware-accelerated subgroup reduction with high throughput and low overhead; no explicit loops, shared memory, or barriers required to get a consistent intra-subgroup maximum.
Common Uses
Intra-subgroup gating/threshold decisions
Wave/warp-based banding or quantized highlights
Fast local peak luminance/intensity for mixing or thresholds
Driving effects in fragment/compute with a local "max response"
How to adjust
Takes exactly one scalar e (enforced by setParameterLength(1) in the source). The result is constant within a subgroup, ideal for mix/step/threshold chains. Available only when the backend supports subgroups (e.g., WebGPU 'subgroups' or relevant GL extensions); provide a fallback on unsupported platforms (e.g., use e directly or a coarser max). For vector inputs, reduce to a scalar before calling.
Code Examples
1<mesh>
2 <sphereGeometry args={[0.6, 128, 128]} />
3 {/* Subgroup max: shared highlight weight within each subgroup */}
4 <meshStandardNodeMaterial
5 colorNode={
6 mix(
7 color(0x2e8b57),
8 color(0xffc107),
9 subgroupMax(
10 clamp( dot( normalWorld, vec3(0.5, 0.8, 0.2) ), 0.0, 1.0 )
11 )
12 )
13 }
14 roughness={0.35}
15 metalness={0.0}
16 />
17</mesh>